Project1

标题: 如何让图片固定在地图的某个坐标上不随玩家移动 [打印本页]

作者: 天浩    时间: 2021-3-25 10:14
标题: 如何让图片固定在地图的某个坐标上不随玩家移动
本帖最后由 天浩 于 2021-3-25 12:12 编辑

如何让图片固定在地图的某个坐标上不随玩家移动

或者 能告诉我让图片跟随  玩家移动   的脚本语句在哪吗?


作者: Fan723    时间: 2021-3-25 10:38
图片做成行走图,用事件做,勿选站立动画,勾选固定方向。
作者: 白嫩白嫩的    时间: 2021-3-25 15:24
建议使用钻头大佬的多层背景插件,可固定在场景任何一层,也可做卷轴背景
作者: alexncf125    时间: 2021-3-25 15:46
本帖最后由 alexncf125 于 2021-3-25 15:54 编辑
如何让图片固定在地图的某个坐标上不随玩家移动

JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // TTK - Fix Picture (v1.0.0)
  3. // by Fogomax
  4. //=============================================================================
  5.  
  6.  
  7. /*:
  8.   * @author Fogomax
  9.   * @plugindesc This plugin fixes the images in the map
  10.   * <TTK FixPicture>
  11.   * @help
  12.     ===========================================================================
  13.     ● Explanation
  14.     ===========================================================================
  15.     This plugins fixes the image in the map and in the coordenates specifieds
  16.     in the event command, its not necessary the position be 0, 0. Because of
  17.     this feature, you still can use the Move Picture command with fixed
  18.     pictures.
  19.     ===========================================================================
  20.     ● Use
  21.     ===========================================================================
  22.     Just include the prefix in the image file name. Using the default Fix
  23.     Prefix, the image name would be "[FIX]Image.png".
  24.     @param Fix Prefix
  25.     @desc The prefix the image needs have to be fixed
  26.     @default [FIX]
  27.  */
  28.  
  29. var Imported = Imported || {};
  30. Imported["TTK_FixPicture"] = "1.0.0";
  31.  
  32. var TTK = TTK || {};
  33. TTK.FixPicture = {};
  34.  
  35. "use strict";
  36.  
  37. (function($) {
  38.         $.Params = $plugins.filter(function(p) { return p.description.contains('<TTK FixPicture>'); })[0].parameters;
  39.  
  40.         //-----------------------------------------------------------------------------
  41.         // Plugin global variables
  42.         //
  43.  
  44.         $.fixPrefix = $.Params["Fix Prefix"];
  45.  
  46.         //-----------------------------------------------------------------------------
  47.         // Sprite_Picture
  48.         //
  49.  
  50.         var _Sprite_Picture_updatePosition = Sprite_Picture.prototype.updatePosition;
  51.  
  52.         Sprite_Picture.prototype.updatePosition = function() {
  53.                 if (~this.picture().name().indexOf($.fixPrefix)) {
  54.                     var picture = this.picture();
  55.                     this.x = (-$gameMap.displayX() * 48) + picture.x();
  56.                     this.y = (-$gameMap.displayY() * 48) + picture.y();
  57.                 } else {
  58.                         _Sprite_Picture_updatePosition.call(this);
  59.                 }
  60.         };
  61. })(TTK.FixPicture);

ps. 没测试

让图片跟随  玩家移动   的脚本语句在哪

不知道
作者: yuna8922842    时间: 2024-1-15 15:19
请问这些语句怎么用啊?
作者: shiroin    时间: 2024-1-15 15:44
yuna8922842 发表于 2024-1-15 15:19
请问这些语句怎么用啊?

楼上发的是插件代码,你需要新建一个空白的.js文件,然后把代码全部黏贴进去保存并重命名为TTK_FixPicture.js制成插件
导入插件后,你只需要把需要固定坐标的图片追加[FIX]的前缀名就视为激活功能,没有脚本或插件指令
比如原本图片名是【我是一张图.png】,修改成【[FIX]我是一张图.png】后,游戏中显示该图片就会自动适配地图坐标,不会受地图滚动而影响,没有追加前缀名的图片则照旧只跟随镜头
作者: yuna8922842    时间: 2024-1-15 16:22
试了不行呀,哪里没弄对吗。。。
作者: shiroin    时间: 2024-1-15 17:02
yuna8922842 发表于 2024-1-15 16:22
试了不行呀,哪里没弄对吗。。。

我测试过插件可行,你是不是针对图片的XY轴设置没调好导致没看见?

this.x = (-$gameMap.displayX() * 48) + picture.x();
this.y = (-$gameMap.displayY() * 48) + picture.y();

受插件影响,图片每次位置刷新都会减去地图图块的尺寸,比如你做了一张40X20的地图
你的图片在显示设置时都需要为X轴修正上调40X48= 1920  Y轴修正上调40X48= 960


作者: yuna8922842    时间: 2024-1-15 20:49
shiroin 发表于 2024-1-15 17:02
我测试过插件可行,你是不是针对图片的XY轴设置没调好导致没看见?

this.x = (-$gameMap.displayX() *  ...

我测试了地图是60*40,在文件夹pictures下放置了 [FIX]风车叶.png 图片,我做了个事件,
执行内容:显示图片,编号1,图像名称 [FIX]风车叶
原点:中心
直接指定
X:3648
Y:3072
结果就是图片显示在右下角屏幕外面看不到了
在这之前我测试的XY轴没超地图界限,显示在屏幕中跟随主角移动而移动....
大佬确定这些语句不用填写任何内容直接做成js后缀放进插件里吗?插件里有两个参数也默认不修改吗?
作者: shiroin    时间: 2024-1-15 21:11
yuna8922842 发表于 2024-1-15 20:49
我测试了地图是60*40,在文件夹pictures下放置了 [FIX]风车叶.png 图片,我做了个事件,
执行内容:显示 ...

我把我的发给你,我是自己有测试过效果的,不需要再编辑什么,即插即用

TTK_FixPicture.zip

898 Bytes, 下载次数: 5


作者: yuna8922842    时间: 2024-1-15 21:20
shiroin 发表于 2024-1-15 21:11
我把我的发给你,我是自己有测试过效果的,不需要再编辑什么,即插即用 ...

感谢大佬,一测试就有效果。
奇怪的是你这个插件右边只有一个可设置的参数,我复制下来的代码做成js插件装上后有2个参数。。。

不过不想纠结这个了毕竟我是代码小白完全不懂,再次感谢大佬




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1