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

#1 2010-08-04 18:26:36

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

If Touching Ground, Change y by 1 Doesn't Allow Jumping

I'm making a platformer, and to ensure that the player doesn't go through the ground, I added 'If Touching Ground, Change Y by 1'. The problem with this is that I also made it so you can't jump unless you are touching the ground. Anyone know of an easy fix for this?


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#2 2010-08-04 18:29:24

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: If Touching Ground, Change y by 1 Doesn't Allow Jumping

This way is easier:

These scripts are from Clash.

This is pretty much how it works:

http://i25.tinypic.com/e0hfno.png The Sensor's Scripts:

http://i28.tinypic.com/2ui7io3.gif

http://i30.tinypic.com/29goawx.jpgPlayer1's Scripts:

http://i32.tinypic.com/359h8uu.jpg


PS: This tests for each side instead of the entire sprite. Hope this helps!  wink

Last edited by Jwosty (2010-08-04 18:30:20)


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#3 2010-08-04 18:34:34

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: If Touching Ground, Change y by 1 Doesn't Allow Jumping

Jwosty wrote:

This way is easier:

These scripts are from Clash.

This is pretty much how it works:

http://i25.tinypic.com/e0hfno.png The Sensor's Scripts:

http://i28.tinypic.com/2ui7io3.gif

http://i30.tinypic.com/29goawx.jpgPlayer1's Scripts:

http://i32.tinypic.com/359h8uu.jpg


PS: This tests for each side instead of the entire sprite. Hope this helps!  wink

Huh? I know about adding sensors and all that, but I want the character to travel to the top of the land because with y velocity, he travels through to the middle of the ground.


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#4 2010-08-04 18:42:15

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: If Touching Ground, Change y by 1 Doesn't Allow Jumping

Simply make a small sprite (a single pixel will do) and send it to the x position of your character, and your y position minus enough so that it's barely off of the bottom of the character. Hide it, and use that as a sensor for whether or not it's touching the ground.

Sorry if that wasn't specific enough for you  smile  I can write up a more detailed explanation if you wish.

Offline

 

#5 2010-08-04 18:49:58

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: If Touching Ground, Change y by 1 Doesn't Allow Jumping

coolstuff wrote:

Simply make a small sprite (a single pixel will do) and send it to the x position of your character, and your y position minus enough so that it's barely off of the bottom of the character. Hide it, and use that as a sensor for whether or not it's touching the ground.

Sorry if that wasn't specific enough for you  smile  I can write up a more detailed explanation if you wish.

That makes sense. Thanks  smile


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#6 2010-08-04 19:00:04

roger-
Scratcher
Registered: 2010-02-13
Posts: 100+

Re: If Touching Ground, Change y by 1 Doesn't Allow Jumping

just put the jumping script in front of the script that makes it move up if touching the ground. if it was the other way around, it would move above the ground before you jump, so you weren't touching the ground and couldn't jump.


Food is Fat. Fat is power.
        I am almighty.

Offline

 

Board footer