API Docs for: 0.2.0
Show:

Q.InputSystem Class

Extends Q.Evented
Module: Quintus.Input

Button and mouse input subsystem for Quintus. An instance of this class is auto-created as Q.input

Methods

bindKey

(
  • key
  • name
)

Bind a key name or keycode to an action name (used by keyboardControls)

Parameters:

  • key String or Integer
    • name or integer keycode for to bind
  • name String
    • name of action to bind to

debind

()

Inherited from Q.Evented: lib/quintus.js:907

debind is called to remove any listeners an object had on other objects. The most common case is when an object is destroyed you'll want all the event listeners to be removed for you.

disableMouseControls

()

Turn off mouse controls

disableTouchControls

()

Turn off touch (buytton and joypad) controls and remove event listeners

drawButtons

()

Draw the touch buttons on the screen

overload this to change how buttons are drawn

drawCanvas

()

Called each frame by the stage game loop to render any onscreen UI

calls drawJoypad and drawButtons if enabled

drawJoypad

()

Draw the joypad on the screen

overload this to change how joypad is drawn

enableKeyboard

()

Enable keyboard controls by binding to events

extend

(
  • className
  • properties
  • [classMethods]
)

Inherited from Q.Class: lib/quintus.js:693

Create a new Class that inherits from this class

Parameters:

  • className String
  • properties Object
    • hash of properties (init will be the constructor)
  • [classMethods] Object optional
    • optional class methods to add to the class

isA

(
  • className
)

Inherited from Q.Class: lib/quintus.js:683

See if a object is a specific class

Parameters:

  • className String
    • class to check against

joypadControls

(
  • [opts]
)

Activate joypad controls (i.e. 4-way touch controls)

Lots of options, defaults are:

{
 size: 50,
 trigger: 20,
 center: 25,
 color: "#CCC",
 background: "#000",
 alpha: 0.5,
 zone: Q.width / 2,
 inputs: DEFAULT_JOYPAD_INPUTS

}

Default joypad controls is an array that defines the inputs to bind to:

  // Clockwise from midnight (a la CSS)
  var DEFAULT_JOYPAD_INPUTS =  [ 'up','right','down','left'];

Parameters:

  • [opts] Object optional
    • joypad options

keyboardControls

(
  • [keys]
)

Convenience method to activate keyboard controls (call bindKey and enableKeyboard internally)

Parameters:

  • [keys] Object optional
    • hash of key names or codes to actions

mouseControls

(
  • [options]
)

Activate mouse controls - mouse controls don't trigger events, but just set Q.inputs[mouseX] & Q.inputs['mouseY'] on each frame.

Default options:

{
  stageNum: 0,
  mouseX: "mouseX",
  mouseY: "mouseY",
  cursor: "off"
}

Parameters:

  • [options] Object optional
    • override default options

off

(
  • event
  • [target]
  • [callback]
)

Inherited from Q.Evented: lib/quintus.js:870

Unbinds an event. Can be called with 1, 2, or 3 parameters, each of which unbinds a more specific listener.

Parameters:

  • event String
    • name of event
  • [target] Object optional
    • optionally limit to a specific target
  • [callback] Function optional
    • optionally limit to one specific callback

on

(
  • event
  • [target]
  • [callback]
)

Inherited from Q.Evented: lib/quintus.js:793

Binds a callback to an event on this object. If you provide a target object, that object will add this event to it's list of binds, allowing it to automatically remove it when it is destroyed.

Parameters:

  • event String
    • name or comma separated list of events
  • [target] Object optional
    • optional context for callback, defaults to the Evented
  • [callback] Function optional
    • callback (optional - defaults to name of event on context

touchControls

(
  • [opts]
)

Activate touch button controls - pass in an options hash to override

Default Options:

{
   left: 0,
   gutter:10,
   controls: DEFAULT_TOUCH_CONTROLS,
   width: Q.width,
   bottom: Q.height
 }

Default controls are left and right buttons, a space, and 'a' and 'b' buttons, as defined as an Array of Arrays below:

 [ ['left','<' ],
   ['right','>' ],
   [],  // use an empty array as a spacer
   ['action','b'],
   ['fire', 'a' ]]

Parameters:

  • [opts] Object optional
    • Options hash

trigger

(
  • event
  • [data]
)

Inherited from Q.Evented: lib/quintus.js:848

Triggers an event, passing in some optional additional data about the event.

Parameters:

  • event String
    • name of event
  • [data] Object optional
    • optional data to pass to the callback