Class Index | File Index

Classes


Class Movable


Defined in: arcade.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Movable(type, opts)
Represents a game object with kinetic properties.
Field Summary
Field Attributes Field Name and Description
 
Defines, what happens when object leaves the viewport to the left or right.
 
Defines, what happens when object leaves the viewport to the left or right.
<static>  
Movable.defaultOptions
Default options used when a Movable or derived object is constructed.
 
Parent ArcadeJS object (set by game.addObject() method).
 
True, if object is hidden and not tested for collisions
 
id
Unique ID (automatically assigned if ommited).
 
Object orientation in radians.
 
pos
Object position in World Coordinates (center of mass).
 
Object scale.
 
Type identifier used to filter objects.
 
True, if this control uses native Canvas Coords instead of WC viewport.
Method Summary
Method Attributes Method Name and Description
 
Return true, if point hits this object.
 
die()
Remove this object from the game.
 
driveToPosition(stepTime, targetPos, eps, maxSpeed, turnRate, maxAccel, maxDecel)
Adjust velocity (by applying acceleration force) to move an object towards a target position.
 
Return current activity.
 
 
 
intersectsWith(otherObject)
Return true, if object intersects with this object.
 
isActivity(activities)
Return true, if current activity is in the list.
 
 
later(seconds, callback, data)
Schedule a callback to be triggered after a number of seconds.
 
setActivity(activity)
Set current activity and trigger onSetActivity events.
 
 
turnToDirection(stepTime, target, turnRate)
Turn game object to direction or target point.
Event Summary
Event Attributes Event Name and Description
 
Callback, triggered when this object dies.
 
onDrag(dragOffset)
Callback, triggered while this object is dragged.
 
onDragcancel(dragOffset)
Callback, triggered when a drag operation is cancelled.
 
onDragstart(clickPos)
Callback, triggered when a mouse drag starts over this object.
 
onDrop(dragOffset)
Callback, triggered when a drag operation ends with mouseup.
 
onKeydown(e, key)
Callback, triggered when document keydown event occurs.
 
Callback, triggered when document keypress event occurs.
 
onKeyup(e, key)
Callback, triggered when document keyup event occurs.
 
onMousewheel(e, delta)
Callback, triggered when mouse wheel was used.
 
onSetActivity(target, activity, prevActivity)
Callback, triggered when game or an object activity changes.
 
onTimeout(data)
Callback, triggered when timeout expires (and no callback was given).
 
onTouchevent(event, originalEvent)
Called on miscelaneous touch.
 
render(ctx)
Draw the object to the canvas.
 
step()
Override this to apply additional transformations.
Class Detail
Movable(type, opts)
Represents a game object with kinetic properties. Used as base class for all game objects.
Parameters:
{string} type
Instance type identifier used to filter objects.
opts Optional
Additional options.
{string} opts.id Optional, Default: random
Unique instance identifier.
{object} opts.debug Optional
Additional debug options.
See:
Movable.defaultOptions
Field Detail
clipModeX
Defines, what happens when object leaves the viewport to the left or right. Values: ('none', 'wrap', 'stop', 'bounce')

clipModeY
Defines, what happens when object leaves the viewport to the left or right.

<static> Movable.defaultOptions
Default options used when a Movable or derived object is constructed.

game
Parent ArcadeJS object (set by game.addObject() method).

hidden
True, if object is hidden and not tested for collisions

id
Unique ID (automatically assigned if ommited).

orientation
Object orientation in radians.

pos
Object position in World Coordinates (center of mass).

scale
Object scale.

type
Type identifier used to filter objects.

useCC
True, if this control uses native Canvas Coords instead of WC viewport.
Method Detail
{boolean} contains(pt)
Return true, if point hits this object.
Parameters:
{Point2} pt
Point in world coordinates
Returns:
{boolean}

die()
Remove this object from the game.

{booelan} driveToPosition(stepTime, targetPos, eps, maxSpeed, turnRate, maxAccel, maxDecel)
Adjust velocity (by applying acceleration force) to move an object towards a target position.
Parameters:
{float} stepTime
{Point2} targetPos
{float} eps
{float} maxSpeed
{float} turnRate
{float} maxAccel
{float} maxDecel
Returns:
{booelan} true, if target position is reached (+/- eps)

{string} getActivity()
Return current activity.
Returns:
{string}

getBoundingBox()

{Circle2} getBoundingCircle()
Returns:
{Circle2} bounding circle in world coordinates. in modelling coordinates.

{boolean} intersectsWith(otherObject)
Return true, if object intersects with this object.
Parameters:
{Movable} otherObject
Returns:
{boolean}

{boolean} isActivity(activities)
Return true, if current activity is in the list.
Parameters:
{string | string array} activities
(seperate multiple entries with space)
Returns:
{boolean}

isDead()

later(seconds, callback, data)
Schedule a callback to be triggered after a number of seconds.
Parameters:
{float} seconds
delay until callback is triggered
{function} callback Optional, Default: this.onTimeout
Function to be called.
{Misc} data Optional
Additional data passed to callback

{string} setActivity(activity)
Set current activity and trigger onSetActivity events.
Parameters:
{string} activity
Returns:
{string} previous activity

toString()

{booelan} turnToDirection(stepTime, target, turnRate)
Turn game object to direction or target point.
Parameters:
{float} stepTime
{float | Vec2 | Point2} target
angle, vector or position
{float} turnRate
Returns:
{booelan} true, if target angle is reached
Event Detail
onDie()
Callback, triggered when this object dies.

onDrag(dragOffset)
Callback, triggered while this object is dragged.
Parameters:
{Vec2} dragOffset

onDragcancel(dragOffset)
Callback, triggered when a drag operation is cancelled.
Parameters:
{Vec2} dragOffset

{boolean} onDragstart(clickPos)
Callback, triggered when a mouse drag starts over this object.
Parameters:
{Point2} clickPos
Returns:
{boolean} must return true, if object wants to receive drag events

onDrop(dragOffset)
Callback, triggered when a drag operation ends with mouseup.
Parameters:
{Vec2} dragOffset

onKeydown(e, key)
Callback, triggered when document keydown event occurs.
Parameters:
{Event} e
{string} key
stringified key, e.g. 'a', 'A', 'ctrl+a', or 'shift+enter'.

onKeypress(e)
Callback, triggered when document keypress event occurs. Synchronous keys are supported
Parameters:
{Event} e
See:
ArcadeJS.isKeyDown(keyCode)

onKeyup(e, key)
Callback, triggered when document keyup event occurs.
Parameters:
{Event} e
{string} key
stringified key, e.g. 'a', 'A', 'ctrl+a', or 'shift+enter'.

onMousewheel(e, delta)
Callback, triggered when mouse wheel was used. Note: this requires to include the jquery.mouseweheel.js plugin.
Parameters:
{Event} e
{int} delta
+1 or -1

onSetActivity(target, activity, prevActivity)
Callback, triggered when game or an object activity changes.
Parameters:
{Movable} target
object that changed its activity (May be the ArcadeJS object too).
{string} activity
new activity
{string} prevActivity
previous activity

onTimeout(data)
Callback, triggered when timeout expires (and no callback was given).
Parameters:
data
data object passed to later()

onTouchevent(event, originalEvent)
Called on miscelaneous touch... and gesture... events.
Parameters:
{Event} event
jQuery event
{OriginalEvent} originalEvent
depends on mobile device

render(ctx)
Draw the object to the canvas. The objects transformation is already applied to the canvas when this function is called. Therefore drawing commands should use modeling coordinates.
Parameters:
ctx
Canvas 2D context.

step()
Override this to apply additional transformations.

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 18 2011 14:05:26 GMT+0200 (MESZ)