本帖最后由 r901042004 于 2016-5-16 14:13 编辑
rpg_core有以下function
TouchInput._onMouseMove = function(event) { if (this._mousePressed) { var x = Graphics.pageToCanvasX(event.pageX); var y = Graphics.pageToCanvasY(event.pageY); this._onMove(x, y); } };
TouchInput._onMouseMove = function(event) {
if (this._mousePressed) {
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
this._onMove(x, y);
}
};
左鍵點擊時會改變x y座標
所以我們只要改成
TouchInput._onMouseMove = function(event) { var x = Graphics.pageToCanvasX(event.pageX); var y = Graphics.pageToCanvasY(event.pageY); if (this._mousePressed) { this._onMove(x, y); } this.CanvasX = x; this.CanvasY = y; };
TouchInput._onMouseMove = function(event) {
var x = Graphics.pageToCanvasX(event.pageX);
var y = Graphics.pageToCanvasY(event.pageY);
if (this._mousePressed) {
this._onMove(x, y);
}
this.CanvasX = x;
this.CanvasY = y;
};
之後只要使用
TouchInput.CanvasX 或 TouchInput.CanvasY
即可調用座標(816*624的畫面座標)
要轉成Map上的絕對座標(事件X Y座標)可以用
var MapX = $gameMap.canvasToMapX(TouchInput.CanvasX); var MapY = $gameMap.canvasToMapY(TouchInput.CanvasY);
var MapX = $gameMap.canvasToMapX(TouchInput.CanvasX);
var MapY = $gameMap.canvasToMapY(TouchInput.CanvasY);
|