API Docs for: 0.1.0
Show:

CG.B2DChainShape Class

Extends CG.B2DEntity
Module: CG

B2DChainShape


                            var e = new CG.B2DChainShape({
                                  name: 'player',
                                  points: [new CG.Point(10,10), new CG.Point(300,50), new CG.Point(450,10)],
                                  x: 100,
                                  y: 100,
                                  world: b2world,
                                  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?

convertRealWorldPointToBox2DVec2

(
  • vertices
)
Array

convertRealWorldPointToBox2DVec2 converts real world vectors to box2d world vecs depending on scale

Parameters:

  • vertices Array

    CG.Point array

Returns:

Array:

vecs b2Vec2 with box2d world scale

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-chainshape.js:24

Options: name {string} points {array} x {number} y (number} world {object} scale {number}

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

Inherited from CG.B2DEntity but overwritten in cangaja/box2d/b2d-chainshape.js:81

bodyDef

B2BodyDef

bodyDef.alowSleep

Boolean

bodyDef.angle

Number

bodyDef.awake

Boolean

bodyDef.bullet

Boolean

bodyDef.fixedRotation

Boolean

bodyDef.position

Unknown

bodyDef.type

box2d.b2BodyType.b2_staticBody/box2d.b2BodyType.b2_dynamicBody/box2d.b2BodyType.b2_kinematicBody/box2d.b2BodyType.b2_bulletBody

bodyDef.userData

bodyType

box2d.b2BodyType

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

fixDef.shape

B2CircleShape

fixedRotation

Boolean

groupIndex

Number

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

height

Number

mapcollision

Boolean

rotation

Number

scale

Inherited from CG.B2DEntity but overwritten in cangaja/box2d/b2d-entity.js:50

transform

Transform

Transform object for matrix transformation

visible

Boolean

visibility option

world

Inherited from CG.B2DEntity but overwritten in cangaja/box2d/b2d-entity.js:45

xhandle

Number

xscale

Number

yhandle

Number

yscale

Number