This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-23 14:05:53

DaiDaiDaiDai
Scratcher
Registered: 2013-02-20
Posts: 5

How to stop falling ....

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

 

#2 2013-02-23 15:09:34

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to stop falling ....

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2013-02-23 18:07:38

DaiDaiDaiDai
Scratcher
Registered: 2013-02-20
Posts: 5

Re: How to stop falling ....

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

 

#4 2013-02-24 12:11:26

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to stop falling ....

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.


http://i46.tinypic.com/35ismmc.png

Offline

 

#5 2013-02-24 14:07:38

DaiDaiDaiDai
Scratcher
Registered: 2013-02-20
Posts: 5

Re: How to stop falling ....

yes, I'm using ceilings in my game

thx for your hlp

Offline

 

#6 2013-02-24 15:40:50

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How to stop falling ....

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)

I hope that this helps!

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer