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

Project1

 找回密码
 注册会员
搜索

脚本中,如何获取人物在屏幕中的相对位置

查看数: 2031 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2020-12-2 01:30

正文摘要:

萌新,做了一个追光的效果,如图。 做法是在scene_map上添加一个window,用sprite加载一张图片,作为window的背景,设置锚点到屏幕中心,不断缩放。 当人物走到地图边缘、离开屏幕中心时,图片也应该随之调整位 ...

回复

wangdm 发表于 2020-12-2 16:07:46
本帖最后由 wangdm 于 2020-12-2 16:09 编辑

左了。
根本不用考虑偏移量,直接指定sprite的坐标和玩家画面坐标相同就行了。

RUBY 代码复制
  1. Window_Spotlight.prototype.update = function () {
  2.     this._spotlightSprite.x = $gamePlayer.screenX();
  3.     this._spotlightSprite.y = $gamePlayer.screenY() - 18;
  4.  
  5.     if (this._canZoomOut) {
  6.         this._spotlightSprite.scale.x += 0.01;
  7.         this._spotlightSprite.scale.y += 0.01;
  8.         if (this._spotlightSprite.scale.x >= 1.5) {
  9.             this._canZoomOut = false;
  10.         }
  11.     } else {
  12.         this._spotlightSprite.scale.x -= 0.01;
  13.         this._spotlightSprite.scale.y -= 0.01;
  14.         if (this._spotlightSprite.scale.x <= 1) {
  15.             this._canZoomOut = true;
  16.         }
  17.     }
  18. };

点评

你不如直接把Sprite加到地图上,也好过先加到window,再放到地图的周转  发表于 2020-12-5 06:37

评分

参与人数 1+1 收起 理由
wabcmcc + 1 塞糖

查看全部评分

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

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

GMT+8, 2024-9-28 02:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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