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

#1 2011-02-11 21:43:17

Knoxx
Scratcher
Registered: 2011-01-17
Posts: 3

How do you stop a sprite from moving?

Hey, i'm trying to make a classic top down R.P.G. I want to know how to stop my Character from moving on the border of my cliff. Can Anyone tell me what to do?

Offline

 

#2 2011-02-11 22:21:44

blahdeblah
Scratcher
Registered: 2008-02-19
Posts: 45

Re: How do you stop a sprite from moving?

I guessing you want to have your character controlled with the arrow keys and stop when hitting the cliff. There are many ways.
If the left/right keys rotate the char, and up moves it, say, 5 steps, then add this to this to the movement script:
If (touching "cliff")
Move -5 steps

What I recommend you do for that R.P.G is to create the ground as part of the background costumes, and then create a collision map sprite, I guess, with impassable spots filled in to their corresponding parts in the background.  Hide this sprite. The script is basically the same.  It could save you from having a lot of sprites.
Hope I helped  smile

Offline

 

#3 2011-02-12 05:14:18

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: How do you stop a sprite from moving?

It completely depends on your movement scripts.
If you have one where it turns around and moves, you could have an is touching obstacle move -## steps.
If you have something different maybe you could keep a LastSafeX and LastSafeY variable that is constantly setting to X and Y if not touching obstacles, and then the X and Y are set back to it if touching obstacles

Last edited by colorfusion (2011-02-12 05:14:47)

Offline

 

#4 2011-02-14 17:10:34

Knoxx
Scratcher
Registered: 2011-01-17
Posts: 3

Re: How do you stop a sprite from moving?

Thanks :-)

Offline

 

Board footer