运行报错,不知道怎么追踪,求围观

cocos creator 2.4.3
谷歌浏览器

事情的经过是这样的,当时:
代码替换掉SpriteFrame的时候,这样报错就很郁闷了,关键还是什么都不改的情况下,每次运行的报错数量都不一样,有时候也不会报错,求大神帮忙侦查一下

源码是这样的:
cc.tween(this.node)
.to(1, {
position: cc.v2(
Math.floor(Math.random()*200)+this.targetNode.x + this.node.parent.x -100 ,
Math.floor(Math.random()*340)+this.targetNode.y - this.node.parent.y -50
), angle: 2000
}, { easing: ‘sineIn’})
.call(() => {
//派送击中音效事件
this.node.dispatchEvent( new cc.Event.EventCustom(‘atkEnd’, true) );
var urlATK = “0”
var thisDao = this.node.getChildByName(“img”).getComponent(cc.Sprite)
cc.resources.load(urlATK, cc.SpriteFrame, function (err, spriteframe) {
thisDao.spriteFrame = spriteframe
})
})
.to(0.3, { scale: 2 })
.call(() => {
this.node.destroy()
})
.start()

你这里异步加载spriteFrame,然后后面又在destory,这里有问题吧?

果然destory注释掉之后,运行了十几次都没有出现这个报错了。可是如果不destory画面就很难看,一片爆炸的spriteframe停留在上面,请问怎么实现这个效果呢?

不异步就行了,在组件中直接加一个spriteframe属性,直接赋值不在动作中加载

1赞

解决了,十分感谢! :snowboarder:

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。