@fatihwk 写道:
在网页运行没有错误, 但编译运行ios版本时出现body is null错误,导致无法运行:
cocos2d: fullPathForFilename: No file found at script/jsb_prepare.jsc. Possible missing file. cocos2d: fullPathForFilename: No file found at script/jsb_boot.jsc. Possible missing file. JS: Cocos2d-JS v3.13 (evaluatedOK == JS_FALSE) JS: /Users/q/Library/Developer/CoreSimulator/Devices/B2CDA198-FCB0-4E04-B9D5-6A3A0F93C4BF/data/Containers/Bundle/Application/9FEBE876-DAB6-429E-83A6-C4C171C7E788/ Tank-mobile.app/script/physicsSprite/jsb_physicsSprite.js:51:TypeError: body is null Evaluating main.js failed (evaluatedOK == JS_FALSE) 2016-11-17 16:15:29.843 Tank-mobile[33112:552538] cocos2d: surface size: 1136x640 cocos2d: QuadCommand: resizing index size from [-1] to [2560] 2016-11-17 16:15:29.865 Tank-mobile[33112:552538] cocos2d: surface size: 1136x640
代码:
var Bullet = cc.PhysicsSprite.extend({ attack:100, type:"bullet", uid:0, speed:10, phyBody:null, shape:null, world:null, isDead:false, ctor:function (target, pos,uid) { this._super(); cc.log("create bullet "); this.world = target; this.uid = uid; this.initWithSpriteFrameName("bullet.png" ); this.setAnchorPoint(0.5,0.5); var radius = this.getContentSize().width/2; mass = 2; this.phyBody = target.space.addBody(new cp.Body(mass, cp.momentForCircle(mass, 0, radius, cp.v(0, 0)))); this.phyBody.owner = this; this.phyBody.setPos(pos); this.shape = new cp.CircleShape(this.phyBody, radius, cp.v(0, 0)); var circle = target.space.addShape(this.shape); circle.setElasticity(1); circle.setFriction(0); circle.setCollisionType(collisions.COLLISIONS_TYPE_BULLET); this.body = this.phyBody; this.setBody( this.phyBody ); return this; },
帖子: 1
参与者: 1