搜索附件  
同能RPG制作大师 附件中心 同能RM技术讨论区 RPG Maker MZ 讨论区 【抛砖引玉】地图格子光标: d1.png

【抛砖引玉】地图格子光标: d1.png

 

【抛砖引玉】地图格子光标:

JAVASCRIPT 代码
  1. const _Spriteset_Map_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;
  2. Spriteset_Map.prototype.createLowerLayer = function(){
  3.     _Spriteset_Map_createLowerLayer.call(this);
  4.     if(Utils.isNwjs()){
  5.         this.createCursor();
  6.     }
  7. }
  8. Spriteset_Map.prototype.createCursor = function(){
  9.     this._cursorSprite = new Sprite_Cursor();
  10.     this._cursorSprite.z = 2;
  11.     this._tilemap.addChild(this._cursorSprite);
  12. }
  13. class Sprite_Cursor extends Sprite {
  14.     initialize(){
  15.         super.initialize();
  16.         this.create();
  17.     }
  18.     create(){
  19.         const bitmap = new Bitmap(48, 48);
  20.         const c = "#B22222";
  21.         bitmap.fillRect(0, 0, 48, 48, c);
  22.         bitmap.clearRect(12, 0, 24, 48);
  23.         bitmap.clearRect(0, 12, 48, 24);
  24.         bitmap.clearRect(3, 3, 42, 42);
  25.         this.bitmap = bitmap;
  26.     }
  27.     update(){
  28.         super.update();
  29.         const mapX = $gameMap.canvasToMapX(TouchInput.x);
  30.         const mapY = $gameMap.canvasToMapY(TouchInput.y);
  31.         const sx = $gameMap.adjustX(mapX) * $gameMap.tileWidth();
  32.         const sy = $gameMap.adjustY(mapY) * $gameMap.tileHeight();
  33.         this.move(sx, sy);
  34.     }
  35. }
复制代码

            本帖来自P1论坛作者sundeshuo,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=495613  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
【抛砖引玉】地图格子光标: d1.png
关闭

幸运抽奖

社区每日抽奖来袭,快来试试你是欧皇还是非酋~

立即查看

Loading...

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2025-3-15 00:16 , Processed in 0.095987 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部