Faces Outside of Window

Discussion in 'RGSS3 Script Requests' started by HexMozart88, Jul 1, 2016.

  1. HexMozart88

    HexMozart88 The Master of Random Garbage Veteran

    Messages:
    1,574
    Likes Received:
    2,803
    Location:
    A small hut in the forest
    First Language:
    English
    Primarily Uses:
    RMVXA
    So, you know how in the menu the actors' faces are always directly lined up with their stats? Well, I've tried making it so that in any equip scene, it shows a window with the actor's name and I was hoping to make the face go just above that window, but what I've discovered is that there is some sort of barrier that makes it so that the face gets cut off if I move it too far in a direction. How do I get rid of this barriers so that the face is shown outside the window? (I hope I made that clear, and I hope this is in the right place.) 
     
    #1
  2. Sixth

    Sixth Veteran Veteran

    Messages:
    2,086
    Likes Received:
    756
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    The face is drawn on the window, therefore that one can NOT go outside the window's rect.


    You will most probably need to create a new sprite which shows the actor's face, position it, and use that instead of the one in the window.


    With the new sprite, you will also want to remove the old face image in the window, I guess.
     
    #2
  3. HexMozart88

    HexMozart88 The Master of Random Garbage Veteran

    Messages:
    1,574
    Likes Received:
    2,803
    Location:
    A small hut in the forest
    First Language:
    English
    Primarily Uses:
    RMVXA
    Aware that this is making me sound like a complete noob, how exactly do I do that? My scripting knowledge is mainly based on shrinking things and moving them around to make it look fancy, as well as deleting anything unnecessary. Don't know how to actually create sprites, I'm afraid. 
     
    #3
  4. Sixth

    Sixth Veteran Veteran

    Messages:
    2,086
    Likes Received:
    756
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    class Window_Base < Window

    def show_face(actor,x,y,z,opa=255)
    @faces = {} if @faces.nil?
    dispose_face(actor) if @faces[actor.id]
    @faces[actor.id] = Sprite.new
    @faces[actor.id].bitmap = Cache.face(actor.face_name).clone
    @faces[actor.id].x = x
    @faces[actor.id].y = y
    sx = actor.face_index % 4 * 96
    sy = actor.face_index / 4 * 96
    @faces[actor.id].src_rect = Rect.new(sx,sy,96,96)
    @faces[actor.id].z = z
    @faces[actor.id].opacity = opa
    end

    def dispose_face(actor)
    return unless @faces && @faces[actor.id]
    @faces[actor.id].bitmap.dispose
    @faces[actor.id].dispose
    @faces.delete(actor.id)
    end

    alias disp_faces8882 dispose
    def dispose
    @faces.each_value {|sp| sp.bitmap.dispose; sp.dispose } if @faces
    disp_faces8882
    end

    end

    class Window_EquipStatus < Window_Base

    alias disp_face8828 actor=
    def actor=(actor)
    @old_actor = @actor
    disp_face8828(actor)
    end

    alias add_face8827 refresh
    def refresh
    dispose_face(@old_actor) if @old_actor
    add_face8827
    show_face(@actor,0,0,200) if @actor
    end

    end



    That script above creates an actor face sprite on the equip menu. It is at a rather odd place, but you can change that at the last show_face line.


    The first number is the X position, the second is the Y position and the last one is the Z level of the sprite.


    You can add another, optional argument, which will be the opacity of the sprite.


    The method show_face I made will create a sprite with the face of the selected actor. The first argument for that method is an actor object. 


    The method dispose_face will dispose the face sprite of the selected actor if there is a face sprite for the actor. 


    Both methods can be called from any window class.


    All face images will be automatically disposed between scene changes, so you don't have to worry about that.


    But you must properly dispose these images when you no longer need them AND staying on the same scene, otherwise, you will most probably get undesired effects.


    Depending on where you want to show these images, you might need to adjust the methods I made or create your own method.


    For example, these sprites will never move, they will stay where they are, so you can't really use them in selectable windows where the window can be scrolled.
     
    #4
  5. HexMozart88

    HexMozart88 The Master of Random Garbage Veteran

    Messages:
    1,574
    Likes Received:
    2,803
    Location:
    A small hut in the forest
    First Language:
    English
    Primarily Uses:
    RMVXA
    Thank you so much, Sixth! It works great! You will definitely get a spot of honour in my credits for this  :)  


    Now, how do I get a moderator to close this?
     
    Last edited by a moderator: Jul 8, 2016
    #5

Share This Page