百度公司招聘岗位,上海seo优化推广,小程序制作一个需要多少钱,东莞品牌型网站建设价格Cocos Creator#xff1a;创建棋盘 创建地图三部曲#xff1a;1. 创建layout组件2. 创建预制体Prefab#xff0c;做好精灵贴图#xff1a;3. 创建脚本LayoutSprite.ts收尾工作#xff1a; 创建地图三部曲#xff1a;
1. 创建layout组件
使用layout进行布局#xff0c;… Cocos Creator创建棋盘 创建地图三部曲1. 创建layout组件2. 创建预制体Prefab做好精灵贴图3. 创建脚本LayoutSprite.ts收尾工作 创建地图三部曲
1. 创建layout组件
使用layout进行布局定义好Grid网格模式做以下设置
2. 创建预制体Prefab做好精灵贴图 3. 创建脚本LayoutSprite.ts
import { _decorator, Component, Node, instantiate, Prefab} from cc;
const { ccclass, property } _decorator;ccclass(LayoutSprite)
export class LayoutSprite extends Component {property({ type: Prefab })private gridItemPrefab null;private myuuid [];start() {//实例化一个gridItemPrefabfor (let i 0; i 64; i) {let gridCell instantiate(this.gridItemPrefab);this.node.addChild(gridCell);this.myuuid.push(gridCell.uuid);console.log(gridCell.uuid);}// console.log(this.myuuid[0]);// console.log(this.node.getChildByUuid(this.myuuid[0]));}}收尾工作
挂载脚本LayoutSprite.ts到layout组件上拖上去挂载预制体prefab到脚本的gridItemPrefab属性上。大功告成