Discuss Scratch

LY_Casserole
New to Scratch
1 post

Keeping Sprite on Moving Platform

How do you keep your sprite on a moving platform and make it stay there until arrows are clicked?
deck26
Scratcher
1000+ posts

Keeping Sprite on Moving Platform

For a single platform you just need to know whether the player is on the platform and their position relative to the platform centre - essentially an x-offset. So you then set the player's position to the cloud position plus the x-offset. This works regardless of how the platform is moving - vertically or horizontally, assuming the player is only moving horizontally on the platform.

As with a player carrying a sword or similar item you need to control the order in which things happen so you move the platform first and then position the player using a broadcast, for example.

If the player moves on the platform you can do this just by changing the x-offset value but when they go off the end of the platform their movement is no longer affected by the platform. But that's just an if/else controlling their movement.

If you have more than one platform this raises additional questions - are they all moving at the same speed and in the same direction? If so a single sprite may suffice but otherwise you need to know which platform you're on.

Powered by DjangoBB