1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // Learn TypeScript:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
- // Learn Attribute:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class footstepmove extends cc.Component {
- @property(cc.Label)
- label: cc.Label = null;
- @property
- text: string = 'hello';
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {}
- start() {
- this.node.on(cc.Node.EventType.TOUCH_START, this.sttt, this);//当手指在背景上移动时触发move事件
- this.node.on(cc.Node.EventType.TOUCH_MOVE, this.move, this);//当手指在背景上移动时触发move事件
- }
- move(event: cc.Event.EventTouch) {//负责移动摇杆 手指移动时调用
- // this.node.x += (event.getLocationX() - this.startpos.x) * 0.1
- // this.node.y += (event.getLocationY() - this.startpos.y) * 0.1
- this.node.x += event.getDeltaX()
- this.node.y += event.getDeltaY()
- }
- sttt(event: cc.Event.EventTouch) {//负责移动摇杆 手指移动时调用
- window['selectfootstep'] = this.node
- }
- // update (dt) {}
- }
|