Quantcast
Channel: Cocos中文社区 - 最新帖子
Viewing all articles
Browse latest Browse all 494966

小白求教如何让重力感应只能上下左右四个方向走?

$
0
0

感觉callback函数改成这样:

callback: function (accelEvent, event) {
	if (Math.abs(this.speed.x) > Math.abs(this.speed.y)) {
		this.speed.x = accelEvent.x
		this.speed.y = 0
	} 
	else {
		this.speed.x = 0
		this.speed.y = accelEvent.y
	}
}

应该可以吧


Viewing all articles
Browse latest Browse all 494966

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>