Helloworld.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const {ccclass, property} = cc._decorator;
  2. import { SDK as sdk, MOTION, CMD} from './sdk';
  3. @ccclass
  4. export default class Helloworld extends cc.Component {
  5. @property(cc.Label)
  6. label: cc.Label = null;
  7. @property(cc.Button)
  8. left: cc.Button = null;
  9. @property(cc.Button)
  10. right: cc.Button = null;
  11. @property
  12. text: string = 'hello1111123123123';
  13. start () {
  14. // init logic
  15. this.label.string = this.text;
  16. sdk.on(MOTION.LEFT_DOWN.toString(), (ts)=>{
  17. console.log("MOTION.LEFT .. " + ts);
  18. console.log("MOTION.LEFT .. " + ts + "," + this.name);
  19. });
  20. sdk.on(MOTION.LEFT_DOWN.toString(), this._onMotionLeft, this);
  21. sdk.on(CMD.ENTER_KEY.toString(), this._ok, this);
  22. sdk.once(MOTION.LEFT_DOWN.toString(), (ts)=>{
  23. console.log("MOTION.LEFT .. once " + ts + "," + this.name);
  24. });
  25. sdk.once(MOTION.LEFT_DOWN.toString(), this._onMotionLeftOnce, this);
  26. sdk.getUserInfo(this.user)
  27. sdk.getRank(0, this.getRank)
  28. //确认
  29. sdk.on(CMD.ENTER_KEY.toString(), this._ok, this);
  30. //取消
  31. sdk.on(CMD.CANCLE_KEY.toString(), this._ok, this);
  32. //取消
  33. sdk.on(CMD.BACK_LEFT.toString(), this._ok, this);
  34. //取消
  35. sdk.on(CMD.BACK_RIGHT.toString(), this._ok, this);
  36. // sdk.on(MOTION.LEFT.toString(), this._ok, this);
  37. // sdk.on(MOTION.RIGHT.toString(), this._ok, this);
  38. // sdk.on(MOTION.STEP.toString(), this._ok, this);
  39. }
  40. user(json){
  41. console.log("getUserInfo 1111111 " + json);
  42. }
  43. getRank(args){
  44. console.log("getRank 1111 type: " + args[0] + " == " + args[1] + " == " + args[1]["list"].length);
  45. }
  46. protected update(dt: number): void {
  47. // console.log("motion get" + sdk.getMotion());
  48. // console.log("isLeftFootDown " + sdk.isLeftFootDown() + ", dt: " + dt);
  49. // console.log("isRightFootDown " + sdk.isRightFootDown());
  50. }
  51. _onMotionLeft(ts){
  52. console.log("MOTION.LEFT .. _onMotionLeft" + ts + "," + this.name);
  53. sdk.off(MOTION.LEFT_DOWN.toString(), this._onMotionLeft);
  54. }
  55. _onMotionLeftOnce(ts){
  56. console.log("MOTION.LEFT .. _onMotionLeftOnce" + ts + "," + this.name);
  57. }
  58. _ok() {
  59. console.log(" -- cmd._ok ");
  60. }
  61. }