123456789101112131415161718192021222324252627282930 |
- import { _decorator, Component, Node } from 'cc';
- const { ccclass, property } = _decorator;
- const OUTOFRANGE = 50
- @ccclass('bullet')
- export class bullet extends Component {
- @property
- public bulletSpeed = 0;
- start() {
- }
- update(deltaTime: number) {
- const pos = this.node.position;
- const moveLength = pos.x + this.bulletSpeed;
- this.node.setPosition(moveLength, pos.y, pos.z)
- if(moveLength > OUTOFRANGE){
- this.node.destroy()
-
- }
-
- }
- }
|