| 赞 | 35 |
| VIP | |
| 好人卡 | |
| 积分 | 64 |
| 经验 | |
| 最后登录 | 2025-12-12 |
| 在线时间 | 1473 小时 |
- 梦石
- 0
- 星屑
- 6375
- 在线时间
- 1473 小时
- 注册时间
- 2015-7-25
- 回帖
- 609
 
|
发表于 2019-9-30 23:32:51
|
显示全部楼层
[pre lang="ruby"]#encoding:utf-8
#==============================================================================
# ■ NPC头顶上显示图片(动态版) by 魔法丶小肉包
#------------------------------------------------------------------------------
# 说明:在指定NPC头上显示图片(自定义图片)
#
# 使用方法:
# 事件-脚本 show_npc_icon 在本事件头上显示一次
# 事件-脚本 show_npc_icon(2) 在2号事件头上显示一次
# 如需一直显示,事件设定并行处理
#
# 素材名:SHOW 素材规格:256*32 分为8列,每一小格32*32(详细请参考心情图标的素材)
#------------------------------------------------------------------------------
# 更新日志:
# 2019.9.30 公开发布
#==============================================================================
class Sprite_Character < Sprite_Base
attr_accessor :character
def initialize(viewport, character = nil)
super(viewport)
@character = character
@balloon_duration = 0
@show_duration = 0
update
end
def dispose
end_animation
end_balloon
end_show
super
end
def update
super
update_bitmap
update_src_rect
update_position
update_other
update_balloon
update_show
setup_new_effect
end
def setup_new_effect
if !animation? && @character.animation_id > 0
animation = $data_animations[@character.animation_id]
start_animation(animation)
end
if !@balloon_sprite && @character.balloon_id > 0
@balloon_id = @character.balloon_id
start_balloon
end
if !@show_sprite && @character.show_id > 0
@show_id = @character.show_id
start_show
end
end
def start_show
dispose_show
@show_duration = 8 * show_speed + show_wait
@show_sprite = ::Sprite.new(viewport)
@show_sprite.bitmap = Cache.system("SHOW")
@show_sprite.ox = 16
@show_sprite.oy = 32
update_show
end
def dispose_show
if @show_sprite
@show_sprite.dispose
@show_sprite = nil
end
end
def update_show
if @show_duration > 0
@show_duration -= 1
if @show_duration > 0
@show_sprite.x = x
@show_sprite.y = y - height
@show_sprite.z = z + 200
sx = show_frame_index * 32
sy = (@show_id - 1) * 32
@show_sprite.src_rect.set(sx, sy, 32, 32)
else
end_show
end
end
end
def end_show
dispose_show
@character.show_id = 0
end
def show_speed
return 8
end
def show_wait
return 12
end
def show_frame_index
return 7 - [(@show_duration - show_wait) / show_speed, 0].max
end
end
class Game_CharacterBase
attr_accessor :show_id
alias minit_public_members init_public_members
def init_public_members
minit_public_members
@show_id = 0
end
end
class Game_Interpreter
def show_npc_icon(id = 0)
return unless get_character(id)
get_character(id).show_id = 1
end
end[/pre] |
评分
-
查看全部评分
|