Home Reference Source
public class | source

GameObject

Extends:

pixi.js~PIXI.Sprite → GameObject

Direct Subclass:

Player

GameObject class that all objects in the game space should inherit. Provides standard field variables such as posX and posY, as well as standard methods to manipulate them.

A GameObject cannot be added directly; it must be inherited. setup() and tick() must be overridden.

Constructor Summary

Public Constructor
public

constructor(texture: PIXI.Texture, id: string, x: number, y: number, vx: number, vy: number)

Creates a new GameObject.

Member Summary

Public Members
public
public

id: *

public

posX: *

public

posY: *

public

texture: *

public

vx: *

public

vy: *

public

x: *

public

y: *

Method Summary

Public Methods
public

Destroyes the Sprite

public

draw()

Call during tick() if necessary.

public

TEMP Moves this object to (9999, 9999) on local screen space, effectively hiding it from view.

public

setCoordinates(newX: number, newY: number)

Sets global coordinates of this player

public

setData(newX: number, newY: number, vx: number, vy: number)

Sets global coordinates and speeds of this player

public

setup()

Override optional.

public

tick(noDraw: boolean)

Override optional.

Public Constructors

public constructor(texture: PIXI.Texture, id: string, x: number, y: number, vx: number, vy: number) source

Creates a new GameObject.

Params:

NameTypeAttributeDescription
texture PIXI.Texture

The texture associated with this sprite

id string

Unique identifier- for example, socket ID for players, numerical ID for atoms

x number

Global x-coordinate

y number

Global y-coordinate

vx number

Horizontal velocity

vy number

Vertical velocity

Public Members

public destroyed: boolean source

public id: * source

public posX: * source

public posY: * source

public texture: * source

public vx: * source

public vy: * source

public x: * source

public y: * source

Public Methods

public destroy() source

Destroyes the Sprite

public draw() source

Call during tick() if necessary. Draws object in the correct position on the player screen.

public hide(): number source

TEMP Moves this object to (9999, 9999) on local screen space, effectively hiding it from view.

Return:

number

public setCoordinates(newX: number, newY: number) source

Sets global coordinates of this player

Params:

NameTypeAttributeDescription
newX number

New x-coordinate to move to

newY number

New y-coordinate to move to

public setData(newX: number, newY: number, vx: number, vy: number) source

Sets global coordinates and speeds of this player

Params:

NameTypeAttributeDescription
newX number

New x-coordinate to move to

newY number

New y-coordinate to move to

vx number

New x velocity

vy number

New y velocity

public setup() source

Override optional. Called once, during game setup phase.

public tick(noDraw: boolean) source

Override optional. Default behavior: handles movement. Call super.tick() from child class if movable.

Params:

NameTypeAttributeDescription
noDraw boolean

true if tick() should only process movement, not drawing.