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

2013/11/22

Buying Weapons + Not shooting laser beams?

M4xin8or M4xin8or

2013/11/22

#
Hi, im fairly new to greenfoot, and i was wondering if there was any way for an actor to scroll over a stationary actor, or a specific set of coordinates on the world, and have an text pop up on the screen, like in black ops, when you got to a wall outline and an option to buy a weapon pops up . Examples, tutorials, and etc are appreciated. I also want to be able to shoot without having a laser shoot out, like an interval between bullets or something. Thank you in advance.
danpost danpost

2013/11/22

#
As far as laser v bullet shooting: laser shooting happens when a bullet is created every act method while bullet shooting will skip several act methods between each bullet creation. This is usually done by adding a shot timer that increments every act. When the timer reaches a certain value, create a new bullet and reset the timer. You can add a boolean field to your actor to allow creation of the pop-up; however you will also need two dual conditional 'if' statements to run accomplish what you want. If 'atLocation' is a method (or condition) that determines whether the actor is on the stationary actor or the specific set of coordinates on the world and the boolean field is called 'didPopUp', then:
if (!didPopUp && atLocation()) // first dual conditional to create pop-up
{
    didPopUp = true;
    // create pop up
}
if (didPopUp && !atLocation()) // second dual conditional to perform reset
    didPopUp = false;
The boolean field is needed because without it, the condition to create the pop up would be true for as long the actor was at the location and many pop-ups would be created. You may even need a third condition for the resetting part: && getWorld().getObjects(PopUp.class).isEmpty().
You need to login to post a reply.