canvas是node节点。不是Canvas
import { _decorator, Component, Node,Touch, EventTouch, systemEvent } from 'cc'; import { MapManager } from './MapManager'; import { CarManager } from './CarManager'; const { ccclass, property } = _decorator; @ccclass('GameCtrl') export class GameCtrl extends Component { @property({ type: MapManager, }) mapManager: MapManager | null = null; @property({ type: CarManager, }) carManager: CarManager | null = null; }
为什么不用map。ts 怕和map集合重复。
import { _decorator, Component, Node } from 'cc'; import { Car } from './Car'; const { ccclass, property } = _decorator; @ccclass('CarManager') export class CarManager extends Component { @property({ type: Car }) mainCar: Car | null = null; //mainCai :Car = null; /** * * points是地图中3条,路径的3个起始点。 */ public resetCars(points: Node[]) { if (points.length <= 0) { console.log("没有point在map"); return; } //初始化小车 放到第1个路径的,起点点。 this._createMainCar(points[0]); } public controMoving(isRunnding = true) { if (isRunnding) { //这里能不能通过getComm调用。 this.mainCar?.startRunning(); }else{ this.mainCar?.stopRunning(); } } private _createMainCar(point: Node) { this.mainCar?.setEntry(point); } }
站长微信:xiaomao0055
站长QQ:14496453