Created
September 25, 2020 11:14
-
-
Save elleonard/d1efacf5d934a9c9ac3ce61d8d100abc to your computer and use it in GitHub Desktop.
MVでマップ上に画像を表示するサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
const MINIMAP_X = 600; | |
const MINIMAP_Y = 30; | |
const MINIMAP_TOGGLE_KEY = 'pagedown'; | |
const _Scene_Map_updateScene = Scene_Map.prototype.updateScene; | |
Scene_Map.prototype.updateScene = function () { | |
_Scene_Map_updateScene.call(this); | |
if (!SceneManager.isSceneChanging()) { | |
this.updateToggleMinimap(); | |
} | |
}; | |
Scene_Map.prototype.updateToggleMinimap = function () { | |
if (Input.isTriggered(MINIMAP_TOGGLE_KEY)) { | |
this._spriteset.toggleMinimap(); | |
} | |
}; | |
class Sprite_Minimap extends Sprite_Base { | |
initialize() { | |
super.initialize(); | |
this.bitmap = ImageManager.loadBitmap('img/system/', 'minimap', 0, false); | |
} | |
} | |
const _Spriteset_Map_createUpperLayer = Spriteset_Map.prototype.createUpperLayer; | |
Spriteset_Map.prototype.createUpperLayer = function () { | |
_Spriteset_Map_createUpperLayer.call(this); | |
this.createMinimap(); | |
}; | |
Spriteset_Map.prototype.createMinimap = function () { | |
this._minimap = new Sprite_Minimap(); | |
this._minimap.move(MINIMAP_X, MINIMAP_Y); | |
this._baseSprite.addChild(this._minimap); | |
}; | |
Spriteset_Map.prototype.toggleMinimap = function () { | |
if (this._minimap.visible) { | |
this.hideMinimap(); | |
} else { | |
this.showMinimap(); | |
} | |
}; | |
Spriteset_Map.prototype.showMinimap = function () { | |
this._minimap.show(); | |
}; | |
Spriteset_Map.prototype.hideMinimap = function () { | |
this._minimap.hide(); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment