cocos2d js v3.0 alpha 使用 chipmunk , jsb 打包问题汇总

cocos2d js v3.0 alpha 使用 chipmunk , jsb 打包问题汇总
0.0 0



1.提示 TypeError: cc.PhysicsSprite.extend is not a function

2.尝试把cc.PhysicsSprite.extend 改成
运行后又提示:JS: assets/jsb_cocos2d_extension.js:173:TypeError: body is null

var createBoxSprite = function(target,staticBody, pos,mass,radius,width,height,file,collision_type,tag){
       var body = new cp.Body(1, cp.momentForBox(mass,width , height));
       if (!staticBody){
       var shape = cp.BoxShape(body,width,height ));
       var sprite = cc.PhysicsSprite.create(imgFile);
       target.addChild(sprite,100,tag) ;
       function getBody()  {
                return body;
       function getShape() {
             return shape;
       return sprite;


但对此"BoxSprite"做 cc.MoveBy 或 MoveTo 时 ,

发现 shape 在运行,但sprite的 imgFile 静止不动 is not a function

5.以前的cocos2d-x-3.0 alpha1 和beta 版上jsb打包是ok的,直接浏览器上跑也Ok

希望 v3.0 js 能整合得更完美点。


Hi, @watson.wan

Sorry for the inconvenient, the inheritance of Cocos2d-JS 3.0a is not perfect, so cc.PhysicsSprite and cc.ParticleExplosion haven’t support extend yet.
but we are working on this, in the next version there will be no problem.




cc.PhysicsSprite now support extend in Cocos2d-JS 3.0 alpha2, but we still have another problem, the physics sprite’s transform is not correctly updated, so it doesn’t move with the physics entity. But it will be fixed soon, temporarily, if you add your PhysicsSprite into a SpriteBatchNode, it will work correctly.


我下午用js alpha2在android打包运行了,只是目前还是发现几个问题

1.通过 cc.PhysicsSprite.extend的物理精灵会报如下的错(其实我有setBody)
JS: assets/jsb_cocos2d_extension.js:194:TypeError: body is null 粒子仍然是未定义,无法使用