03-03-2008, 06:18 AM
Command Windows
Animated Text
by Selwyn
Animated Text
by Selwyn
INTRODUCTION
Selwyn @ RMXP.Org Sun Apr 09, 2006 Wrote:here's a little script someone requested from my game.
this script makes the text in command windows move to the right when it's selected. (see screenshot below)
paste the following code in a new section JUST UNDER Window_Command
SCREENSHOTS
SCRIPT
The Script
[code]#==============================================================================
# ? Window_Command
#----------------------------------------------------------------------------------------------------
# by Selwyn
# selwyn@rmxp.ch
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# ? initialize
#--------------------------------------------------------------------------
def initialize(width, commands)
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
@sprites = []
for i in 0...@item_max
@sprites[i] = Sprite.new
@sprites[i].x = self.x + 16
@sprites[i].y = self.y + 16 + 32 * i
@sprites[i].z = 100
@sprites[i].bitmap = Bitmap.new(self.width - 32, 32)
@sprites[i].bitmap.draw_text(4, 0, self.width - 32, 32, @commands[i])
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.index = 0
end
#--------------------------------------------------------------------------
# ? update
#--------------------------------------------------------------------------
def update
super
for i in 0...@sprites.size
sprite = @sprites[i]
x = i == @index ? self.x + 16 + 32 : self.x + 16
if sprite.x < x
n = (x - sprite.x) / 3
n = 1 if n == 0
sprite.x += n
elsif sprite.x > x
n = (sprite.x - x) / 3
n = 1 if n == 0
sprite.x -= n
end
end
end
#--------------------------------------------------------------------------
# ? x=(x)
#--------------------------------------------------------------------------
def x=(x)
super
return if @sprites == nil
for sprite in @sprites
sprite.x = self.x + 16
end
end
#--------------------------------------------------------------------------
# ? y=(y)
#--------------------------------------------------------------------------
def y=(y)
super
return if @sprites == nil
for i in 0...@sprites.size
@sprites[i].y = self.y + 16 + 32 * i
end
end
#--------------------------------------------------------------------------
# ? visible=(visible)
#--------------------------------------------------------------------------
def visible=(visible)
super
return if @sprites == nil
for sprite in @sprites
sprite.visible = visible
end
end
#--------------------------------------------------------------------------
# ? dispose
#--------------------------------------------------------------------------
def dispose
super
return if @sprites == nil
for sprite in @sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# ? draw_item
#--------------------------------------------------------------------------
def draw_item(index, color)
sprite = @sprites[index]
sprite.bitmap.clear
sprite.bitmap.font.color = color
sprite.bitmap.draw_text(4, 0, self.width - 32, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ? disable_item
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end[code]
# ? Window_Command
#----------------------------------------------------------------------------------------------------
# by Selwyn
# selwyn@rmxp.ch
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# ? initialize
#--------------------------------------------------------------------------
def initialize(width, commands)
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
@sprites = []
for i in 0...@item_max
@sprites[i] = Sprite.new
@sprites[i].x = self.x + 16
@sprites[i].y = self.y + 16 + 32 * i
@sprites[i].z = 100
@sprites[i].bitmap = Bitmap.new(self.width - 32, 32)
@sprites[i].bitmap.draw_text(4, 0, self.width - 32, 32, @commands[i])
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.index = 0
end
#--------------------------------------------------------------------------
# ? update
#--------------------------------------------------------------------------
def update
super
for i in 0...@sprites.size
sprite = @sprites[i]
x = i == @index ? self.x + 16 + 32 : self.x + 16
if sprite.x < x
n = (x - sprite.x) / 3
n = 1 if n == 0
sprite.x += n
elsif sprite.x > x
n = (sprite.x - x) / 3
n = 1 if n == 0
sprite.x -= n
end
end
end
#--------------------------------------------------------------------------
# ? x=(x)
#--------------------------------------------------------------------------
def x=(x)
super
return if @sprites == nil
for sprite in @sprites
sprite.x = self.x + 16
end
end
#--------------------------------------------------------------------------
# ? y=(y)
#--------------------------------------------------------------------------
def y=(y)
super
return if @sprites == nil
for i in 0...@sprites.size
@sprites[i].y = self.y + 16 + 32 * i
end
end
#--------------------------------------------------------------------------
# ? visible=(visible)
#--------------------------------------------------------------------------
def visible=(visible)
super
return if @sprites == nil
for sprite in @sprites
sprite.visible = visible
end
end
#--------------------------------------------------------------------------
# ? dispose
#--------------------------------------------------------------------------
def dispose
super
return if @sprites == nil
for sprite in @sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# ? draw_item
#--------------------------------------------------------------------------
def draw_item(index, color)
sprite = @sprites[index]
sprite.bitmap.clear
sprite.bitmap.font.color = color
sprite.bitmap.draw_text(4, 0, self.width - 32, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ? disable_item
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end[code]
NOTES
this works my cursor script.
TERMS AND CONDITIONS
give credit, enjoy!