设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 233|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3807
在线时间
369 小时
注册时间
2012-2-19
帖子
47
跳转到指定楼层
1
发表于 2024-2-20 22:51:38 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x

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.  
  9. Spriteset_Map.prototype.createCursor = function () {
  10.     this._cursorSprite = new Sprite_Cursor();
  11.     this._cursorSprite.z = 2;
  12.     this._tilemap.addChild(this._cursorSprite);
  13. }
  14.  
  15. class Sprite_Cursor extends Sprite {
  16.     initialize() {
  17.         super.initialize();
  18.         this.create();
  19.     }
  20.  
  21.     create() {
  22.         const bitmap = new Bitmap(48, 48);
  23.         const c = "#B22222";
  24.         bitmap.fillRect(0, 0, 48, 48, c);
  25.         bitmap.clearRect(12, 0, 24, 48);
  26.         bitmap.clearRect(0, 12, 48, 24);
  27.         bitmap.clearRect(3, 3, 42, 42);
  28.         this.bitmap = bitmap;
  29.     }
  30.  
  31.     update() {
  32.         super.update();
  33.         const mapX = $gameMap.canvasToMapX(TouchInput.x);
  34.         const mapY = $gameMap.canvasToMapY(TouchInput.y);
  35.         const sx = $gameMap.adjustX(mapX) * $gameMap.tileWidth();
  36.         const sy = $gameMap.adjustY(mapY) * $gameMap.tileHeight();
  37.         this.move(sx, sy);
  38.     }
  39. }

评分

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

查看全部评分

Lv3.寻梦者

梦石
0
星屑
1026
在线时间
202 小时
注册时间
2023-5-18
帖子
104
2
发表于 2024-2-21 11:13:11 | 只看该作者
支持,刚好要用到
我的B站传送门
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 01:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表