【抛砖引玉】地图格子光标
JAVASCRIPT 代码
const _Spriteset_Map_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
Spriteset_Map.prototype.createLowerLayer = function(){
_Spriteset_Map_createLowerLayer.call(this);
if(Utils.isNwjs()){
this.createCursor();
}
}
Spriteset_Map.prototype.createCursor = function(){
this._cursorSprite = new Sprite_Cursor();
this._cursorSprite.z = 2;
this._tilemap.addChild(this._cursorSprite);
}
class Sprite_Cursor extends Sprite {
initialize(){
super.initialize();
this.create();
}
create(){
const bitmap = new Bitmap(48, 48);
const c = "#B22222";
bitmap.fillRect(0, 0, 48, 48, c);
bitmap.clearRect(12, 0, 24, 48);
bitmap.clearRect(0, 12, 48, 24);
bitmap.clearRect(3, 3, 42, 42);
this.bitmap = bitmap;
}
update(){
super.update();
const mapX = $gameMap.canvasToMapX(TouchInput.x);
const mapY = $gameMap.canvasToMapY(TouchInput.y);
const sx = $gameMap.adjustX(mapX) * $gameMap.tileWidth();
const sy = $gameMap.adjustY(mapY) * $gameMap.tileHeight();
this.move(sx, sy);
}
}
本帖来自P1论坛作者sundeshuo,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=495613若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页:
[1]