Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

请问creator重力感应怎么用?

$
0
0

@758482981 写道:

希望精灵通过重力感应移动。小白第一次使用重力感应。
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);
},

});请问如何修改。

帖子: 4

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



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