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

2014/9/15

How do you make a rocket move like its in space?

coder04 coder04

2014/9/15

#
Can anyone tell me how to move my rocket like the one in this game- http://www.greenfoot.org/scenarios/4207 Please can u right the code out for me
danpost danpost

2014/9/15

#
That movement is a basic 'SmoothMover' using key-input for acceleration/deceleration. Import the SmoothMover class (or download and use the 'QActor' class from my Zombie Shooter Demo scenario) and have your Rocket class extend it.
coder04 coder04

2014/9/15

#
can u paste the code so i can add it to my rocket class please
danpost danpost

2014/9/15

#
The first change after adding a superclass for smooth moving would be changing what class the Rocket class extends:
// changing
public class Rocket extends Actor
// to either
public class Rocket extends SmoothMover
// or
public class Rocket extends QActor
The other changes would depend on the class you have the Rocket class extend. They both provide functionality for smooth movement, but are implemented in different ways. You will have to attempt to implement it following the instructions given within the documentation of the class you use; then, if you have problems, state which one you are using and give the code you attempted with a brief explanation of the exact behavior you wish to obtain and how it is not behaving in that fashion. Use the 'code' link below the 'Post a reply' input box to insert any codes into your posts and always provide, by way of copy/paste ops, complete compilation error or exception messages you may be getting.
coder04 coder04

2014/9/15

#
this is a better example i want it exactly like the rocket in this game http://www.greenfoot.org/scenarios/12062
danpost danpost

2014/9/15

#
You will have to use the SmoothMover class specifically. The QActor class does not currently separate the movement vector from the direction the actor is facing; so, it will not work for what you want.
You need to login to post a reply.