Gravity is quite simple to create or mimic in Scratch - this short code snippet will show you how to implement it.
Look at this picture and this will show you how to implement gravity onto your sprite.
You will also have to declare one variable (in this example it's identified as setY).
Things to consider:
- Ground is set by the color Cyan (light blue) as indicated by the touching color block. You can set ground as a sprite or anything else.
- Movement (this is only up and down)
If you have problems making your character move left and right (even while you are jumping, then take a look at this other example I've kindly created for your convenience.
If you implement this, it will create smooth movement (even while jumping, you can still move around).
Last edited by Nick60 (2010-05-10 18:07:46)
Offline