@758482981 写道:
想写一个依靠重力感应过关的RPG游戏,但是游戏人物有移动方向,不同移动的方向的动画也不同。求教如何实现。
GSensor:function(){
cc.inputManager.setAccelerometerEnabled(true);
var self = this
var listener1 = cc.EventListener.create({
event: cc.EventListener.ACCELERATION,
callback: function (accelEvent, event) {
this.speed.x = accelEvent.x
this.speed.y = accelEvent.yreturn true }.bind(self), }); cc.eventManager.addListener(listener1, this.node); },,这么写只会四面八方移动。应该也可以根据移动的方向算出旋转的方向。那请问下如何算呢?
帖子: 3
参与者: 1