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

Report as inappropriate.

gogglebot
gogglebot presents ...

2013/5/8

Space Game test

This is my second project and the first posted on the website.
I have a problem with this, I am using a scrolling world which I got from a demo scenario, which works fine with my own stuff put in, but I am trying to put a smoke effect in, to leave a trail behind the ship, but I think because the smoke is made as a child of the ship, which is staionary to the camera, the smoke is also stationary. Also is it possible to only produce smoke if your moving? I presume you'd do that by checking if UP is held, then doing makeSmoke.

Thanks

1567 views / 5 in the last 7 days

Tags: mouse game demo with-source

open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

danpostdanpost

2013/5/8

The Smoke class should extend the ScrollActor class. That, and you using the wrong x and y to place your smoke into the world (in the ship class). The 'makeSmoke' method should be like this: private void makeSmoke() { count--; if (count == 0) { ScrollWorld sw = (ScrollWorld) getWorld(); getWorld().addObject ( new Smoke(), sw.getCameraX(), sw.getCameraY()); count = 2; } } You may want to add a 'setPaintOrder' statement in your subclass of ScrollWorld. Oh, and move your call to 'makeSmoke' inside the 'up' key detection clause
gogglebotgogglebot

2013/5/9

Ok, this makes the smoke no longer attached to the ship and it leaves a trail when up is pressed, BUT, the smoke also leaves the ship entirely, and appears to be keyboard controlled still. All that needs to happen is that the smoke is spawned in the world at a specific point, not relative to the screen, and stays there until it disappears.
gogglebotgogglebot

2013/5/9

The 'specific point' being where it ship is at the time. Sorry that wasn't very clear.

Want to leave a comment? You must first log in, and be a member for more than a week.

Who likes this?

No votes yet.