Hi, fellow Scratchers,
I was working on a sequel to one of my projects and it'll be a scrolling game. It's and up/down scroller, and the controls for character movement and scrolling movement are separate. As those who've made scrollers know, the sprites catch on the edges of the stage, rather than disappear. I realize I could simply make a "Hide if Touching Screen Edge", but then it doesn't reserve the position the sprite was in.
How can I fix this? It's getting to be a pain.
- 3DBlenderRender
Offline
Make a variable called xpos. Then, set xpos to the starting x position. Then, lets say the sprite moves by 10 when the right key is pressed. When you move by 10, also change xpos by 10, and when you move by -10, change xpos by -10. Then make the sprite hide when xpos is 240 or more or -240 or less. When xpos is between -240 and 240, the sprite should show. Then, when the sprite is hidden and you continue to press the right (or left) arrow key, it continues to change xpos. I hope this helps.
Offline
scratcher7_13 wrote:
Make a variable called xpos. Then, set xpos to the starting x position. Then, lets say the sprite moves by 10 when the right key is pressed. When you move by 10, also change xpos by 10, and when you move by -10, change xpos by -10. Then make the sprite hide when xpos is 240 or more or -240 or less. When xpos is between -240 and 240, the sprite should show. Then, when the sprite is hidden and you continue to press the right (or left) arrow key, it continues to change xpos. I hope this helps.
![]()
Perfect, just what I needed. Of course, I'll have to make it -240 + Variable P and 240 + Variable P, as the object is a moving CPU. Thanks so much!
- 3DBlenderRender
Offline
You are welcome!
Offline