API Docs for: 0.1.0
Show:

CG.B2DEntity Class

Extends CG.Entity
Module: CG

B2DEntity is the base class with properties for all B2D objects. This class handles also the drawings for all classes.


                        var e = new CG.B2DEntity({
                          name: 'player',
                          image: new CG.Point(100,100),
                          world: b2world,
                          x: 10,
                          y: 20,
                          scale: 40
                        })
                        

Methods

AABB

() Object

returns the bounds of rotated rectangle

Returns:

Object:

returns the calculated bounds

addVelocity

(
  • b2Vec2
)

Parameters:

applyImpulse

(
  • degrees
  • power
)

Parameters:

checkCollision

(
  • objects
  • callback
)

checks if there is a collision of the given objects to this object http://devmag.org.za/2009/04/13/basic-collision-detection-in-2d-part-1/

Parameters:

  • objects Array

    a array of objects to check for collision => Sprites, Animations, MapAreas

  • callback Callback

    what to do after collision?

getPosition

()

hit

(
  • impulse
  • source
)

Parameters:

ifClicked

() True/false

checks click inside of the rectangle, supports rotation

Returns:

True/false:

ifMouseOver

()

checks if the mouse/pointer is over the rectangle

init

(
  • options
)

Inherited from CG.Entity but overwritten in cangaja/box2d/b2d-entity.js:25

Options: name {string} id or name to identify image {mixed} path to image, image or atlasimage from asset world {object} reference to world of B2DWorld x {number} the x position y {number} the y position scale {number} the world scale of B2DWorld

Parameters:

Returns:

:

setImage

(
  • image
)

initialize image for object. for now => sprite, particle, buffer, bitmap and button use it

Parameters:

  • image Image

    image path, image or atlasimage

setPosition

(
  • b2Vec2
)

Parameters:

setType

(
  • b2BodyType
)

Parameters:

Properties

body

B2Body

bodyDef

B2BodyDef

bodyDef.alowSleep

Boolean

bodyDef.angle

Number

bodyDef.awake

Boolean

bodyDef.bullet

Boolean

bodyDef.fixedRotation

Boolean

boundingradius

Number

bullet

B2Body

categoryBits

Number

clicked

Boolean

dragable

Boolean

fixDef

B2FixtureDef

fixDef.density

Number

fixDef.filter.categoryBits

Number

fixDef.filter.groupIndex

Number

fixDef.filter.maskBits

Number

fixDef.friction

Number

fixDef.restitution

Number

fixedRotation

Boolean

groupIndex

Number

if groupindex is 0 then use categoryBits and maskBits for collision detection

height

Number

mapcollision

Boolean

restitution

Number

rotation

Number

transform

Transform

Transform object for matrix transformation

visible

Boolean

visibility option

world

B2World

xhandle

Number

xscale

Number

yhandle

Number

yscale

Number