0

我带着更多的决心回到这个项目来修复我的旧错误。

见:https ://scratch.mit.edu/projects/75999804/

问题描述 当使用“触摸颜色”感应块时,它可以正常工作(尽管会反弹并且可以正常跳跃)。我想制作自己的触摸传感器以进行更多控制(使用不同的对象、不同的颜色等)。但是,我的触摸传感器不能以相同的行为工作,我不明白为什么(精灵不再正确“弹跳”和“跳跃”)。

查看问题在行动 比较行为 - 请参阅问题区域的 scmpoo sprite 中的注释 - 在永久循环下方将以下“touchingFoot = true”与“touching color [brown]”交换它们应该具有相同的操作,但您会看到行为差异

TouchingFoot(和所有传感器)在游戏中声明,并且是连续循环广播(以感知与所需对象的接触)。

希望有人能帮忙,我真的在这里挠头(不是双关语)。

-- 更多细节 - 2018/04/25

我想尝试使用传感器来避免很长的 if 语句。(如果我把它做成一个有许多平台的横向卷轴,这可能会发生)。证明很难找到正确的逻辑。(我看到的问题是,当精灵只接触其中一个块时,来自其他块(not_touching)的请求正在与它正在接触的块循环竞争。

我一直在寻找一种在平台内执行检查的方法,尽管它本身。(使 if 语句更易于管理)。

4

1 回答 1

0

Answer: I can't get your project to work properly, but the following will make it behave like the "touching colour [brown]" block.

Change:

Script to change

To:

Script changed

Why:

Your previous script checks for collisions with one sprite and sets the variable, but if it is not touching the second sprite it gets reset to "false". This means it will only trigger if your sheep is touching all of the sprites.

Edit: This is if you want to do it in the platforms. Change the script in your 'game' sprite to:

Script changed

Also change the sprit in your platforms to:

enter image description here

This resets the sensors. Then it broadcasts 'collisiondetect', and the sensors are set to 'true' if there is a collision. Done in a remix.

于 2018-04-23T17:46:59.247 回答