JoystickTest.ts 641 B

12345678910111213141516171819202122232425262728293031
  1. import Joystick_8d from "./Joystick_8d";
  2. const {ccclass, property} = cc._decorator;
  3. @ccclass
  4. export default class JoystickTest extends cc.Component {
  5. @property(Joystick_8d)
  6. joystick: Joystick_8d = null;
  7. @property(cc.Node)
  8. mMoveNode: cc.Node = null;
  9. public runing:boolean;
  10. public dir:cc.Vec2;
  11. onLoad () {
  12. // this.joystick.setCallback((run:boolean,dir)=>{
  13. // this.runing = run;
  14. // this.dir = dir;
  15. // });
  16. }
  17. update (dt) {
  18. if(this.runing){
  19. this.mMoveNode.x += this.dir.x*5;
  20. this.mMoveNode.y += this.dir.y*5;
  21. }
  22. }
  23. }