我在 Android(Nexus 5、Android 4.4.4)中收到一些“无效的本机对象”错误。在浏览器版本中没有错误。
我将应用程序的代码部分放入一个全新的 helloworld 应用程序中。第 59 行,出现错误的位置如下所示。这是来自 ADB 的 logcat 消息:
D/cocos2d-x 调试信息(32165):jsb:错误:文件/Applications/MAMP/htdocs/test_actions/frameworks/runtime-src/proj.android/../../js-bindings/bindings/auto/jsb_cocos2dx_auto .cpp: Line: 3955, Function: js_cocos2dx_Node_runAction D/cocos2d-x debug info(32165): Invalid Native Object D/cocos2d-x debug info(32165): JS: assets/src/app.js:59:Error: Invalid Native Object D/cocos2d-x 调试信息(32165):
这是代码。
var HelloWorldLayer = cc.Layer.extend({ sprite:null, ctor:function () {
var self = this; ////////////////////////////// // 1. super init first this._super(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // ask director the window size var size = cc.director.getWinSize(); // Load sprite frames to frame cache, add texture node cc.spriteFrameCache.addSpriteFrames(res.murbiks_plist); var murbiksImages = cc.SpriteBatchNode.create(cc.textureCache.addImage(res.murbiks_png)); self.addChild(murbiksImages); var anims = {}; var loadFrames = function(name,cnt) { var frames = []; for (var i = 1; i <= cnt; i++) { str = name + (i < 10 ? ("0" + i) : i); frames.push(cc.spriteFrameCache.getSpriteFrame(str)); } var anim = cc.Animation.create(frames, 0.06); anim.retain(); anims[name] = cc.animate(anim); } loadFrames("mostafa_fly",9); loadFrames("mostafa_land",7); var mostafa = cc.Sprite.create(res.murbiks_single_png); mostafa.attr({ x: 0, y: 0, scale: 1.9, rotation: 0 }); mostafa.retain(); self.addChild(mostafa, 5); var animAction = mostafa.runAction(cc.repeatForever(anims.mostafa_fly)), bezierMostafa = [ cc.p(0,0), cc.p(200,520), cc.p(500,220) ]; var mostafaAction = mostafa.runAction( cc.sequence( cc.bezierTo(2.5, bezierMostafa), cc.callFunc(function() { self.stopAction(animAction); animAction = mostafa.runAction(anims.mostafa_land); // LINE 59, INVALID NATIVE OBJECT }) ) ); return true;
} });
那会是什么?