Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MultiTouchSpace

Hierarchy

Index

Properties

Protected _canvas

_canvas: EventTarget

Protected _ctx

_ctx: any

Protected _dragged

_dragged: boolean = false

Protected _hasMouse

_hasMouse: boolean = false

Protected _hasTouch

_hasTouch: boolean = false

Protected _isReady

_isReady: boolean = false

Protected _playing

_playing: boolean = false

Protected _pointer

_pointer: Pt = new Pt()

Protected _pressed

_pressed: boolean = false

Protected bound

bound: Bound = new Bound()

id

id: string = "space"

Protected playerCount

playerCount: number = 0

Protected players

players: ISpacePlayers

Accessors

center

  • get center(): Pt

customRendering

  • get customRendering(): function
  • set customRendering(f: function): void
  • Set a custom rendering function(graphics_context, canvas_space) if needed

    Returns function

      • (context: any, self: Space): null
      • Parameters

        • context: any
        • self: Space

        Returns null

  • Set a custom rendering function(graphics_context, canvas_space) if needed

    Parameters

    • f: function
        • (context: any, self: Space): null
        • Parameters

          • context: any
          • self: Space

          Returns null

    Returns void

height

  • get height(): number

innerBound

  • get innerBound(): Bound

isPlaying

  • get isPlaying(): boolean
  • Get a boolean to indicate whether the animation is playing

    Returns boolean

outerBound

  • get outerBound(): Bound

pointer

  • get pointer(): Pt
  • Get the mouse or touch pointer that stores the last action

    Returns Pt

size

  • get size(): Pt

width

  • get width(): number

Methods

Protected _mouseAction

  • _mouseAction(type: string, evt: MouseEvent | TouchEvent): void
  • Go through all the players and call its action callback function

    Parameters

    • type: string

      an UIPointerActions constant or string: "up", "down", "move", "drag", "drop", "over", and "out"

    • evt: MouseEvent | TouchEvent

      mouse or touch event

    Returns void

Protected _mouseDown

  • _mouseDown(evt: MouseEvent | TouchEvent): boolean
  • MouseDown handler

    Parameters

    • evt: MouseEvent | TouchEvent

    Returns boolean

Protected _mouseMove

  • _mouseMove(evt: MouseEvent | TouchEvent): boolean
  • MouseMove handler

    Parameters

    • evt: MouseEvent | TouchEvent

    Returns boolean

Protected _mouseOut

  • _mouseOut(evt: MouseEvent | TouchEvent): boolean
  • MouseOut handler

    Parameters

    • evt: MouseEvent | TouchEvent

    Returns boolean

Protected _mouseOver

  • _mouseOver(evt: MouseEvent | TouchEvent): boolean
  • MouseOver handler

    Parameters

    • evt: MouseEvent | TouchEvent

    Returns boolean

Protected _mouseUp

  • _mouseUp(evt: MouseEvent | TouchEvent): boolean
  • MouseUp handler

    Parameters

    • evt: MouseEvent | TouchEvent

    Returns boolean

Protected _touchMove

  • _touchMove(evt: TouchEvent): boolean
  • TouchMove handler

    Parameters

    • evt: TouchEvent

    Returns boolean

add

  • Add an IPlayer to this space. An IPlayer can define the following callback functions:

    • animate( time, ftime, space )
    • start(bound, space)
    • resize( size, event )
    • action( type, x, y, event ) Subclasses of Space may define other callback functions.

    Parameters

    Returns this

bindCanvas

  • bindCanvas(evt: string, callback: EventListener): void
  • Bind event listener in canvas element. You can also use bindMouse or bindTouch to bind mouse or touch events conveniently.

    Parameters

    • evt: string

      an event string such as "mousedown"

    • callback: EventListener

      callback function for this event

    Returns void

bindMouse

  • bindMouse(_bind?: boolean): this
  • A convenient method to bind (or unbind) all mouse events in canvas element. All "players" added to this space that implements an action callback property will receive mouse event callbacks. The types of mouse actions are defined by UIPointerActions constants: "up", "down", "move", "drag", "drop", "over", and "out". See Space's add() function for more details.

    see

    Space's [add`](./space.space.html#add) function

    Parameters

    • Default value _bind: boolean = true

      a boolean value to bind mouse events if set to true. If false, all mouse events will be unbound. Default is true.

    Returns this

bindTouch

  • bindTouch(_bind?: boolean): this
  • A convenient method to bind (or unbind) all touch events in canvas element. All "players" added to this space that implements an action callback property will receive mouse event callbacks. The types of mouse actions are: "up", "down", "move", "drag", "drop", "over", and "out".

    see

    Space's [add`](./space.space.html#add) function

    Parameters

    • Default value _bind: boolean = true

      a boolean value to bind touch events if set to true. If false, all mouse events will be unbound. Default is true.

    Returns this

clear

  • clear(): this

getForm

pause

  • pause(toggle?: boolean): this
  • Pause the animation

    Parameters

    • Default value toggle: boolean = false

      a boolean value to set if this function call should be a toggle (between pause and resume)

    Returns this

play

  • play(time?: number): this
  • Main play loop. This implements window.requestAnimationFrame and calls it recursively. Override this play() function to implemenet your own animation loop.

    Parameters

    • Default value time: number = 0

      current time

    Returns this

Protected playItems

  • playItems(time: number): void
  • Main animate function. This calls all the items to perform

    Parameters

    • time: number

      current time

    Returns void

playOnce

  • playOnce(duration?: number): this
  • Play animation loop, and then stop after duration time has passed.

    Parameters

    • Default value duration: number = 5000

      a value in millisecond to specify a time period to play before stopping, or -1 to play forever

    Returns this

refresh

  • refresh(b: boolean): this
  • Set whether the rendering should be repainted on each frame

    Parameters

    • b: boolean

      a boolean value to set whether to repaint each frame

    Returns this

remove

  • Remove a player from this Space

    Parameters

    • player: IPlayer

      an IPlayer that has an animateID property

    Returns this

removeAll

  • removeAll(): this

Protected render

  • render(context: any): this
  • Custom rendering

    Parameters

    • context: any

      rendering context

    Returns this

replay

  • replay(): void
  • Replay the animation after stop(). This resets the end-time counter. You may also use pause() and resume() for temporary pause.

    Returns void

resize

  • resize(b: IPt, evt?: Event): this

resume

  • resume(): this

stop

  • stop(t?: number): this
  • Specify when the animation should stop: immediately, after a time period, or never stops.

    Parameters

    • Default value t: number = 0

      a value in millisecond to specify a time period to play before stopping, or -1 to play forever, or 0 to end immediately. Default is 0 which will stop the animation immediately.

    Returns this

touchesToPoints

  • A convenient method to convert the touch points in a touch event to an array of Pt.

    Parameters

    • evt: TouchEvent

      a touch event which contains touches, changedTouches, and targetTouches list

    • Default value which: TouchPointsKey = "touches"

      a string to select a touches list: "touches", "changedTouches", or "targetTouches". Default is "touches"

    Returns Pt[]

    an array of Pt, whose origin position (0,0) is offset to the top-left of this space

unbindCanvas

  • unbindCanvas(evt: string, callback: EventListener): void
  • Unbind a callback from the event listener

    Parameters

    • evt: string

      an event string such as "mousedown"

    • callback: EventListener

      callback function to unbind

    Returns void

Object literals

Protected _time

_time: object

diff

diff: number = 0

end

end: number = -1

prev

prev: number = 0

Generated using TypeDoc