Android games

I

Izaya

Guest
Hi guys, can you please help me in making an android game it's so hard for me to understand gestures, can you help me in making a code for a long pressed tap to make a ship shoot on an on, I'm trying to make an indie game like a space shooter game. Please help me, thanks for understanding :)
 
G

Grammar

Guest
Hey man!

So, I will give you an easy explanation:

You will need device_mouse_check_button_pressed() for checkig you tap on your phone. the Syntax is like you want check a mouseclick::

if ( device_mouse_check_button_pressed(device, mb_left) ) {
//Shooting Stuff
}

You can multiple touch your screen on different positions, and for this you need the device. Use for the first Finger which taps on the screen device_mouse_check_button_pressed(0, mb_left), for the second tap device_mouse_check_button_pressed(1, mb_left) - and so on, up to 7 Tap's I think.


You said you want a long shot. Basicly you ca figure this out with an Alarm-Event. So, lets see:

//In the Create:
charge = 0;
trigger = 0;

//In the Step Event:
if ( device_mouse_check_button_pressed(0, mb_left) ) {

if ( trigger == 0 ){
alarm[0] = 1;
trigger = 1;
}

} else {

if( charge >= 30 ){
instance_create( x, y, Shot_Obj);
}

charge = 0;
}

//In the Alarm 0 Event:
charge++;
trigger = 0;


And that's it! This Code in a Object, will create a Instance of the Object 'Shot_Obj' (What is an example for a shot what is fired by your player), when the Variable 'charge' has a value of 30 or more. The Variable 'charge' will raise if you hold the tap for a while, which is caused by the Alarm 0 Event. And so on. There are just a few specials in Android, the rest is same in GML like for other Platforms. The Code above will run on Windows as well!

(Little hint: For testing my Android games while I am coding, I start them on Windows, nor on my mobile Phone. That takes to much time. I start in Windows, check if the code works and then I close it. Its more nice for debugging in my opinion)


Hope I could help you, and much luck for your Project!

- Cheers
 
Top