12345678910111213141516171819202122232425262728 |
- import { _decorator, AnimationClip, Component, Node, Sprite, SpriteFrame, Vec3 } from 'cc';
- import { Tools } from './Tools/Tools';
- const { ccclass, property } = _decorator;
- @ccclass('Bullet')
- export class Bullet extends Component {
- start() {
- }
- init(pos: Vec3, angle: number, frames: SpriteFrame[]) {
- this.node.setPosition(pos);
- this.node.angle = angle;
- if(frames.length === 1){
- this.getComponent(Sprite).spriteFrame = frames[0];
- return;
- }
-
- const ani = Tools.createAnimation(frames, 25, this.node, AnimationClip.WrapMode.Loop);
- ani.play();
- }
- update(deltaTime: number) {
- this.node.translate(new Vec3(0, 5));
- }
- }
|