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

#1 2010-01-15 16:11:27

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

If touching ___ do this...

I'm having another difficulty.

I have two sprites, one that moves (Sprite1) and one that's immobile (Sprite2).

I want Sprite1 to do something like this: If touching Sprite2, stop moving.

However, when a different arrow key is pressed, Sprite1 can move. I don't want it to be able to stop moving forever. Any suggestions?


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#2 2010-01-15 16:16:58

BWOG
Scratcher
Registered: 2008-09-19
Posts: 1000+

Re: If touching ___ do this...

Make a variable called "move". For the arrow key scripts, put the script inside of an if block, like this:

When key pressed
If <(move) = (1)
|Move (_) steps
End if

Then make a script like this:
When green flag clicked
Forever
|If <touching Sprite2>
||Set (move) to 0
|End if

Offline

 

#3 2010-01-15 16:45:06

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Re: If touching ___ do this...

I did what you said, but when it does touch the sprite, it sets move to 0 and then it's incapable of moving at all, since move does not equal 1.


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#4 2010-01-15 17:49:21

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: If touching ___ do this...

You really need sensing... you could look at my Almost Perfect Platformer project for help...

Offline

 

#5 2010-01-15 18:04:41

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Re: If touching ___ do this...

shadow_7283 wrote:

You really need sensing... you could look at my Almost Perfect Platformer project for help...

Actually, I tried this. I did use sensing with it, but ultimately, I need it so that it can still move after it touches the sprite, except not in the same direction as when it bumped into the sprite.

Or something.


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#6 2010-01-15 18:11:38

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: If touching ___ do this...

Can you upload your project so I can see exactly how to help?


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#7 2010-01-16 07:29:43

AnimationMan
Scratcher
Registered: 2009-05-04
Posts: 46

Re: If touching ___ do this...

New blocks is a good idea. But they can't program everything. Love the idea!


I love my MacBook Pro!

Offline

 

#8 2010-01-16 10:41:51

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Re: If touching ___ do this...

It's sort of like the Pokemon games. If the player touches a house, they are unable to continue any further in that direction. However, when they press another arrow, they can continue along their way.


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#9 2010-01-22 02:13:19

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: If touching ___ do this...

See if you can find my solution to this problem with walls in this app...
http://scratch.mit.edu/projects/Locomule/708768

Not only was the player initially getting stuck in walls, it also had another problem with corners where two walls met. Fixed all that.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer