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

请原谅英文不太好,全中文提交了!!!

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

2.尝试把cc.PhysicsSprite.extend 改成 cc.Class.extend.call(cc.PhysicsSprite
运行后又提示:JS: assets/jsb_cocos2d_extension.js:173:TypeError: body is null
3.使用下面的方式创建物理精灵

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));
                body.setPos(pos);
       if (!staticBody){
                target.space.addBody(body);
       }
       var shape = target.space.addShape(new cp.BoxShape(body,width,height ));
                shape.setCollisionType(collision_type);
                shape.setElasticity(0.5);
                shape.setFriction(0.1);
       var sprite = cc.PhysicsSprite.create(imgFile);
                sprite.setBody(body);
       target.addChild(sprite,100,tag) ;
       function getBody()  {
                return body;
       }
       function getShape() {
             return shape;
    }
       return sprite;
};

精灵创建成功,并加入场景

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

发现 shape 在运行,但sprite的 imgFile 静止不动

4.cc.ParticleExplosion.extend 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.

Huabin

@watson.wan

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

2.cc.ParticleGalaxy.extend 粒子仍然是未定义,无法使用