小弟正在学习,一头雾水,遇到一个很奇怪的问题,不知道是我写错了,还是什么问题,希望大家帮忙.
思路是,一个sprite有一个基础动画,是一直播放的,实现代码:
this._block = cc.Sprite.createWithSpriteFrame(cc.spriteFrameCache.getSpriteFrame(“shake0001.png”));
this._block.setPosition(GC.left, GC.down);
this.addChild(this._block);
this._block.runAction(cc.repeatForever(this.getAnimation(null)));
这一步是没有问题的,getAnimation方法是自定义方法,根据参数返回不同的动画.
然后启动定时器:
this.schedule(this.moveBlock, 3);
每三秒调用一次moveBlock方法.方法主要实现移动物体,并且在移动的同时播放一个其他的动画.
方法中,下面这一句就会报错
this._block.runAction(cc.spawn(cc.moveTo(0.3, position),this.getAnimation(“down”)));
错误信息:Error: Invalid Native Object
但是把这句放到定时器以外执行是没有问题的.实在找不到问题了.特此开帖,希望各位大大们帮忙一下.