BulletNode.ts 763 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { _decorator, Collider2D, Contact2DType, IPhysics2DContact, Node, tween, v3, Vec3 } from 'cc';
  2. import { NodeEx } from '../../framework/pool/NodeEx';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('BulletNode')
  5. export class BulletNode extends NodeEx {
  6. protected onLoad() {
  7. }
  8. setGoPos(pos,back) {
  9. let direction = 0.2
  10. if (pos < 0) {
  11. direction = -0.2
  12. }
  13. this.node.scale = new Vec3(direction, 0.2, 0.2)
  14. tween(this.node).to(0.2, { position: pos }).call(() => {
  15. back()
  16. }).start();
  17. }
  18. protected onDestroy() {
  19. //如果该组件有事件自行取消注释
  20. //Framework.event.removeEvent(this);
  21. super.onDestroy();
  22. }
  23. //节点被放入池中时调用
  24. unuse() {
  25. }
  26. //节点从池中取出时调用
  27. reuse(...val: any[]) {
  28. }
  29. }