希望精灵通过重力感应移动。小白第一次使用重力感应。
cc.Class({
extends: cc.Component,
properties: {
sprite:cc.Node,
},
// use this for initialization
onLoad: function () {
var self = this
var listener1 = cc.EventListener.create({
event: cc.EventListener.ACCELERATION,
callback: function (accelEvent, event) {
this.sprite.x = accelEvent.x
this.sprite.y = accelEvent.y
cc.log('scuss')
return true
}.bind(self),
});
cc.eventManager.addListener(listener1, this.node);
},
});请问如何修改。