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

2015/1/14

Can't get coordinate (pixel) of actor, help please!

Socrates Socrates

2015/1/14

#
So basically I'm making a sidescroller, and I want to spawn objects when my character passes a certain pixel coordinate (x axis). So my entire map is 4000 pixels and my screen is 700 x 700 and my sidescrolling bounds are 300 from the center. I want to spawn an actor when the player passes 2000 pixels but even if I run to the end of my world I'll only reach 600 pixels. I think it measures the character in terms of the screen and not the world. Thanks
danpost danpost

2015/1/14

#
What scrolling system are you using? For instance, if you are using my SWorld superclass for scrolling, you can make use of the 'getUnivX' method.
Socrates Socrates

2015/1/14

#
yea I'm using yours. would I call it in my actor class? And another question I have about your scrolling system is, how do I make an unscrollable object that has no collision? thanks danpost
danpost danpost

2015/1/14

#
I believe the SWorld documentation states how to create non-scrolling objects. From an Actor subclass, you can determine the scrolling x-coordinate of an actor with something like the following:
int univX = ((SWorld)getWorld()).getUnivX(getX());
Socrates Socrates

2015/1/14

#
oh ok i got that to work, but not making certain objects have no collision. I'm also getting a bug when I add a border (like a frame around my game screen) it doesnt scroll (which is what I want) but then my player actor disapears from the map
danpost danpost

2015/1/14

#
I do not know what you mean by 'not making certain objects have no collision'. Collision is something that is implemented, not something you need to remove (unless you over-implemented it). As far as your player actor disappearing from the map, I cannot say what might be causing that; and, probably will not be able to unless you upload the scenario with source so that I can look at it in its entirety. I almost sounds like your sub-classing is messed up (in both issues).
Socrates Socrates

2015/1/14

#
I wanted to remove collision from a few objects that you could walk by. For example I wanted a portal to the next level and I wanted the player to stand inside of it, but it has collision and it just stands next to it. I posted my scenario, it would be great if you could look at it for me ,thanks. http://www.greenfoot.org/scenarios/13110
You need to login to post a reply.