Character Anchors
2019.02.13
by Shaz
Introduction
This plugin allows you to adjust the position of a character's sprite by changing the X and/or Y anchors.
This would allow you, for example, to have a sprite that is larger than 48x48 centered both vertically and horizontally on the tile, extending below the bottom of the tile. Or to have an event that starts an NPC dialogue, with the NPC sprite several tiles away.
How to Use
Add to your plugin folder (name doesn't matter, but call it Shaz_CharacterAnchors.js in case there's ever an update that adds parameters).
Enable the plugin via the plugin manager.
Add anchor tags to an event using the event note box or using comments.
Background
By default, event sprites are anchored by the center horizontally (anchorX = 0.5) and the bottom vertically (anchorY = 1).
The anchor point is "attached" to the bottom middle of the tile.
This plugin allows you to set a different anchor point for the sprite, but it will still be attached to the bottom middle of the tile, so you'll need to experiment a bit to get it lined up correctly.
For example, if you set the X and Y anchors both to 0, the top left corner of the sprite would be aligned to the bottom center of the tile, so it would appear on the row below the event's location, half way over into the next tile to the right
Examples
Use one or both tags as needed.
Using event notes:
Code:
- <anchorX: 0.5><anchorY: 0.5>
复制代码
Code:
Code:
Using comments:
Code:
- Comment: <anchorX: 0.5><anchorY: 0.5>
复制代码
Code:
- Comment: <anchorX: 0.5>
- <anchorY: 0.5>
复制代码
Code:
- Comment: <anchorX: 0.5>
- Comment: <anchorY: 0.5>
复制代码
Script Calls
Where
id is the event's id, with no leading zeros:
Code:
- Script: $gameMap.event(id).setAnchorX(0.5)
复制代码
Code:
- Script: $gamePlayer.setAnchorX(0.5)
复制代码
Code:
- Script: $gamePlayer.followers()[0].setAnchorX(0.5)
复制代码
Or inside a move route that's applied to the player or an event:
Code:
- Script: this.setAnchorX(0.5)
复制代码
Notes
n can be a whole number or a floating point number.
0, 0 is the top left of the sprite.
1, 1 is the bottom right of the sprite.
n can be less than 0, or greater than 1 - the sprite can be on a completely different tile if you use larger negative or positive numbers.
Plugin
Get it here!
Credit
- Shaz
Terms
- free for use in commercial games
- do not post elsewhere - link back to this page
本贴来自国际rpgmaker官方论坛作者:Shaz处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/character-anchors.105599/