test1.ts 791 B

123456789101112131415161718192021222324252627
  1. import { _decorator, Component, Node, tween, Vec3 } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. class BindTarget{
  4. pos:Vec3;
  5. }
  6. @ccclass('test1')
  7. export class test1 extends Component {
  8. private bindTarget:BindTarget = null;
  9. @property(Node) test_btn:Node = null
  10. protected start(): void {
  11. this.test_btn.on(Node.EventType.TOUCH_START,()=>{
  12. console.log("test_btn TOUCH_START")
  13. })
  14. this.bindTarget = new BindTarget();
  15. this.bindTarget.pos = new Vec3(0,0)
  16. let self = this
  17. let color_opactiy_tw_size = tween(this.bindTarget).to(1,{pos:new Vec3(100,100)},{
  18. onUpdate(tar:BindTarget) {
  19. self.node.position = tar.pos
  20. },
  21. })
  22. color_opactiy_tw_size.start();
  23. }
  24. }