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

2021/4/2

How to reference scrolled Coordinates from actor class

hernry2812 hernry2812

2021/4/2

#
At a certain point of the game I want to set my Actor back to the start point, where it initially started. I am using danposts Scrolling SuperWorld, so I cant just use
setLocation(400,400);
because the location my actor is set to always depends on the position he was before (Scrolling Window Movement). Thats why I tried the following code danpost gave me to place my other actors at the right position:
setLocation(getX() - RaceWorld.scrolledX-560, getY()-scrolledY-360);
The problem here is that I am now in an actor class and no more in my world class, so Greenfoot tells me that those 2 variables are having private access in SWorld. I set every method in SWorld to public, but I still can't use them to set my main actor to the location I want.
danpost danpost

2021/4/2

#
hernry2812 wrote...
I set every method in SWorld to public, but I still can't use them to set my main actor to the location I want.
The SWorld class is not to be modified. You can use "((SWorld)getWorld()).getScrolledX()" and similar for y.
You need to login to post a reply.