Pages

Tuesday, November 2, 2010

developing java touch games

 

iphone-finger-game

In game canvas you can detect keys and touch and using graphic function.Canvas have pre defined functions .For using touch in your game you have three function

protected  void pointerDragged(int x, int y) 
protected  void pointerPressed(int x, int y)
protected  void pointerReleased(int x, int y)

they are active when you dragged or pressed or released your finger(or pen) on your device.X and Y is place of your finger or pen.If you want same action for all of function you can define another function like this

public void doyouraction(int x,int y)
{

//add your code here

// you can change your function name(doyouraction)

}

in other hand you should have deferent code or functions

{} are keyword for define start and end of your codes.Public means that you can use your function in other class ,if you don’t want use private instead.After coding function use it with this codes

protected  void pointerDragged(int x, int y) 

{

doyouraction(int x,int y) ;
}

just this,in next post you’ll see infoo about detect keys and code for them

1 comment:

linkwithin

Related Posts Plugin for WordPress, Blogger...