开启5图层
This commit is contained in:
		
							parent
							
								
									811ba26731
								
							
						
					
					
						commit
						44848d881c
					
				| @ -350,159 +350,159 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = | |||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
|     "fiveLayers": function () { |     "fiveLayers": function () { | ||||||
| 		// 是否启用五图层(增加背景2层和前景2层) 将__enable置为true即会启用;启用后请保存后刷新编辑器
 | 	// 是否启用五图层(增加背景2层和前景2层) 将__enable置为true即会启用;启用后请保存后刷新编辑器
 | ||||||
| 		// 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层
 | 	// 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层
 | ||||||
| 		// 另外 请注意加入两个新图层 会让大地图的性能降低一些
 | 	// 另外 请注意加入两个新图层 会让大地图的性能降低一些
 | ||||||
| 		// 插件作者:ad
 | 	// 插件作者:ad
 | ||||||
| 		var __enable = false; | 	var __enable = true; | ||||||
| 		if (!__enable) return; | 	if (!__enable) return; | ||||||
| 
 | 
 | ||||||
| 		// 创建新图层
 | 	// 创建新图层
 | ||||||
| 		function createCanvas (name, zIndex) { | 	function createCanvas(name, zIndex) { | ||||||
| 			if (!name) return; | 		if (!name) return; | ||||||
| 			var canvas = document.createElement('canvas'); | 		var canvas = document.createElement('canvas'); | ||||||
| 			canvas.id = name; | 		canvas.id = name; | ||||||
| 			canvas.className = 'gameCanvas anti-aliasing'; | 		canvas.className = 'gameCanvas anti-aliasing'; | ||||||
| 			// 编辑器模式下设置zIndex会导致加入的图层覆盖优先级过高
 | 		// 编辑器模式下设置zIndex会导致加入的图层覆盖优先级过高
 | ||||||
| 			if (main.mode != "editor") canvas.style.zIndex = zIndex || 0; | 		if (main.mode != "editor") canvas.style.zIndex = zIndex || 0; | ||||||
| 			// 将图层插入进游戏内容
 | 		// 将图层插入进游戏内容
 | ||||||
| 			document.getElementById('gameDraw').appendChild(canvas); | 		document.getElementById('gameDraw').appendChild(canvas); | ||||||
| 			var ctx = canvas.getContext('2d'); | 		var ctx = canvas.getContext('2d'); | ||||||
| 			core.canvas[name] = ctx; | 		core.canvas[name] = ctx; | ||||||
| 			canvas.width = core._PX_ || core.__PIXELS__; | 		canvas.width = core._PX_ || core.__PIXELS__; | ||||||
| 			canvas.height = core._PY_ || core.__PIXELS__; | 		canvas.height = core._PY_ || core.__PIXELS__; | ||||||
| 			return canvas; | 		return canvas; | ||||||
| 		} | 	} | ||||||
| 
 | 
 | ||||||
| 		var bg2Canvas = createCanvas('bg2', 20); | 	var bg2Canvas = createCanvas('bg2', 20); | ||||||
| 		var fg2Canvas = createCanvas('fg2', 63); | 	var fg2Canvas = createCanvas('fg2', 63); | ||||||
| 		// 大地图适配
 | 	// 大地图适配
 | ||||||
| 		core.bigmap.canvas = ["bg2", "fg2", "bg", "event", "event2", "fg", "damage"]; | 	core.bigmap.canvas = ["bg2", "fg2", "bg", "event", "event2", "fg", "damage"]; | ||||||
| 		core.initStatus.bg2maps = {}; | 	core.initStatus.bg2maps = {}; | ||||||
| 		core.initStatus.fg2maps = {}; | 	core.initStatus.fg2maps = {}; | ||||||
| 
 | 
 | ||||||
| 		if (main.mode == 'editor') { | 	if (main.mode == 'editor') { | ||||||
| 			/*插入编辑器的图层 不做此步新增图层无法在编辑器显示*/ | 		/*插入编辑器的图层 不做此步新增图层无法在编辑器显示*/ | ||||||
| 			// 编辑器图层覆盖优先级 eui > efg > fg(前景层) > event2(48*32图块的事件层) > event(事件层) > bg(背景层)
 | 		// 编辑器图层覆盖优先级 eui > efg > fg(前景层) > event2(48*32图块的事件层) > event(事件层) > bg(背景层)
 | ||||||
| 			// 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
 | 		// 背景层2(bg2) 插入事件层(event)之前(即bg与event之间)
 | ||||||
| 			document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event')); | 		document.getElementById('mapEdit').insertBefore(bg2Canvas, document.getElementById('event')); | ||||||
| 			// 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后)
 | 		// 前景层2(fg2) 插入编辑器前景(efg)之前(即fg之后)
 | ||||||
| 			document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm')); | 		document.getElementById('mapEdit').insertBefore(fg2Canvas, document.getElementById('ebm')); | ||||||
| 			// 原本有三个图层 从4开始添加
 | 		// 原本有三个图层 从4开始添加
 | ||||||
| 			var num = 4; | 		var num = 4; | ||||||
| 			// 新增图层存入editor.dom中
 | 		// 新增图层存入editor.dom中
 | ||||||
| 			editor.dom.bg2c = core.canvas.bg2.canvas; | 		editor.dom.bg2c = core.canvas.bg2.canvas; | ||||||
| 			editor.dom.bg2Ctx = core.canvas.bg2; | 		editor.dom.bg2Ctx = core.canvas.bg2; | ||||||
| 			editor.dom.fg2c = core.canvas.fg2.canvas; | 		editor.dom.fg2c = core.canvas.fg2.canvas; | ||||||
| 			editor.dom.fg2Ctx = core.canvas.fg2; | 		editor.dom.fg2Ctx = core.canvas.fg2; | ||||||
| 			editor.dom.maps.push('bg2map', 'fg2map'); | 		editor.dom.maps.push('bg2map', 'fg2map'); | ||||||
| 			editor.dom.canvas.push('bg2', 'fg2'); | 		editor.dom.canvas.push('bg2', 'fg2'); | ||||||
| 
 | 
 | ||||||
| 			// 创建编辑器上的按钮
 | 		// 创建编辑器上的按钮
 | ||||||
| 			var createCanvasBtn = function (name) { | 		var createCanvasBtn = function (name) { | ||||||
| 				// 电脑端创建按钮
 | 			// 电脑端创建按钮
 | ||||||
| 				var input = document.createElement('input'); | 			var input = document.createElement('input'); | ||||||
| 				// layerMod4/layerMod5
 | 			// layerMod4/layerMod5
 | ||||||
| 				var id = 'layerMod' + num++; | 			var id = 'layerMod' + num++; | ||||||
| 				// bg2map/fg2map
 | 			// bg2map/fg2map
 | ||||||
| 				var value = name + 'map'; | 			var value = name + 'map'; | ||||||
| 				input.type = 'radio'; | 			input.type = 'radio'; | ||||||
| 				input.name = 'layerMod'; | 			input.name = 'layerMod'; | ||||||
| 				input.id = id; | 			input.id = id; | ||||||
| 				input.value = value; | 			input.value = value; | ||||||
| 				editor.dom[id] = input; | 			editor.dom[id] = input; | ||||||
| 				input.onchange = function () { | 			input.onchange = function () { | ||||||
| 					editor.uifunctions.setLayerMod(value); | 				editor.uifunctions.setLayerMod(value); | ||||||
| 				} |  | ||||||
| 				return input; |  | ||||||
| 			}; |  | ||||||
| 
 |  | ||||||
| 			var createCanvasBtn_mobile = function (name) { |  | ||||||
| 				// 手机端往选择列表中添加子选项
 |  | ||||||
| 				var input = document.createElement('option'); |  | ||||||
| 				var id = 'layerMod' + num++; |  | ||||||
| 				var value = name + 'map'; |  | ||||||
| 				input.name = 'layerMod'; |  | ||||||
| 				input.value = value; |  | ||||||
| 				editor.dom[id] = input; |  | ||||||
| 				return input; |  | ||||||
| 			}; |  | ||||||
| 			if (!editor.isMobile) { |  | ||||||
| 				var input = createCanvasBtn('bg2'); |  | ||||||
| 				var input2 = createCanvasBtn('fg2'); |  | ||||||
| 				// 获取事件层及其父节点
 |  | ||||||
| 				var child = document.getElementById('layerMod'), |  | ||||||
| 					parent = child.parentNode; |  | ||||||
| 				// 背景层2插入事件层前
 |  | ||||||
| 				parent.insertBefore(input, child); |  | ||||||
| 				// 不能直接更改背景层2的innerText 所以创建文本节点
 |  | ||||||
| 				var txt = document.createTextNode('bg2'); |  | ||||||
| 				// 插入事件层前(即新插入的背景层2前)
 |  | ||||||
| 				parent.insertBefore(txt, child); |  | ||||||
| 				// 向最后插入前景层2(即插入前景层后)
 |  | ||||||
| 				parent.appendChild(input2); |  | ||||||
| 				var txt2 = document.createTextNode('fg2'); |  | ||||||
| 				parent.appendChild(txt2); |  | ||||||
| 				parent.childNodes[2].replaceWith("bg"); |  | ||||||
| 				parent.childNodes[6].replaceWith("事件"); |  | ||||||
| 				parent.childNodes[8].replaceWith("fg"); |  | ||||||
| 			} else { |  | ||||||
| 				var input = createCanvasBtn_mobile('bg2'); |  | ||||||
| 				var input2 = createCanvasBtn_mobile('fg2'); |  | ||||||
| 				// 手机端因为是选项 所以可以直接改innerText
 |  | ||||||
| 				input.innerText = '背景层2'; |  | ||||||
| 				input2.innerText = '前景层2'; |  | ||||||
| 				var parent = document.getElementById('layerMod'); |  | ||||||
| 				parent.insertBefore(input, parent.children[1]); |  | ||||||
| 				parent.appendChild(input2); |  | ||||||
| 			} | 			} | ||||||
| 		} | 			return input; | ||||||
|  | 		}; | ||||||
| 
 | 
 | ||||||
| 		var _loadFloor_doNotCopy = core.maps._loadFloor_doNotCopy; | 		var createCanvasBtn_mobile = function (name) { | ||||||
| 		core.maps._loadFloor_doNotCopy = function () { | 			// 手机端往选择列表中添加子选项
 | ||||||
| 			return ["bg2map", "fg2map"].concat(_loadFloor_doNotCopy()); | 			var input = document.createElement('option'); | ||||||
|  | 			var id = 'layerMod' + num++; | ||||||
|  | 			var value = name + 'map'; | ||||||
|  | 			input.name = 'layerMod'; | ||||||
|  | 			input.value = value; | ||||||
|  | 			editor.dom[id] = input; | ||||||
|  | 			return input; | ||||||
|  | 		}; | ||||||
|  | 		if (!editor.isMobile) { | ||||||
|  | 			var input = createCanvasBtn('bg2'); | ||||||
|  | 			var input2 = createCanvasBtn('fg2'); | ||||||
|  | 			// 获取事件层及其父节点
 | ||||||
|  | 			var child = document.getElementById('layerMod'), | ||||||
|  | 				parent = child.parentNode; | ||||||
|  | 			// 背景层2插入事件层前
 | ||||||
|  | 			parent.insertBefore(input, child); | ||||||
|  | 			// 不能直接更改背景层2的innerText 所以创建文本节点
 | ||||||
|  | 			var txt = document.createTextNode('bg2'); | ||||||
|  | 			// 插入事件层前(即新插入的背景层2前)
 | ||||||
|  | 			parent.insertBefore(txt, child); | ||||||
|  | 			// 向最后插入前景层2(即插入前景层后)
 | ||||||
|  | 			parent.appendChild(input2); | ||||||
|  | 			var txt2 = document.createTextNode('fg2'); | ||||||
|  | 			parent.appendChild(txt2); | ||||||
|  | 			parent.childNodes[2].replaceWith("bg"); | ||||||
|  | 			parent.childNodes[6].replaceWith("事件"); | ||||||
|  | 			parent.childNodes[8].replaceWith("fg"); | ||||||
|  | 		} else { | ||||||
|  | 			var input = createCanvasBtn_mobile('bg2'); | ||||||
|  | 			var input2 = createCanvasBtn_mobile('fg2'); | ||||||
|  | 			// 手机端因为是选项 所以可以直接改innerText
 | ||||||
|  | 			input.innerText = '背景层2'; | ||||||
|  | 			input2.innerText = '前景层2'; | ||||||
|  | 			var parent = document.getElementById('layerMod'); | ||||||
|  | 			parent.insertBefore(input, parent.children[1]); | ||||||
|  | 			parent.appendChild(input2); | ||||||
| 		} | 		} | ||||||
| 		////// 绘制背景和前景层 //////
 | 	} | ||||||
| 		core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) { | 
 | ||||||
| 			config.ctx = cacheCtx; | 	var _loadFloor_doNotCopy = core.maps._loadFloor_doNotCopy; | ||||||
| 			core.maps._drawBg_drawBackground(floorId, config); | 	core.maps._loadFloor_doNotCopy = function () { | ||||||
| 			// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
 | 		return ["bg2map", "fg2map"].concat(_loadFloor_doNotCopy()); | ||||||
| 			core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap); | 	} | ||||||
| 			core.maps._drawBgFgMap(floorId, 'bg', config); | 	////// 绘制背景和前景层 //////
 | ||||||
| 			if (config.onMap) { | 	core.maps._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) { | ||||||
| 				core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | 		config.ctx = cacheCtx; | ||||||
| 				core.clearMap('bg2'); | 		core.maps._drawBg_drawBackground(floorId, config); | ||||||
| 				core.clearMap(cacheCtx); | 		// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
 | ||||||
| 			} | 		core.maps._drawFloorImages(floorId, config.ctx, 'bg', null, null, config.onMap); | ||||||
| 			core.maps._drawBgFgMap(floorId, 'bg2', config); | 		core.maps._drawBgFgMap(floorId, 'bg', config); | ||||||
| 			if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | 		if (config.onMap) { | ||||||
| 			config.ctx = toDrawCtx; | 			core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | ||||||
|  | 			core.clearMap('bg2'); | ||||||
|  | 			core.clearMap(cacheCtx); | ||||||
| 		} | 		} | ||||||
| 		core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) { | 		core.maps._drawBgFgMap(floorId, 'bg2', config); | ||||||
| 			config.ctx = cacheCtx; | 		if (config.onMap) core.drawImage('bg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | ||||||
| 			// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
 | 		config.ctx = toDrawCtx; | ||||||
| 			core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap); | 	} | ||||||
| 			core.maps._drawBgFgMap(floorId, 'fg', config); | 	core.maps._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) { | ||||||
| 			if (config.onMap) { | 		config.ctx = cacheCtx; | ||||||
| 				core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | 		// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
 | ||||||
| 				core.clearMap('fg2'); | 		core.maps._drawFloorImages(floorId, config.ctx, 'fg', null, null, config.onMap); | ||||||
| 				core.clearMap(cacheCtx); | 		core.maps._drawBgFgMap(floorId, 'fg', config); | ||||||
| 			} | 		if (config.onMap) { | ||||||
| 			core.maps._drawBgFgMap(floorId, 'fg2', config); | 			core.drawImage(toDrawCtx, cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | ||||||
| 			if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | 			core.clearMap('fg2'); | ||||||
| 			config.ctx = toDrawCtx; | 			core.clearMap(cacheCtx); | ||||||
| 		} | 		} | ||||||
| 		////// 移动判定 //////
 | 		core.maps._drawBgFgMap(floorId, 'fg2', config); | ||||||
| 		core.maps._generateMovableArray_arrays = function (floorId) { | 		if (config.onMap) core.drawImage('fg2', cacheCtx.canvas, core.bigmap.v2 ? -32 : 0, core.bigmap.v2 ? -32 : 0); | ||||||
| 			return { | 		config.ctx = toDrawCtx; | ||||||
| 				bgArray: this.getBgMapArray(floorId), | 	} | ||||||
| 				fgArray: this.getFgMapArray(floorId), | 	////// 移动判定 //////
 | ||||||
| 				eventArray: this.getMapArray(floorId), | 	core.maps._generateMovableArray_arrays = function (floorId) { | ||||||
| 				bg2Array: this._getBgFgMapArray('bg2', floorId), | 		return { | ||||||
| 				fg2Array: this._getBgFgMapArray('fg2', floorId) | 			bgArray: this.getBgMapArray(floorId), | ||||||
| 			}; | 			fgArray: this.getFgMapArray(floorId), | ||||||
| 		} | 			eventArray: this.getMapArray(floorId), | ||||||
| 	}, | 			bg2Array: this._getBgFgMapArray('bg2', floorId), | ||||||
|  | 			fg2Array: this._getBgFgMapArray('fg2', floorId) | ||||||
|  | 		}; | ||||||
|  | 	} | ||||||
|  | }, | ||||||
|     "itemShop": function () { |     "itemShop": function () { | ||||||
| 	// 道具商店相关的插件
 | 	// 道具商店相关的插件
 | ||||||
| 	// 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找)
 | 	// 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找)
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user