This site requires JavaScript, please enable it in your browser!
Greenfoot back
treykrizek03
treykrizek03 wrote ...

2020/5/21

Scroller Displacement Problems

treykrizek03 treykrizek03

2020/5/21

#
I have a problem with the scroller class at this tutorial link (https://www.greenfoot.org/scenarios/18226) by danpost with the blocks that my actor is supposed to jump on being displaced after shrinking the viewport to my preferred size (512*320) from 1920*1200 (so I could pace the blocks on the screen). Thanks for any help and if you need to see the code for the scroller class you can look at the linked tutorial or just ask and I can send you my scenario.
treykrizek03 treykrizek03

2020/5/21

#
The scenario is on my page
danpost danpost

2020/5/22

#
treykrizek03 wrote...
The scenario is on my page
Your first major issue is having Life# classes extend the Player class (as well as the GameOver class and the Extraction class extending Player). These actors are NOT players.
danpost danpost

2020/5/22

#
treykrizek03 wrote...
The scenario is on my page
The second major issue is where you initialize the Scroller object. Move it (code between "super..." and "prepare...") to the end of the startGame method.
treykrizek03 treykrizek03

2020/5/25

#
That worked with the scroller. Thanks for the help. I was wondering now how I would be able to get the Player to spawn back into the world at the correct checkpoint after falling off of it. (This was working before the Scroller was fixed, the coordinates of the objects got displaced, so the Player isn't getting set to the correct location.)
danpost danpost

2020/5/25

#
treykrizek03 wrote...
how I would be able to get the Player to spawn back into the world at the correct checkpoint after falling off of it ... the coordinates of the objects got displaced, so the Player isn't getting set to the correct location.)
You will need to make use of getScrollX and getScrollY. I guess one way to handle it is to negate the scrolled amount (un-scroll back to initial position), then add the player back in. Another is to subtract the scrolled amounts from the coordinates where you want the player.
You need to login to post a reply.