Page 1 of 1

Help Please

PostPosted: Mon Sep 05, 2011 12:57 am
by QuasarCreator
Right now I am making an app in my free time. :o However, I am completely new with all this. So if someone could please help me with my question I would be very thankful. :D

In my game their will be a spaceship that launches a rocket. So, how can I make it so whenever the user double taps the screen the rocket will fire in the direction of the tap? :?:

Re: Help Please

PostPosted: Mon Sep 05, 2011 1:10 am
by skydereign
Here's a pretty simple way of doing it. Have a filled region stretch across the screen. Then add this for its mouse button down event (you need to add an int variable called timer).
click_region -> Mouse Button Down (left) -> Script Editor
Code: Select all
timer=10;
if(timer>0)
{
    CreateActor("rocket", "rocket_anim", "(none)", "(none)", player.x, player.y, true);
}

Then in the actor's draw, have this.
click_region -> Draw Actor -> Script Editor
Code: Select all
timer-=timer>0;


Now to make the rocket actually move toward the mouse position, put this in the rocket's create actor event.
rocket -> Create Actor -> Script Editor
Code: Select all
directional_velocity=20;
angle=direction(xscreen, xmouse, yscreen, ymouse);

Re: Help Please

PostPosted: Mon Sep 05, 2011 4:21 am
by QuasarCreator
Ok thanks!

Re: Help Please

PostPosted: Mon Sep 05, 2011 4:40 pm
by QuasarCreator
I have a problem right now. When I type in the code it says it can not define the variable. What should I do?

Re: Help Please

PostPosted: Mon Sep 05, 2011 9:34 pm
by Jagmaster
You will need to declare a variable called timer. Here is a tutorial for that (from the tutorial page) http://game-editor.com/forum/viewtopic.php?f=4&t=8603&start=0