Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Change X past the edge
- wilsonbiggs
-
Scratcher
5 posts
Change X past the edge
I'm making a game and in the game a platform will be moving. I do it by repeatedly moving it left by doing (change x by (-6)). However, it stops at a certain X value (274.3), when it is almost past the edge. How do I get it to move past this point?
Last edited by wilsonbiggs (March 6, 2013 20:13:25)
- andre_rifaut
-
Scratcher
100+ posts
Change X past the edge
Just change the costume center to the left or right side of your costume in the costume editor (depending on the direction you need to glide it).
But anyway, Scratch 2.0 seems to be more restrictive with the X,Y position when outside the visible part of the scene. In your case it is difficult to predict exactly to which value your last move will be truncated … This might impose to have more clumsier code for some games. If your are used to make game, do not hesitate to point out that point.
But anyway, Scratch 2.0 seems to be more restrictive with the X,Y position when outside the visible part of the scene. In your case it is difficult to predict exactly to which value your last move will be truncated … This might impose to have more clumsier code for some games. If your are used to make game, do not hesitate to point out that point.
Last edited by andre_rifaut (March 6, 2013 23:49:35)
- AlveKatt
-
Scratcher
94 posts
Change X past the edge
http://beta.scratch.mit.edu/projects/10066520/
You can always use Mayhems solution that my Rescue ship game uses. It basically has it's own variables for Scroll X and Y.
If you have a side scroller you just need X.
It basically moves a control sprite a few pixels, and:
When button left is pressed
repeat until not button left is not pressed
Point in direction +90 degrees
Move five steps
Change Variable-X by X
move to 0-0.
Then in the sprites you want as background you have basically
When flag clicked
Forever
If Variable-X > than the length of a background sprite and Variable-X < than two lengths of a back ground sprite
Show
Go to position x: Variable-X - Length of the backgroundsprite
Else
Hide
And then for the next background to the right:
When flag clicked
Forever
If X > than two lengths of a background sprite and X < than three lengths of a back ground sprite
Show
Go to position x: Variable-X - Two Lengths of the backgroundsprite
Else
Hide
And so on. I guess you could do this with just two alternating background sprites though, and even have alternating costumes based on the values of Variable-X.
You can always use Mayhems solution that my Rescue ship game uses. It basically has it's own variables for Scroll X and Y.
If you have a side scroller you just need X.
It basically moves a control sprite a few pixels, and:
When button left is pressed
repeat until not button left is not pressed
Point in direction +90 degrees
Move five steps
Change Variable-X by X
move to 0-0.
Then in the sprites you want as background you have basically
When flag clicked
Forever
If Variable-X > than the length of a background sprite and Variable-X < than two lengths of a back ground sprite
Show
Go to position x: Variable-X - Length of the backgroundsprite
Else
Hide
And then for the next background to the right:
When flag clicked
Forever
If X > than two lengths of a background sprite and X < than three lengths of a back ground sprite
Show
Go to position x: Variable-X - Two Lengths of the backgroundsprite
Else
Hide
And so on. I guess you could do this with just two alternating background sprites though, and even have alternating costumes based on the values of Variable-X.
Last edited by AlveKatt (March 7, 2013 18:52:58)
- TrollGameStudios
-
Scratcher
30 posts
Change X past the edge
Set X to a variable
Then make it so the sprite hides once it goes of the edge.
That way even when you move it off screen it will still be where it should be.
For instance: If you hold down the right arrow for 10 secs and the sprite moves off the screen, then you have to hold down the left arrow key for 10 seconds until it comes back.
Then make it so the sprite hides once it goes of the edge.
That way even when you move it off screen it will still be where it should be.
For instance: If you hold down the right arrow for 10 secs and the sprite moves off the screen, then you have to hold down the left arrow key for 10 seconds until it comes back.
- Paddle2See
-
Scratch Team
1000+ posts
Change X past the edge
Since this topic hasn't seen a new post from the topic owner in a long time, I'm going to assume that it is dead and close the topic. If it still is alive, the topic owner just needs to use the Report button to ask a mod to reopen it 
Please check the dates of the last post to make sure you aren't posting on a dead topic (necroposting). Thanks!

Please check the dates of the last post to make sure you aren't posting on a dead topic (necroposting). Thanks!
- Discussion Forums
- » Help with Scripts
-
» Change X past the edge