查看: 1439|回复: 2

[原创发布] 【抛砖引玉】地图格子光标

[复制链接]
梦石
0
星屑
6814
在线时间
461 小时
注册时间
2012-2-19
回帖
37
发表于 2024-2-20 22:51:38 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
b022d7876e6cf519864ae3a3c30fdf37.png
  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. }
复制代码

评分

参与人数 1赞 +1 收起 理由
Arrose + 1 精品文章

查看全部评分

梦石
0
星屑
3359
在线时间
786 小时
注册时间
2023-5-18
回帖
154
发表于 2024-2-21 11:13:11 | 显示全部楼层
支持,刚好要用到
B站:传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复

使用道具 举报

梦石
0
星屑
68
在线时间
17 小时
注册时间
2024-1-24
回帖
4
发表于 2024-6-18 20:49:14 | 显示全部楼层
非常有用!感谢楼主大大
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部