赞 | 31 |
VIP | 24 |
好人卡 | 0 |
积分 | 26 |
经验 | 16894 |
最后登录 | 2024-11-3 |
在线时间 | 419 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 2590
- 在线时间
- 419 小时
- 注册时间
- 2016-2-3
- 帖子
- 759
|
自己写的坐骑插件,不保证完全能用,可以试试看
- //=============================================================================
- // Zeros_RidingSystem.js
- //=============================================================================
- /*:
- * @plugindesc
- * @author 零殇
- *
- * @param v
- * @desc 版本
- * @default 1.0
- *
- * @help
- *
- * 上坐骑图片叫做Vehicle.png,放在img/characters下面,目前只适配角色大小和坐骑图大小一样的(标准)图片,否则会出现问题
- * 坐骑图片编号:图片第一行0 1 2 3,第二行4 5 6 7
- *
- * 使用方法:
- * 事件.setRidingCharacter('Vehicle',坐骑图片编号,玩家x偏移,玩家y偏移,玩家在坐骑上的高度);
- *
- * setRidingCharacterFront('Vehicle') //设置坐骑前景(如果有的话可以设置这张覆盖在角色上面的图片)
- *
- * 比如:
- * 上坐骑
- * $gamePlayer.setRidingCharacter('Vehicle',0,5,5,20);
- * 设置坐骑前景
- * $gamePlayer.setRidingCharacterFront('VehicleFrontz')
- * 下坐骑
- * $gamePlayer.clearRidingCharacter()
- */
- (function () {
- Game_CharacterBase.prototype.setRidingCharacter = function (characterName, idx, charaHeigh, charadx, charady) {
- this._ridingCharacterName = characterName;
- this._ridingCharacterIndex = idx | 0;
- this._charadx = charadx | 5;
- this._charady = charady | 5;
- this._charaHeight = charaHeigh | 20;
- SceneManager.goto(Scene_Map)
- };
- Game_CharacterBase.prototype.setRidingCharacterFront = function (characterName) {
- this._ridingCharacterNameFront = characterName;
- }
- // 检查角色是否骑坐骑
- Game_CharacterBase.prototype.isRiding = function () {
- return !!this._ridingCharacterName;
- };
- // 清除角色的坐骑行走图
- Game_CharacterBase.prototype.clearRidingCharacter = function () {
- this._ridingCharacterName = '';
- this._ridingCharacterNameFront = '';
- this._ridingCharacterIndex = 0;
- SceneManager.goto(Scene_Map)
- };
- // 覆盖Sprite_Character的_updateBitmap方法
- const _Sprite_Character_updateBitmap = Sprite_Character.prototype.updateBitmap;
- Sprite_Character.prototype.updateBitmap = function () {
- _Sprite_Character_updateBitmap.call(this);
- // 检查角色是否骑坐骑,如果是,则拼接角色和坐骑的行走图
- if (this._character.isRiding()) {
- const characterName = this._character.characterName();
- const ridingCharacterName = this._character._ridingCharacterName;
- const ridingCharacterNameFront = this._character._ridingCharacterNameFront;
- const characterIndex = this._character.characterIndex();
- const index = this._character._ridingCharacterIndex;
- const characterBitmap = ImageManager.loadCharacter(characterName);
- const ridingCharacterBitmap = ImageManager.loadCharacter(ridingCharacterName);
- const bitmapSize = characterBitmap.width / 12;
-
- let chax=this._character._charadx;
- let chay=this._character._charady;
- console.log(chax,chay)
- const combinedBitmap = new Bitmap(bitmapSize + chax * 2, bitmapSize * 2);
- let drx = (index % 4 * bitmapSize * 3 + this.characterPatternX() * bitmapSize)
- let dry = (Math.floor(index / 4) * bitmapSize * 4 + (this._character.direction() - 2) / 2 * bitmapSize)
- let dx = (characterIndex % 4 * bitmapSize * 3)
- let dy = (Math.floor(characterIndex / 4) * bitmapSize * 4 + (this._character.direction() - 2) / 2 * bitmapSize)
- let dirX = (this._character.direction() == 4 ? chax : 0) + (this._character.direction() == 6 ? -chax : 0);
- let dirY = (this._character.direction() == 8 ? chay : 0) + (this._character.direction() == 2 ? -chay : 0);
- combinedBitmap.blt(ridingCharacterBitmap, drx, dry, bitmapSize, bitmapSize, chax, bitmapSize);
- combinedBitmap.blt(characterBitmap, dx, dy, bitmapSize, bitmapSize, dirX + chax, dirY + bitmapSize - this._character._charaHeight);
- if(ridingCharacterNameFront){
- const ridingCharacterBitmapFront = ImageManager.loadCharacter(ridingCharacterNameFront);
- combinedBitmap.blt(ridingCharacterBitmapFront, drx, dry, bitmapSize, bitmapSize, chax, bitmapSize);
- }
- this.bitmap = combinedBitmap;
- }
- };
- Sprite_Character.prototype.updateCharacterFrame = function () {
- const pw = this.patternWidth();
- const ph = this.patternHeight();
- const sx = (this.characterBlockX() + this.characterPatternX()) * pw;
- const sy = (this.characterBlockY() + this.characterPatternY()) * ph;
- if (this._character.isRiding()) return;
- else this.setFrame(sx, sy, pw, ph);
- };
- })();
复制代码 |
|