enemyPlane.ts 738 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { _decorator, Component, Node, sp } from 'cc';
  2. import { constant } from '../framework/constant';
  3. const { ccclass, property } = _decorator;
  4. const OUTOFBOUNCE = 50
  5. @ccclass('enemyPlane')
  6. export class enemyPlane extends Component {
  7. // @property
  8. // public enemySpeed = 0;
  9. private _enemySpeed = 0;
  10. public enemyType = constant.EnemyPlaneType.TYPE1
  11. start() {
  12. }
  13. update(deltaTime: number) {
  14. const pos = this.node.position;
  15. const movePos = pos.x - this._enemySpeed;
  16. this.node.setPosition(movePos, pos.y, pos.z)
  17. if(movePos > OUTOFBOUNCE){
  18. this.node.destroy()
  19. }
  20. }
  21. show(speed:number){
  22. this._enemySpeed = speed
  23. }
  24. }