Input

php\gdx\Input

final class

Methods


__construct()

private

getAccelerometerX()
Returns:double The value of the accelerometer on its x-axis. ranges between [-10,10].
getAccelerometerY()
Returns:double The value of the accelerometer on its y-axis. ranges between [-10,10].
getAccelerometerZ()
Returns:double The value of the accelerometer on its y-axis. ranges between [-10,10].
getX($pointer)

Returns the x coordinate of the last touch on touch screen devices and the current mouse position on desktop for the first pointer in screen coordinates. The screen origin is the top left corner.

Parameters:
  • $pointerint - (optional) the pointer id. Returns the x coordinate in screen coordinates of the given pointer.
Returns:

int

getDeltaX($pointer)
Parameters:
  • $pointerint - (optional) the pointer id.
Returns:

int the different between the current pointer location and the last pointer location on the x-axis.

getY($pointer)

Returns the y coordinate of the last touch on touch screen devices and the current mouse position on desktop for the first pointer in screen coordinates. The screen origin is the top left corner.

Parameters:
  • $pointerint - (optional) the pointer id. Returns the y coordinate in screen coordinates of the given pointer.
Returns:

int

getDeltaY($pointer)
Parameters:
  • $pointerint - (optional) the pointer id.
Returns:

int the different between the current pointer location and the last pointer location on the y-axis.

isTouched($pointer)
Parameters:
  • $pointerint - (optional)
Returns:

bool whether the screen is currently touched.

justTouched()
Returns:bool whether a new touch down event just occurred.
isButtonPressed($button)

Whether a given button is pressed or not. Button constants can be found in {@link Buttons}. On Android only the Button#LEFT constant is meaningful.

Parameters:
  • $buttonint
Returns:

bool

isKeyPressed($key)

Returns whether the key is pressed.

Parameters:
  • $keyint
setOnscreenKeyboardVisible($visible)

Sets the on-screen keyboard visible if available.

Parameters:
  • $visiblebool
vibrate($millis)

Vibrates for the given amount of time. Note that you’ll need the permission <code> <uses-permission android:name=”android.permission.VIBRATE” /></code> in your manifest file in order for this to work.

Parameters:
  • $millisint - the number of milliseconds to vibrate.
cancelVibrate()
getAzimuth()

The azimuth is the angle of the device’s orientation around the z-axis. The positive z-axis points towards the earths center.

Returns:double
getPitch()

The pitch is the angle of the device’s orientation around the x-axis. The positive x-axis roughly points to the west and is orthogonal to the z- and y-axis.

Returns:double
getRoll()

The roll is the angle of the device’s orientation around the y-axis. The positive y-axis points to the magnetic north pole of the earth.

Returns:double
getCurrentEventTime()
Returns:int the time of the event currently reported to the InputProcessor.
setCatchBackKey($catchBack)

Sets whether the BACK button on Android should be caught. This will prevent the app from being paused. Will have no effect on the desktop.

Parameters:
  • $catchBackbool
setCatchMenuKey($catchMenu)

Sets whether the MENU button on Android should be caught. This will prevent the onscreen keyboard to show up. Will have no effect on the desktop.

Parameters:
  • $catchMenubool
getRotation()
Returns:int the rotation of the device with respect to its native orientation.
getNativeOrientation()
Returns:string the native orientation of the device.
setCursorCatched($catched)

Only viable on the desktop. Will confine the mouse cursor location to the window and hide the mouse cursor.

Parameters:
  • $catchedbool - whether to catch or not to catch the mouse cursor
isCursorCatched()
Returns:bool whether the mouse cursor is catched.
setCursorPosition($x, $y)

Only viable on the desktop. Will set the mouse cursor location to the given window coordinates (origin top-left corner).

Parameters:
  • $xint
  • $yint
setCursorImage($pixmap, $xHotspot, $yHotspot)

Only viable on the desktop. Will set the mouse cursor image to the image represented by the Pixmap. The Pixmap must be in RGBA8888 format, width & height must be powers-of-two greater than zero (not necessarily equal), and alpha transparency must be single-bit (i.e., 0x00 or 0xFF only). To revert to the default operating system cursor, pass in a null Pixmap; xHotspot & yHotspot are ignored in this case.

Parameters: