查看: 4441|回复: 4

[已经解决] 怎样变换角色行走图的读取路徑

[复制链接]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 2020-1-17 22:00:51 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 alexncf125 于 2024-1-25 01:45 编辑

我想有以下的效果(不止一个角色)
在数据库中,我已经把1号角色的行走图设成va格式的Graphics\Characters\$001.png
我想当Graphics\Characters\XP里有xp格式的$xp_001_0.png时
1号角色用的行走图换成$xp_001_0.png,并且把行走图缩放50%
如果没有则沿用va格式的Graphics\Characters\$001.png
点击展开/收起[pre lang="ruby"]#====================================== ========================================
# ** MSX - XP Characters on VX/VXAce
#================================================= =============================
# Author: Melosx
# Notes translated by ShinGamix
# http://www.rpgmakervxace.net/index.php?/user/1272-shingamix/
# Version: 1.0
# Compatible with VX and VXAce
#
#================================================= =============================
# * Description
# ------------------------------------------------- ----------------------------
# This script allows you to use xp in vx chara simply inserting the tag
# $ xp
# Before the name of the file.
# You can then use the normal VX / VXAce along with those of XP.
#
#================================================= =============================
# * Instructions
# ------------------------------------------------- ----------------------------
# Place the script under Materials and above Main. Add to chara of XP
# $ Xp before the tag name.
#
#================================================= =============================

#================================================= =============================
# ** Sprite_Character
#================================================= =============================

class Sprite_Character < Sprite_Base

def update_bitmap
   if @tile_id != @character.tile_id or
  @character_name != @character.character_name or
  @character_index != @character.character_index
  @tile_id = @character.tile_id
  @character_name = @character.character_name
  @character_index = @character.character_index
  if @tile_id > 0
    sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
    sy = @tile_id % 256 / 8 % 16 * 32;
    self.bitmap = tileset_bitmap(@tile_id)
    self.src_rect.set(sx, sy, 32, 32)
    self.ox = 16
    self.oy = 32
  else
    self.bitmap = Cache.character(@character_name)
    sign = @character_name[/^[!$]./]
    if sign != nil and sign.include?('$')
@cw = bitmap.width / 3
@ch = bitmap.height / 4
    else
@cw = bitmap.width / 12
@ch = bitmap.height / 8
    end
    if @character_name != nil and @character_name.include?('$xp')
@cw = bitmap.width / 4
@ch = bitmap.height / 4
    end
    self.ox = @cw / 2
    self.oy = @ch
  end
   end
end

def update_src_rect
   if @character_name != nil and @character_name.include?('$xp')
  if @tile_id == 0
    pattern = @character.pattern > 0 ? @character.pattern - 1 : 3
    sx = pattern * @cw
    sy = (@character.direction - 2) / 2 * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
   else
  if @tile_id == 0
    index = @character.character_index
    pattern = @character.pattern < 3 ? @character.pattern : 1
    sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
   end
end
end

#================================================= =========================
# ** Window_Base
#================================================= =========================

class Window_Base < Window

def draw_character(character_name, character_index, x, y)
   return if character_name == nil
   bitmap = Cache.character(character_name)
   sign = character_name[/^[!$]./]
   if character_name != nil and character_name.include?('$xp')
  cw = bitmap.width / 4
  ch = bitmap.height / 4
  n = character_index
  src_rect = Rect.new(0, 0, cw, ch)
   else
  if sign != nil and sign.include?('$')
    cw = bitmap.width / 3
    ch = bitmap.height / 4
  else
    cw = bitmap.width / 12
    ch = bitmap.height / 8
  end
  n = character_index
  src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
   end
   self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end

end[/pre]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2020-1-17 22:45:29 | 显示全部楼层
又或者,如何忽略数据库设定,
直接把1号角色的行走图换成Graphics\Characters\XP里xp格式的$xp_001_0.png
直接把23号角色的行走图换成Graphics\Characters\XP里xp格式的$xp_023_0.png
直接把456号角色的行走图换成Graphics\Characters\XP里xp格式的$xp_456_0.png
???

点评

并缩放50%  发表于 2020-1-17 22:46
回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2020-1-18 22:57:45 | 显示全部楼层
上面那些可以不回答了
只跪求
    if @character_name.size == 4
      self.bitmap = Cache.characterxp('$xp_' + @character_name + '_0')
    end
中@character_name是$001.png
怎樣去掉'$'變成$xp_001_0.png??
回复

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2020-1-18 23:33:11 | 显示全部楼层
唉,自己解決了,過了一整日,人都沒一個
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部