Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> 


———
Before you ask! Read! ;)

You must have 30+ Posts to create a topic here!

Thanks for reading!
———

 
Reply to this topicStart new topic
> [Help Request]Window_Player, A custom window I need some help with
Bigace
post Mar 16 2012, 07:41 PM
Post #1


The King of Spades
Group Icon

Group: Revolutionary
Posts: 400
Type: Developer
RM Skill: Intermediate




Okay in my CMS in Scene's Skill, Status, Equip, and Bio; I have a window that shows the characters faces like this



However it doesn't show up like that in the game, but instead like this:





CODE
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Window_Base
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_Base < Window
    def draw_actor_face(actor, x, y, type)
        begin
            case type
            when 0 then face = RPG::Cache.picture("face/" + actor.name + FACE_SMALL) rescue nil
            when 1 then face = RPG::Cache.picture("face/" + actor.name + FACE_GRAY) rescue nil
            when 2 then face = RPG::Cache.picture("face/" + actor.name + FACE_LARGE) rescue nil
            when 3 then face = RPG::Cache.picture("face/" + actor.name + FACE_MIDDLE) rescue nil
            end
            cw, ch = face.width, face.height
            self.contents.blt(x , y - ch, face, Rect.new(0, 0, cw, ch))
        rescue
        end  
    end  
end
#==============================================================================
# ■ Window_Player
#==============================================================================
class Window_Player < Window_Base
    def initialize(actor)
        super(342, -8, 258, 85)
        self.contents = Bitmap.new(width - 32, height - 32)
        self.opacity, self.z, @actor = 0, 150, actor
        refresh
    end
    def refresh
        self.contents.clear
        for i in 0...$game_party.actors.size
            actor = $game_party.actors[i]
            draw_actor_face(actor, i * 57, 50, 1)
            if actor.index == 0
                draw_actor_face(actor, 0, 50, 0)
            elsif actor.index == 1
                draw_actor_face(actor, 57, 50, 0)
            elsif actor.index == 2
                draw_actor_face(actor, 115, 50, 0)
            elsif actor.index == 3
                draw_actor_face(actor, 171, 50, 0)
            end
        end
    end
end


So whats supposed to happen with this window is when the player switches between characters, the character that the player is on will be colored in and the other 3 will be grayed out. Pretty much I need the second image to act like the first image. Hopfully this is enough info.


__________________________



Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

QUOTE ('Exiled One')
"If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others."
Go to the top of the page
 
+Quote Post
   
Moonpearl
post Mar 17 2012, 03:24 AM
Post #2


Level 5
Group Icon

Group: Member
Posts: 73
Type: Developer
RM Skill: Advanced




My best guess is that you don't call Window_Player#refresh each time the cursor changes position, however one canot say with only this part of the script. By the way, why not write your refresh method like this instead:
CODE
    def refresh
        self.contents.clear
        for i in 0...$game_party.actors.size
            actor = $game_party.actors[i]
            draw_actor_face(actor, i * 57, 50, actor.index == i ? 0 : 1)
        end
    end


__________________________





Go to the top of the page
 
+Quote Post
   
Bigace
post Mar 17 2012, 08:32 AM
Post #3


The King of Spades
Group Icon

Group: Revolutionary
Posts: 400
Type: Developer
RM Skill: Intermediate




Okay lol, I should of just post RMXPUnlimited. tongue.gif

Anyways, not much of the rest of the script I can post. Anything else would be in the scenes which would look like this:

CODE
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# ■ Window_Base
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
class Window_Base < Window
    def draw_actor_face(actor, x, y, type)
        begin
            case type
            when 0 then face = RPG::Cache.picture("face/" + actor.name + FACE_SMALL) rescue nil
            when 1 then face = RPG::Cache.picture("face/" + actor.name + FACE_GRAY) rescue nil
            when 2 then face = RPG::Cache.picture("face/" + actor.name + FACE_LARGE) rescue nil
            when 3 then face = RPG::Cache.picture("face/" + actor.name + FACE_MIDDLE) rescue nil
            end
            cw, ch = face.width, face.height
            self.contents.blt(x , y - ch, face, Rect.new(0, 0, cw, ch))
        rescue
        end  
    end  
end
#==============================================================================
# ■ Window_Player
#==============================================================================
class Window_Player < Window_Base
    def initialize(actor)
        super(342, -8, 258, 85)
        self.contents = Bitmap.new(width - 32, height - 32)
        self.opacity, self.z, @actor = 0, 150, actor
        refresh
    end
    def refresh
        self.contents.clear
        for i in 0...$game_party.actors.size
            actor = $game_party.actors[i]
            draw_actor_face(actor, i * 57, 50, 1)
            if actor.index == 0
                draw_actor_face(actor, 0, 50, 0)
            elsif actor.index == 1
                draw_actor_face(actor, 57, 50, 0)
            elsif actor.index == 2
                draw_actor_face(actor, 115, 50, 0)
            elsif actor.index == 3
                draw_actor_face(actor, 171, 50, 0)
            end
        end
    end
end
class Scene_Biography
    include ACE
    def initialize(actor_index = 0); @actor_index = actor_index; end
    def main
        @actor = $game_party.actors[@actor_index]
        @status_face, @biog_window = Window_Face.new(@actor), Window_Biography.new(@actor)
        @player_window = Window_Player.new(@actor)
        #[Background stuff]
        @windows = [@biog_window, @status_face, @mst_lay, @mst_back, @player_window]
        Graphics.transition(10, "Graphics/Transitions/004-Blind04")
        loop {Graphics.update; Input.update; update; break if $scene != self}
        Graphics.freeze
        @windows.each {|window| window.dispose}
    end
                    def update
                                         # [other stuff]
                    end
end




__________________________



Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

QUOTE ('Exiled One')
"If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others."
Go to the top of the page
 
+Quote Post
   
Moonpearl
post Mar 17 2012, 10:27 AM
Post #4


Level 5
Group Icon

Group: Member
Posts: 73
Type: Developer
RM Skill: Advanced




Well, as I said, I can't see your scene calling Window_Player#refresh anywhere. So what happend is that the only time your window executes its refresh method to draw the faces is when it is created (while the actor's index is probably not set yet, or not properly set), which makes all faces appear gray. Since you never refresh the window after that, it's only natural that its content does not change.


__________________________





Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 05:04 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker