CocosCreator-3.0-动态生成3种敌人
import { _decorator, Component, Node, Label, Sprite, Vec3, Prefab, instantiate, director, resources, SpriteFrame, Layers, UITransform, Canvas, view, View } from 'cc';
const { ccclass, property } = _decorator;
// 全局变量
var nodeFatherX: Node;
var frame: number = 0; //总共绘制的帧数
var arrayPlane = [];
var arrayPlaneNunber: number = -2; //累计生成敌人数
var gameWidthX: number = 0; //游戏宽度
var gameHeightX: number = 0; //游戏高度
@ccclass('Fish')
export class Fish extends Component {
// [1]
// dummy = '';
// [2]
// @property
// serializableDummy = 0;
@property({ type: SpriteFrame })
public spriteFrameEnemyBig: SpriteFrame | null = null; // 精灵框架敌人大号
@property({ type: SpriteFrame })
public spriteFrameEnemyMid: SpriteFrame | null = null; // 精灵框架敌人中号
@property({ type: SpriteFrame })
public spriteFrameEnemySmall: SpriteFrame | null = n

本文介绍了如何使用CocosCreator 3.0进行游戏开发,重点讲解动态生成不同类型的敌人的方法,涵盖了敌人的创建、管理以及与游戏逻辑的交互,为游戏增加更多趣味性和挑战性。
最低0.47元/天 解锁文章
3577

被折叠的 条评论
为什么被折叠?



