じ☆ve冰风 发表于 2024-4-19 22:11:05

角色移动拖尾

提问区有人求这效果思路 于是乎实现了下 对Sprite_Character略做改动就行了#==============================================================================# ■ Sprite_Character#------------------------------------------------------------------------------#  角色显示用脚本。监视 Game_Character 类的实例、# 自动变化脚本状态。#==============================================================================class Sprite_Character < RPG::Sprite#--------------------------------------------------------------------------# ● 定义实例变量#--------------------------------------------------------------------------attr_accessor :character                # 角色#--------------------------------------------------------------------------# ● 初始化对像#   viewport: 查看端口#   character : 角色 (Game_Character)#--------------------------------------------------------------------------def initialize(viewport, character = nil)    super(viewport)    @character = character    #####################添加数组 计时器    @canyingarr = []    @Time =0    ####################    updateend#--------------------------------------------------------------------------# ● 更新画面#--------------------------------------------------------------------------def update    super      ######################################   if ?   for i in @canyingarr       i.opacity -=15####影响拖尾长度       @canyingarr.delete(i) if i.opacity= 384      self.bitmap = RPG::Cache.tile($game_map.tileset_name,          @tile_id, @character.character_hue)      self.src_rect.set(0, 0, 32, 32)      self.ox = 16      self.oy = 32      # 元件 ID 为无效值的情况下      else      self.bitmap = RPG::Cache.character(@character.character_name,          @character.character_hue)      @cw = bitmap.width / 4      @ch = bitmap.height / 4      self.ox = @cw / 2      self.oy = @ch      end    end    # 设置可视状态    self.visible = (not @character.transparent)    # 图形是角色的情况下    if @tile_id == 0      # 设置传送目标的矩形      sx = @character.pattern * @cw      sy = (@character.direction - 2) / 2 * @ch      self.src_rect.set(sx, sy, @cw, @ch)            #######################################      if @character.moving?&&@time ==0      a = Sprite.new(viewport)      a.bitmap = RPG::Cache.character(@character_name,@character_hue)      a.x = @character.screen_x      a.y = @character.screen_y      a.z = @character.screen_z(@ch)      a.ox = @cw / 2      a.oy = @ch      a.src_rect.set(sx, sy, @cw, @ch)      @canyingarr.push(a)      end      @time+=1      @time%=3###影响拖尾密度            ###########################################    end    # 设置脚本的坐标    self.x = @character.screen_x    self.y = @character.screen_y    self.z = @character.screen_z(@ch)    # 设置不透明度、合成方式、茂密    self.opacity = @character.opacity    self.blend_type = @character.blend_type    self.bush_depth = @character.bush_depth    # 动画    if @character.animation_id != 0      animation = $data_animations[@character.animation_id]      animation(animation, true)      @character.animation_id = 0    endendend复制代码
             本帖来自P1论坛作者yagami,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=347056若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页: [1]
查看完整版本: 角色移动拖尾