How do you make sprites stand on top of each other? In my project I need the sprite to walk accross a floor... For some reason the sprite goes through the floor and walls.
Offline
Well the walls part is going to be a bit trickier. Either your going to need a sensor (nice article), or complications in your script. Now, for your gravity would you like to see the simpler method or the more complex that's also more realistic?
With regards,
ErnieParke
Last edited by ErnieParke (2013-02-23 15:09:53)
Offline
Thank you for your input Ernie...Either will do. I'm fairly new to scratch so the simpler method is fine but if you feel like posting the more complex method plz go ahead.
Offline
Okay, seeing as you are new, I'll get you the simpler method, though I have on last quick question; do you have any ceilings in your game I'm asking this because if I don't know this, then I might not get you the best script.
Offline
yes, I'm using ceilings in my game
thx for your hlp
Offline
Okay, so that's going to complicate things, and it's going to be best for to use the more advanced method. Now, you'll need to replace your jumping/falling script(s) with this:
when gf clicked set [Y Velocity v] to (0) forever if <<([up arrow v] key pressed?) and <(Y Velocity) = (0)>> and (touching [ground/ceiling color]?)>//The jumping part set [Y Velocity v] to (7)//Jump strength else if (touching [ground/ceiling color]?) if <(Y Velocity) > (0)>//Detects floors and ceilings set [Y Velocity v] to ((0) - (Y Velocity))//Ceiling else set [Y Velocity v] to (0)//Floor end else if <(Y Velocity) > (-5)>//Maximum falling speed change [Y Velocity v] by (-.5)//Gravity end end end change y by (Y Velocity)
Offline