1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- const {ccclass, property} = cc._decorator;
- import { SDK as sdk, MOTION, CMD} from './sdk';
- @ccclass
- export default class Helloworld extends cc.Component {
- @property(cc.Label)
- label: cc.Label = null;
- @property(cc.Button)
- left: cc.Button = null;
- @property(cc.Button)
- right: cc.Button = null;
- @property
- text: string = 'hello1111123123123';
- start () {
- // init logic
- this.label.string = this.text;
- sdk.on(MOTION.LEFT_DOWN.toString(), (ts)=>{
- console.log("MOTION.LEFT .. " + ts);
- console.log("MOTION.LEFT .. " + ts + "," + this.name);
- });
- sdk.on(MOTION.LEFT_DOWN.toString(), this._onMotionLeft, this);
- sdk.on(CMD.ENTER_KEY.toString(), this._ok, this);
- sdk.once(MOTION.LEFT_DOWN.toString(), (ts)=>{
- console.log("MOTION.LEFT .. once " + ts + "," + this.name);
- });
- sdk.once(MOTION.LEFT_DOWN.toString(), this._onMotionLeftOnce, this);
- sdk.getUserInfo(this.user)
- sdk.getRank(0, this.getRank)
- //确认
- sdk.on(CMD.ENTER_KEY.toString(), this._ok, this);
- //取消
- sdk.on(CMD.CANCLE_KEY.toString(), this._ok, this);
- //取消
- sdk.on(CMD.BACK_LEFT.toString(), this._ok, this);
- //取消
- sdk.on(CMD.BACK_RIGHT.toString(), this._ok, this);
-
- // sdk.on(MOTION.LEFT.toString(), this._ok, this);
- // sdk.on(MOTION.RIGHT.toString(), this._ok, this);
- // sdk.on(MOTION.STEP.toString(), this._ok, this);
- }
- user(json){
- console.log("getUserInfo 1111111 " + json);
- }
- getRank(args){
- console.log("getRank 1111 type: " + args[0] + " == " + args[1] + " == " + args[1]["list"].length);
- }
- protected update(dt: number): void {
- // console.log("motion get" + sdk.getMotion());
- // console.log("isLeftFootDown " + sdk.isLeftFootDown() + ", dt: " + dt);
- // console.log("isRightFootDown " + sdk.isRightFootDown());
- }
- _onMotionLeft(ts){
- console.log("MOTION.LEFT .. _onMotionLeft" + ts + "," + this.name);
- sdk.off(MOTION.LEFT_DOWN.toString(), this._onMotionLeft);
- }
- _onMotionLeftOnce(ts){
- console.log("MOTION.LEFT .. _onMotionLeftOnce" + ts + "," + this.name);
- }
- _ok() {
- console.log(" -- cmd._ok ");
- }
- }
|