CG.B2DRope Class
B2DRope is a simple wrapper that creates a rope with segments. Just play with the params to get a good result.
var e = new CG.B2DRope({
name: 'player',
image: this.asset.getImageByName('glowball'),
x: 100,
y: 100,
length: 600,
segments: 20
segmentWidth: 4,
world: b2world,
scale: 40
})
Item Index
Methods
Properties
- allowSleep
- alpha
- anchor
- angle
- awake
- body
- bodyCount
- bodyDef
- bodyDef.alowSleep
- bodyDef.angle
- bodyDef.awake
- bodyDef.bullet
- bodyDef.fixedRotation
- bodyGroup
- boundingradius
- bullet
- categoryBits
- clicked
- dead
- density
- dragable
- enableLimit
- fixDef
- fixDef.density
- fixDef.filter.categoryBits
- fixDef.filter.groupIndex
- fixDef.filter.maskBits
- fixDef.friction
- fixDef.restitution
- fixedRotation
- friction
- groupIndex
- height
- hover
- id
- isHit
- length
- lowerAngle
- mapcollision
- maskBits
- prevBody
- restitution
- rotation
- scale
- segmentHeight
- segments
- segmentWidth
- strength
- transform
- upperAngle
- visible
- width
- 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} image {mixed} x {number} y (number} length {number} segments {number} segmentHeight {number} world {object} scale {number}
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
anchor
B2Vec2
body
bodyDef
B2BodyDef
bullet
B2Body
fixDef
B2FixtureDef
scale
segmentWidth
transform
Transform
Transform object for matrix transformation