Easy Inputs (ssk.easyInputs.*)

This library provides a number of factories that create easy input object instances. These objects dispatch Runtime events when touched. To use these events you simply add listeners to any part of your code that cares about the input.

(Images below have debugEn == true. Normally, the touch areas are invisible.)

One Touch Two Touch
One Touch Two Touch
One Stick Two Stick One Stick + One Touch
One Stick Two Stick One Stick + One Touch

Note: Each of the three 'stick' factories uses the 'Joystick Factory' to build the virtual joystick(s).

Easy Input Factories

oneTouch

The entire screen is a button.

ssk.easyInputs.oneTouch.create( [ group [ , params ]] )

ssk.easyInputs.oneTouch.create( group, { debugEn = true, keyboardEn = true } )

twoTouch

The screen is split down the middle and each half (left & right) is treated as a button.

ssk.easyInputs.twoTouch.create( [ group [ , params ]] )

ssk.easyInputs.twoTouch.create( group, { debugEn = true, keyboardEn = true } )

oneStick

A single virtual joystick is created anywhere you touch the screen and tracks your finger till you lift it.

ssk.easyInputs.oneStick.create( [ group [ , params ]] )

ssk.easyInputs.oneStick.create( group, { debugEn = true, joyParams = { doNorm = true } } )

twoStick

The screen is split in half horizontally, each side (left & right) hosting a virtual joystick.

ssk.easyInputs.twoStick.create( [ group [ , params ]] )

ssk.easyInputs.twoStick.create( group, { debugEn = true, joyParams = { doNorm = true } } )

oneStickOneTouch

One side of the screen is a button, one side hosts a virtual joystick.

By default, the left-side is the joystick and the right is the button, but this can be swapped.

ssk.easyInputs.oneStickOneTouch.create( [ group [ , params ]] )

ssk.easyInputs.oneStickOneTouch.create( group, { debugEn = true, joyParams = { doNorm = true } } )

Joystick Factory

This factory produces a 'virtual' fixed- or floating- joystick. The prior stays in place, while the latter moves to the beginning of the touch event that triggered it.

Virtual joysticks dispatch a Runtime event that can be listened for anywhere and by any object(s). See 'Easy Input Listeners' below to learn more about this.

ssk.easyInputs.joystick.create( group, x, y, joyParams  )

joystick.create( nil, left + 30, bottom - 30 )

Easy Input Instances

One Touch Instance

The 'One Touch Instance' is a composite object contained in display group that catches touches and converts them into a custom Runtime event. This event can the be listed for for anywhere and by any object(s).

Additionally, this 'instance' has these methods:

Two Touch Instance

The 'Two Touch Instance' is a composite object contained in display group that catches touches and converts them into a custom Runtime events. These events can the be listed for for anywhere and by any object(s).

Additionally, this 'instance' has these methods:

One Stick Instance

The 'One Stick Instance' is a composite object contained in display group that catches touches and converts them into a custom Runtime event. This event can the be listed for for anywhere and by any object(s).

Additionally, this 'instance' has this methods:

Two Stick Instance

The 'Two Stick Instance' is a composite object contained in display group that catches touches and converts them into a custom Runtime events. These events can the be listed for for anywhere and by any object(s).

Additionally, this 'instance' has this methods:

One Stick + One Touch Instance

The 'One Stick + One Touch Instance' is a composite object contained in display group that catches touches and converts them into a custom Runtime events. These events can the be listed for for anywhere and by any object(s).

Additionally, this 'instance' has these methods:

Joystick Instance

The 'Joystick Instance' is a composite object contained in display group that catches touches and converts them into a custom Runtime events. These events can the be listed for for anywhere and by any object(s).

It has no special methods attached to it.

Easy Input Listeners

One Touch Listeners

One Touch objects produce a custom Runtime event with all the same properties as the standard Corona SDK touch event.

Exception: The name field has been changed from "touch" to whatever custom event name the instance is using (Ex: "onOneTouch").


-- One Touch Function Listener

ssk.easyInputs.oneTouch.create( group )

local function onOneTouch( event )

   table.dump( event )

end; listen( "onOneTouch", onOneTouch )


-- One Touch Table Listener

ssk.easyInputs.oneTouch.create( group )

local player = newImagRect( group, centerX, centerY, "images/player.png")

function player.onOneTouch( self, event )

   table.dump( event )

end; listen( "onOneTouch", player )

Two Touch Listeners

Two Touch objects produce a custom Runtime event with all the same properties as the standard Corona SDK touch event.

Exception: The name field has been changed from "touch" to whatever custom event name the instance is using (Ex: "onTwoTouchLeft" or "onTwoTouchRight" ).


-- Two Touch Function Listener

ssk.easyInputs.twoTouch.create( group )

local function onTwoTouchLeft( event )

   table.dump( event )

end; listen( "onTwoTouchLeft", onTwoTouchLeft )

local function onTwoTouchRight( event )

   table.dump( event )

end; listen( "onTwoTouchRight", onTwoTouchRight )



-- Two Touch Table Listener

ssk.easyInputs.twoTouch.create( group )

local player = newImagRect( group, centerX, centerY, "images/player.png")

function player.onTwoTouchLeft( self, event )

   table.dump( event )

end; listen( "onTwoTouchLeft", player )

function player.onTwoTouchRight( self, event )

   table.dump( event )

end; listen( "onTwoTouchRight", player )

One Stick + One Touch Listeners

'One Stick + One Touch' objects need both a One Touch Listener and a One Stick Listener.

One Stick Listeners

Two Stick Listeners

The 'One' and 'Two' stick listeners both produce virtual joystick events.

Virtual Joystick Listeners

Virtual joysticks produce a custom Runtime event that includes these properties:


-- Two Touch Function Listener

ssk.easyInputs.oneStick.create( group )

local function onJoystick( event )

   table.dump( event )

end; listen( "onJoystick", onJoystick )



-- Two Touch Table Listener

ssk.easyInputs.oneStick.create( group )

local player = newImagRect( group, centerX, centerY, "images/player.png")

function player.onJoystick( self, event )

   table.dump( event )

end; listen( "onJoystick", player )


RoamingGamer Copyright © Roaming Gamer, LLC. 2008-2016; All Rights Reserved