I’m trying to access the shape (actually, shapeList
) of a Chipmunk body, but I’m getting an undefined error. I’m using Cocos2D-JS v3.6.
So, I’ve taken the following code and ran it on chrome and in the win32-debugger of Cocos Code IDE:
for (var i in myPhysicsSprite.body) {
console.log(i);
}
In the browser I get the following:
p
vy
vx
f
w
t
v_limit
w_limit
v_biasy
v_biasx
w_bias
space
shapeList
arbiterList
constraintList
nodeRoot
nodeNext
nodeIdleTime
m
m_inv
i
i_inv
rot
a
sanityCheck
getPos
getVel
getAngVel
isSleeping
isStatic
isRogue
setMass
setMoment
addShape
removeShape
removeConstraint
setPos
setVel
setAngVel
setAngleInternal
setAngle
velocity_func
position_func
resetForces
applyForce
applyImpulse
getVelAtPoint
getVelAtWorldPoint
getVelAtLocalPoint
eachShape
eachConstraint
eachArbiter
local2World
world2Local
kineticEnergy
activate
activateStatic
pushArbiter
sleep
sleepWithGroup
But when I run as win32 debug on Cocos Code IDE’s debugger I only get:
vx
vy
m_inv
i_inv
activate
activateStatic
applyForce
applyImpulse
destroy
getAngVel
getAngVelLimit
getAngle
getForce
getMass
getMoment
getPos
getRot
getSpace
getTorque
getVel
getVelAtLocalPoint
getVelAtWorldPoint
getVelLimit
init
initStatic
isRogue
isSleeping
isStatic
kineticEnergy
local2World
resetForces
setAngVel
setAngVelLimit
setAngle
setForce
setMass
setMoment
setPos
setTorque
setVel
setVelLimit
sleep
sleepWithGroup
updatePosition
updateVelocity
world2Local
setUserData
getUserData
eachShape
eachConstraint
eachArbiter
getHandle
setHandle
So, I can salvage this by manually adding and maintaining a property with the shapes to the PhysicsSprite
directly, but I wonder if the API shouldn’t be the same between execution environments.