Class: ParallaxGameObject

ParallaxGameObject(renderableObj, scale, aCamera)

Represent a GameObject located at some distance D away, thus resulting in slower movements

Found in Chapter 11, page 681 of the textbook

Example: 11.2 Parallax Objects

Constructor

new ParallaxGameObject(renderableObj, scale, aCamera)

Parameters:
Name Type Description
renderableObj Renderable the Renderable associated with this ParallaxGameObject
scale float determines how far forward or back this ParallaxGameObject is

==1: means same as actors

> 1: farther away, slows down inversely (scale==2 slows down twice)

< 1: closer, speeds up inversely (scale==0.5 speeds up twice)

aCamera Camera the Camera this ParallaxGameObject will be drawn to
Source:

Extends

Methods

_drawTile(aCamera)

Draws a grid of tiles filling every available space within the Camera
Parameters:
Name Type Description
aCamera Camera the Camera to draw to
Inherited From:
Source:

draw(aCamera)

Draws this TiledGameObject if visible and executes tiling if it should tile
Parameters:
Name Type Description
aCamera Camera the Camera to draw to
Inherited From:
Source:

getBBox() → {BoundingBox}

Returns the BoundingBox for this gameObject
Inherited From:
Source:
Returns:
a new copy of the bounding box of this GameObject
Type
BoundingBox

getCurrentFrontDir() → {vec2}

Returns the front direction of this gameObject
Inherited From:
Source:
Returns:
mCurrentFrontDir - the current front direction of this gameObject
Type
vec2

getParallaxScale() → {float}

Returns the current distance scale for this ParallaxGameObject
Source:
Returns:
mParallaxScale - the distance scale
Type
float

getRenderable() → {Renderable}

Returns the renderable associated with this gameObject
Inherited From:
Source:
Returns:
mRenderComponent - the renderable associated with this gameObject
Type
Renderable

getRigidBody() → {RigidShape}

Returns the RigidShape of this gameObject
Inherited From:
Source:
Returns:
mRigidBody - the RigidShape of this gameObject
Type
RigidShape

getXform() → {Transform}

Returns the Transform of the Renderable associated with this GameObject
Inherited From:
Source:
Returns:
the Transform of this GameObject
Type
Transform

isVisible() → {boolean}

Returns the visibility of this gameObject
Inherited From:
Source:
Returns:
mVisible - the visivility of this gameObject
Type
boolean

pixelTouches(otherObj, wcTouchPos) → {boolean}

Determines if this GameObject has an overlapping pixel with another GameObject
Parameters:
Name Type Description
otherObj GameObject the other GameObject
wcTouchPos vec2 vector to store the first world coordinates where the pixels touch
Inherited From:
Source:
Returns:
whether this GameObject has a pixel overlapping otherObj
Type
boolean

setCurrentFrontDir(f)

Changes this gameObject's current facing direction
Parameters:
Name Type Description
f vec2 vector that will be put into mCurrentFrontDir after being normalized
Inherited From:
Source:

setIsTiled(t)

Set the tiling property to true or false
Parameters:
Name Type Description
t boolean the tiling state
Inherited From:
Source:

setParallaxScale(s)

Set the distance scale for this ParallaxGameObject
Parameters:
Name Type Description
s float the new distance scale

==1: means same as actors

> 1: farther away, slows down inversely (scale==2 slows down twice)

< 1: closer, speeds up inversely (scale==0.5 speeds up twice)

Source:

setRigidBody(r)

Sets the rigid body this gameObject will use
Parameters:
Name Type Description
r RigidShape the rigid body
Inherited From:
Source:

setVisibility(f)

Sets the visibility of this gameObject to true or false
Parameters:
Name Type Description
f boolean boolean to set if this gameObject is visibile or not
Inherited From:
Source:

setWCTranslationBy(delta)

Set world coordinate translation delta to change the position of this ParallaxGameObject
Parameters:
Name Type Description
delta vec2 [x,y] world coordinate values to translate
Source:

shouldTile() → {boolean}

Returns whether or not tiling is active for this TiledGameObject
Inherited From:
Source:
Returns:
mShouldTile - true if tiling is active
Type
boolean

toggleDrawRenderable()

Switches whether this gameObject's renderable is drawn
Inherited From:
Source:

toggleDrawRigidShape()

Switches whether this gameObject's rigid shape is drawn
Inherited From:
Source:

update()

Update this ParallaxGameObject, moving it if the Camera has moved
Overrides:
Source: