Reputation: 1596
I'm using andengine to build my first game. i can receive the x,y values of touch position with the following code. I want to compare the x value(from touchEvent) with the maximum x value of the screen. is it possible with andengine?
@Override
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
if(this.mPhysicsWorld != null) {
if(pSceneTouchEvent.isActionDown()) {
this.addFace(pSceneTouchEvent.getX(), pSceneTouchEvent.getPointerID());
return true;
}
}
return false;
}
Upvotes: 1
Views: 3058
Reputation: 12527
Contained in the andengine TouchEvent is a reference to the Android MotionEvent that triggered the call using getMotionEvent();
That motion event will be in device screen coordinates.
Upvotes: 1
Reputation: 4312
There are two concern to get maximum x and y of device which one you need I don't know but here I post both.
You can use following code to get maximum height and width of device
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Upvotes: 2