// Learn cc.Class: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { highwayParent: { default: null, type: cc.Node, serializable: true, }, highwayPrefab: { default: null, type: cc.Node, serializable: true, }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start() { let _startPos = GlobalD.TiledMap._tilePosFromLocation(this.node.getPosition()); this.onSetHighway(_startPos, true, 4); }, //设置提示建筑的道路 onSetHighway(_startTiledtile, _isAxisX, _length) { for (let i = 0; i < _length; i++) { let highwayTemp = null; highwayTemp = cc.instantiate(this.highwayPrefab); //设置半透明 highwayTemp.opacity = 100; highwayTemp.active = true; highwayTemp.parent = this.highwayParent; let tiledTile = highwayTemp.addComponent('TiledTile'); if (_isAxisX) { tiledTile.x = _startTiledtile.x + i; tiledTile.y = _startTiledtile.y; } else { tiledTile.x = _startTiledtile.x; tiledTile.y = _startTiledtile.y + i; } //记录终点的坐标 if (i == _length - 1) { task.virtualShadowPosEnd = cc.v2(tiledTile.x, tiledTile.y); } } }, });