What I'm trying to do is allow the user to have an animated picture for the window cursor. Each cell in the animation will be its own pic. I actually have it mostly worked out, but the script doesn't wait long enough between cells.
Script update WIP
CODE
#------------------------------------------------------------------------------ # * Munkis' Picture-based window cursor V 1.1 # * Made by munkis # •”•••••••••••— # •‘ FEATURES •‘ # •š••••••••••• # * Replaces the default window cursor with a picture you create. Also centers # the text in the command windows (thanks to TheLawG14) # * ALIASES create_command_window, terminate, and update methods of Scene_Menu, # Scene_End, and Scene_Title. # OVERWRITES draw_item method of Window_Command. # * V 1.0: Initial release # * V 1.1: You can now use multiple cursor pics as individual animation cells #------------------------------------------------------------------------------
class Command_Window_Pic_Test < Window_Base def initialize(x,y,width,height) super(x,y,width,height) self.z = 0 self.opacity = 0 @anim_start = 0 # [config] @cursor_cells = ["MenuSelectCell01","MenuSelectCell02","MenuSelectCell03"] # @window_properties = [pic_name, window_x, window_y, window_width, # window_height, opacity in Scene_Menu, # opacity in Scene_end, opacity in Scene_Title] @window_properties = [187,125,175,235,0,0,255] # [/config] end def refresh(window_contents) self.contents.clear if @anim_start !=60 @anim_start +=1 @pick_cell = rand(2) elsif @anim_start == 60 @anim_start = 0 end bitmap = Cache.picture(@cursor_cells[@pick_cell]) if $scene.is_a?(Scene_Menu) self.opacity = @window_properties[4] rect = Rect.new(0, -(window_contents*WLH), @window_properties[2], @window_properties[3]) self.contents.blt(x-@window_properties[0], y-@window_properties[1], bitmap, rect) elsif $scene.is_a?(Scene_End) self.opacity = @window_properties[5] rect = Rect.new(0, -(window_contents*WLH), @window_properties[2], @window_properties[3]) self.contents.blt(x-@window_properties[0], y-@window_properties[1], bitmap, rect) elsif $scene.is_a?(Scene_Title) self.opacity = @window_properties[6] rect = Rect.new(0, -(window_contents*WLH), @window_properties[2], @window_properties[3]) self.contents.blt(x-@window_properties[0], y-@window_properties[1], bitmap, rect) end bitmap.dispose end end class Window_Command < Window_Selectable def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 if $scene.is_a?(Scene_Menu) or $scene.is_a?(Scene_End) or $scene.is_a?(Scene_Title) self.contents.draw_text(rect, @commands[index],1) else self.contents.draw_text(rect, @commands[index]) end end end class Window_Selectable < Window_Base alias update_picture_cursor update_cursor def update_cursor update_picture_cursor self.cursor_rect.empty if $scene.is_a?(Scene_Menu) or $scene.is_a?(Scene_End) or $scene.is_a?(Scene_Title) end end class Scene_Menu < Scene_Base alias picture_create_command_window_menu create_command_window alias picture_terminate_menu terminate alias picture_update_menu update def create_command_window picture_create_command_window_menu @command_window.opacity = 0 @pic_test = Command_Window_Pic_Test.new(@command_window.x-16,@command_window.y-17,@command_window.width+32,@command_window.height+6) end def terminate picture_terminate_menu @pic_test.dispose end def update picture_update_menu if @window_contents != @command_window.index @window_contents = @command_window.index end @pic_test.refresh(@window_contents) end end class Scene_End < Scene_Base alias picture_create_command_window_end create_command_window alias picture_terminate_end terminate alias picture_update_end update def create_command_window picture_create_command_window_end @command_window.opacity = 0 @pic_test = Command_Window_Pic_Test.new(@command_window.x-16,@command_window.y-34,@command_window.width+32,@command_window.height+6) end def terminate picture_terminate_end @pic_test.dispose end def update picture_update_end if @window_contents != @command_window.index @window_contents = @command_window.index end @pic_test.refresh(@window_contents) end end class Scene_Title < Scene_Base alias picture_create_command_window_title create_command_window alias picture_terminate_title terminate alias picture_update_title update def create_command_window picture_create_command_window_title @command_window.opacity = 0 @pic_test = Command_Window_Pic_Test.new(@command_window.x,@command_window.y,@command_window.width,@command_window.he ight) end def terminate picture_terminate_title @pic_test.dispose unless @command_window.nil? end def update picture_update_title unless @command_window.nil? if @window_contents != @command_window.index @window_contents = @command_window.index end @pic_test.refresh(@window_contents) end end end
EDIT: It changes cells once per frame; I want it to wait 30 frames (although the user will be able to change this value).
This post has been edited by munkis: Nov 10 2011, 09:54 AM
Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed
Can only give you some theoretical code; I'm not at my computer at the moment. You can combine the 3 images into one 'spritesheet' just use a sprite instead of a bitmap to display it; and then use src_rect to specify what's being displayed
What this does is itterate through the number of frames with any delay specified, so in terms of frame delay.. If you use 1 as the delay, and had 5 frames, Itd display like so: 0, 1, 2, 3, 4, 3... Down to 0 and back. 2 delay would be like: 0, 0, 1, 1.......
If I haven't lost you, hope that helps.
__________________________
Got 30 minutes? Then you've enough time to play this awesome game: - potentially promising project page - thanks holder
Now all I get are incredibly useless error messages that I apparently can't fix. The line the message indicates only has an end command, but adding or subtracting ends doesn't work, and I don't even understand why I'm getting the error in the first place.
Group: +Gold Member
Posts: 1,522
Type: Scripter
RM Skill: Undisclosed
Wow.... very theoretical Although that's a really cool algorithm for the index
I may have tinkered with the code slightly....
CODE
#------------------------------------------------------------------------------ # * Munkis' Picture-based window cursor V 1.1 # * Made by munkis # �•”�•��•��•��•��•��•��•��•��•��•��•— # �•‘ FEATURES �•‘ # �•š�•��•��•��•��•��•��•��•��•��•��•� # * Replaces the default window cursor with a picture you create. Also centers # the text in the command windows (thanks to TheLawG14) # * ALIASES create_command_window, terminate, and update methods of Scene_Menu, # Scene_End, and Scene_Title. # OVERWRITES draw_item method of Window_Command. # * V 1.0: Initial release # * V 1.1: You can now use multiple cursor pics as individual animation cells #------------------------------------------------------------------------------
class Game_System attr_accessor :cursor_speed alias initialize_picture initialize unless $@ def initialize(*args) @cursor_speed = 30 return initialize_picture(*args) end end
class Window_Selectable < Window_Base alias initialize_picture initialize unless $@ alias create_picture_contents create_contents unless $@ alias open_picture open unless $@ alias update_picture update unless $@ alias update_picture_cursor update_cursor unless $@ alias dispose_picture dispose unless $@ def initialize(*args) @active_time_count = 0 initialize_picture(*args) @cursor_sprite = Sprite.new(self.viewport) @cursor_sprite.bitmap = Bitmap.new(32, 32) end def create_contents(*args) @is_picture_scene = false if $scene.is_a?(Scene_Menu) or $scene.is_a?(Scene_End) or $scene.is_a?(Scene_Title) @is_picture_scene = true end text_offset = 16 if @is_picture_scene self.width -= text_offset * 2 end create_picture_contents(*args) if @is_picture_scene self.ox -= text_offset self.width += text_offset * 2 end end def open(*args) @cursor_sprite.opacity = 0 return open_picture(*args) end def update @cursor_sprite.opacity = self.openness == 255 ? self.opacity : 0 update_picture end def update_cursor if @is_picture_scene self.cursor_rect.empty @cursor_sprite.x = self.x + 16 @cursor_sprite.y = self.y + 14 @cursor_sprite.z = self.z + 1 ir = item_rect(@index) @cursor_sprite.oy = -(ir.y + (ir.height - @cursor_sprite.bitmap.height)/2) if @active_time_count == 0 @cursor_sprite.bitmap.dispose picture_name = "MenuSelectCell%02d" % (rand(3) + 1) @cursor_sprite.bitmap = Cache.picture(picture_name) end @active_time_count += 1 @active_time_count = 0 if @active_time_count == $game_system.cursor_speed else update_picture_cursor end end def dispose @cursor_sprite.bitmap.dispose @cursor_sprite.dispose dispose_picture end end
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.
Group: +Gold Member
Posts: 1,522
Type: Scripter
RM Skill: Undisclosed
I see what the problem is, sorry, I had it following the windows opacity, which you have as 0 in your scripts custom. I've updated the code in my last post so it now follows the opacity of the text's bitmap, which fixes it for me
__________________________
K.I.S.S. Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.