CG.B2DEntity Class
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
})
Item Index
Methods
Properties
- allowSleep
- alpha
- angle
- awake
- body
- body
- bodyDef
- bodyDef.alowSleep
- bodyDef.angle
- bodyDef.awake
- bodyDef.bullet
- bodyDef.fixedRotation
- boundingradius
- bullet
- categoryBits
- clicked
- dead
- density
- dragable
- fixDef
- fixDef.density
- fixDef.filter.categoryBits
- fixDef.filter.groupIndex
- fixDef.filter.maskBits
- fixDef.friction
- fixDef.restitution
- fixedRotation
- friction
- groupIndex
- height
- hover
- id
- isHit
- mapcollision
- maskBits
- restitution
- rotation
- scale
- scale
- strength
- transform
- visible
- width
- world
- world
- x
- xhandle
- xscale
- y
- yhandle
- yscale
Methods
AABB
()
Object
returns the bounds of rotated rectangle
Returns:
returns the calculated bounds
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
Arraya array of objects to check for collision => Sprites, Animations, MapAreas
-
callback
Callbackwhat to do after collision?
getPosition
()
ifClicked
()
True/false
checks click inside of the rectangle, supports rotation
Returns:
ifMouseOver
()
checks if the mouse/pointer is over the rectangle
init
-
options
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:
-
options
Object
Returns:
setImage
-
image
initialize image for object. for now => sprite, particle, buffer, bitmap and button use it
Parameters:
-
image
Imageimage path, image or atlasimage
Properties
body
body
B2Body
bodyDef
B2BodyDef
bullet
B2Body
fixDef
B2FixtureDef
scale
transform
Transform
Transform object for matrix transformation