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

2012/4/26

Experienced programmers' help needed please!

DHoffman94 DHoffman94

2012/4/26

#
So, i am having a bit of trouble. I have a rocket in my asteroids game, and i have thruster animations to go along with it. However, the animations are set to spawn IN THE MIDDLE of the ship instead of behind the ship relative to where the actual thrusters are. How would i add an object to the world where instead of using getX() and getY() to get the dead center of the image, i use a point on the image and get the x and y coordinate of that position. Please respond soon! :)
Duta Duta

2012/4/26

#
This blog post might help. Also, this is the accompanying scenario
DHoffman94 DHoffman94

2012/4/26

#
Hmm, this will take some time to understand this code, as it is always easier to understand when you are the person who wrote it. I will write back if i have made process. Thank you!
ttamasu ttamasu

2012/4/26

#
If you have an actor class called Thruster, I would do something like this in the ship class Truster flame = new Thruster(); getWorld().addObject(flame,getX(),getY()); flame.setRotation(getRotation()); flame.move(- (getImage().getWidth()/2 + // ships width flame.getImage().getWidth()/2) // flames width ) ); // move the flames behind the ship... may have to adjust // granted you might notice the flame intially in the ship but at normal frame rates most people would not notice.
DHoffman94 DHoffman94

2012/4/26

#
I have practicly copied the code from the bus scenerio, however the only trouble is i dont fully understand it. It works, and the thruster is in the correct position, but i might need some help understanding it.
nccb nccb

2012/4/26

#
I wrote the blog post that duta mentions: http://sinepost.wordpress.com/2012/04/10/burning-rubber/ You might need to read this one too, to understand polar coordinates: http://sinepost.wordpress.com/2012/03/27/where-am-i-headed/ If you get stuck with either post, please do leave a comment on the blog and I'll attempt to explain it in more detail.
You need to login to post a reply.