在 Scratch 中拖动精灵
如何在 Scratch 中执行期间拖动精灵?
How do I drag sprites during execution in Scratch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在 Scratch 中执行期间拖动精灵?
How do I drag sprites during execution in Scratch?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
Scratch Wiki 对此进行了介绍。
boisvert的答案在技术上是正确的,但是,他的脚本总是将精灵从其中心拖动。使用稍微更高级的脚本将从拾取的位置拖动,更像是挂锁:(
上面的 wiki 链接具有这是视觉块格式。)
This is covered on the Scratch Wiki.
boisvert's answer is technically correct, however, his script will always drag the sprite from it's center. Using a slightly more advanced script will drag from the spot it was picked up, more like the padlock:
(The wiki link above has this is visual blocks format.)
单击精灵名称旁边的挂锁。它看起来会是开放的;然后精灵在可执行版本中变得可拖动。
或者,您可以使用脚本对其拖动行为进行编程:
它可以变得更聪明,在偏移位置跟随鼠标,有延迟,在放下时捕捉到某个位置,在鼠标经过它时突出显示某些内容...如果您使用脚本,您的选择是无限的。
Click the padlock next to the sprite name. It will look open; then the sprite becomes draggable in the executable version.
Alternatively, you could program its dragged behaviour with a script:
it can be made more clever, to follow the mouse at an offset position, with a delay, snap to a position when dropped, highlight something as it passes over it... If you use a script your choices are limitless.
要获得快速简单的路线,您所要做的就是单击精灵的信息按钮: 单击此处查看图片1。
之后,您应该找到显示“
可以拖动播放器
”的框,然后单击:点击此处查看图片 2。事实上就是这样。现在,每当有人玩你的游戏时,他们就可以拖动精灵。您只需让他们知道这是可能的,因为大多数项目不允许这样做。
For a quick and simple route, all you have to do is click the info button of the sprite: Click here for image 1.
After that you should find the box that says:
can drag in player
and click that: Click here for image 2.This is actually it. Now whenever somebody plays your game they can drag the sprite. You just have to let them know that it is possible since most project don't allow it.
如果您不介意在脚本未运行时精灵是否仍可拖动,则可以在选择精灵时按右上角的
i
按钮。然后,按可以在播放器中拖动
。但是,这不适用于 Scratch 3.0,因此您需要使用我的其他方法,即脚本。If you would not mind if the sprite is still draggable when the script is not running then you press the
i
button at the top-right corner when the sprite is selected. Then, you pressCan drag in player
. However, this does not work for Scratch 3.0 and so you would need to use my other method, scripting.您可以使用
布尔值、touching [mouse point]?
以及变量(mouse x)
和 < code>(mouse y) 获取鼠标坐标并检测鼠标是否按下。您可以这样做:如果您在其他方面需要更多帮助,可以关注我 >如果你想@endermite334。
You can use the
<mouse down?>
boolean, thetouching [mouse pointer]?
and the variables(mouse x)
and(mouse y)
to get the mouse's coordinates and to detect if the mouse is down. Here is how you can do it:If you need more help with other things, you ca follow me if you want to @endermite334.
在 Scratch 3.0 中,精灵默认是可拖动的。您可以使用
设置拖动模式[不可拖动]来更改它
Sprites are by default draggable in Scratch 3.0. You can change that by using
set drag mode [not draggable]