Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Confused with scrolling background issue
- Andy7_24
-
28 posts
Confused with scrolling background issue
I have started to make a scrolling background game, but something weird happened that I don't know how to fix. Once you get close to the end of the terrain on the right, you randomly fall through the floor. If you drag the sprite back up after falling onto ground that he can stand on, the screen won't move left anymore if you hold the left arrow key. I am utterly confused and I would really appreciate some help! Link to my Game
Thanks a lot!
Thanks a lot!

- deck26
-
1000+ posts
Confused with scrolling background issue
Don't have two separate loops - one controlling the value of gravity and the other changing y by gravity. Combine them to make it simpler and more predictable.
Hiding or showing a sprite in a forever loop is inefficient - better to keep track of whether it is showing or hidden and only call show/hide when necessary. Similarly for switching sprite costumes.
You problem seems to occur when the scrolling backdrop doesn't work properly. Try displaying your variables to see what's happening.
Hiding or showing a sprite in a forever loop is inefficient - better to keep track of whether it is showing or hidden and only call show/hide when necessary. Similarly for switching sprite costumes.
You problem seems to occur when the scrolling backdrop doesn't work properly. Try displaying your variables to see what's happening.
- Andy7_24
-
28 posts
Confused with scrolling background issue
Don't have two separate loops - one controlling the value of gravity and the other changing y by gravity. Combine them to make it simpler and more predictable.
Hiding or showing a sprite in a forever loop is inefficient - better to keep track of whether it is showing or hidden and only call show/hide when necessary. Similarly for switching sprite costumes.
You problem seems to occur when the scrolling backdrop doesn't work properly. Try displaying your variables to see what's happening.
I still don't know what's happening. This is my first proper Scratch Project and I have no idea what I'm doing! XD
The Gravity seems to freak out before it get to that place and the character seems to bounce slightly. Apart from that I can't see anything!
I have no idea how to fix this!
- deck26
-
1000+ posts
Confused with scrolling background issue
Scrolling is perhaps a bit ambitious for a first project.
Generally reduce your use of forever loops as these can conflict with each other or generally cause lag. Merging them together can be useful.
Avoid having multiple scripts doing the same thing - you have a couple of sprites responding to the dead broadcast by setting scrollX to 0. Since the penguin is responsible for setting scrollX most of the time I'd eliminate any scripts where other sprites change it.
You don't need left and right costumes if you use left-right roatation style and point the sprite in the right direction.
Avoid using glide if you're also controlling movement by changing x and y as it will just confuse things.
Your black colour on EndLevel doesn't match the colour used in terrain so the touching colour block doesn't detect the contact. That was your main problem I think.
Certain arrow key combinations may not work on certain computers. I can't move left or right if I'm holding the down arrow key.
Here's a remix which may not be correct yet but includes most of the above changes. https://scratch.mit.edu/projects/146990174/
Generally reduce your use of forever loops as these can conflict with each other or generally cause lag. Merging them together can be useful.
Avoid having multiple scripts doing the same thing - you have a couple of sprites responding to the dead broadcast by setting scrollX to 0. Since the penguin is responsible for setting scrollX most of the time I'd eliminate any scripts where other sprites change it.
You don't need left and right costumes if you use left-right roatation style and point the sprite in the right direction.
Avoid using glide if you're also controlling movement by changing x and y as it will just confuse things.
Your black colour on EndLevel doesn't match the colour used in terrain so the touching colour block doesn't detect the contact. That was your main problem I think.
Certain arrow key combinations may not work on certain computers. I can't move left or right if I'm holding the down arrow key.
Here's a remix which may not be correct yet but includes most of the above changes. https://scratch.mit.edu/projects/146990174/
- STAR_PLATINUM_ORA
-
1 post
Confused with scrolling background issue
Me too my game is broken and idk how to fix it if u wanna know how broken it is check it here https://scratch.mit.edu/projects/333324047
- deck26
-
1000+ posts
Confused with scrolling background issue
https://scratch.mit.edu/projects/333324047Please create your own topic rather than hijacking someone else's. Me too my game is broken and idk how to fix it if u wanna know how broken it is check it here
- Discussion Forums
- » Help with Scripts
-
» Confused with scrolling background issue