Thread: [Essentials Tutorial] How to add more features to the Pokégear
View Single Post
  #8    
Old August 30th, 2013 (11:14 PM). Edited August 30th, 2013 by linkthehero.
linkthehero's Avatar
linkthehero linkthehero is offline
     
    Join Date: Sep 2012
    Gender: Male
    Posts: 66
    sorry but i god some problems to fix it.please help me
    Quote:
    class PokegearButton < SpriteWrapper
    attr_reader :index
    attr_reader :name
    attr_accessor :selected

    def initialize(x,y,name="",index=0,viewport=nil)
    super(viewport)
    @index=index
    @name=name
    @selected=false
    fembutton=pbResolveBitmap(sprintf("Graphics/Pictures/pokegearButtonf"))
    if $Trainer.gender==1 && fembutton
    @button=AnimatedBitmap.new("Graphics/Pictures/pokegearButtonf")
    else
    @button=AnimatedBitmap.new("Graphics/Pictures/pokegearButton")
    end
    @contents=BitmapWrapper.new(@button.width,@button.height)
    [email protected]
    self.x=x
    self.y=y
    update
    end

    def dispose
    @button.dispose
    @contents.dispose
    super
    end

    def refresh
    self.bitmap.clear
    self.bitmap.blt(0,0,@button.bitmap,Rect.new(0,0,@button.width,@button.height))
    pbSetSystemFont(self.bitmap)
    textpos=[ # Name is written on both unselected and selected buttons
    [@name,self.bitmap.width/2,10,2,Color.new(248,248,248),Color.new(40,40,40)],
    [@name,self.bitmap.width/2,62,2,Color.new(248,248,248),Color.new(40,40,40)]
    ]
    pbDrawTextPositions(self.bitmap,textpos)
    icon=sprintf("Graphics/Pictures/pokegear"[email protected])
    imagepos=[ # Icon is put on both unselected and selected buttons
    [icon,18,10,0,0,-1,-1],
    [icon,18,62,0,0,-1,-1]
    ]
    pbDrawImagePositions(self.bitmap,imagepos)
    end

    def update
    if self.selected
    self.src_rect.set(0,self.bitmap.height/2,self.bitmap.width,self.bitmap.height/2)
    else
    self.src_rect.set(0,0,self.bitmap.width,self.bitmap.height/2)
    end
    refresh
    super
    end
    end



    #===============================================================================
    # - Scene_Pokegear
    #-------------------------------------------------------------------------------
    # Modified By Harshboy
    # Modified by Peter O.
    # Also Modified By OblivionMew
    # Overhauled by Maruno
    #===============================================================================
    class Scene_Pokegear
    #-----------------------------------------------------------------------------
    # initialize
    #-----------------------------------------------------------------------------
    def initialize(menu_index = 0)
    @menu_index = menu_index
    end
    #-----------------------------------------------------------------------------
    # main
    #-----------------------------------------------------------------------------
    def main
    commands=[]
    # OPTIONS - If you change these, you should also change update_command below.
    @cmdMap=-1
    @cmdPhone=-1
    @cmdJukebox=-1
    @cmdVoltorbFlip=-1
    commands[@cmdMap=commands.length]=_INTL("Map")
    commands[@cmdPhone=commands.length]=_INTL("Phone") if $PokemonGlobal.phoneNumbers &&
    $PokemonGlobal.phoneNumbers.length>0
    commands[@cmdJukebox=commands.length]=_INTL("Jukebox")
    commands[@cmdPension=commands.length]=_INTL("Pensionschecker") if pbGet(102)
    commands[@cmdVoltorbFlip=commands.length]=_INTL("VoltorbFlip")
    @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z=99999
    @button=AnimatedBitmap.new("Graphics/Pictures/pokegearButton")
    @sprites={}
    @sprites["background"] = IconSprite.new(0,0)
    femback=pbResolveBitmap(sprintf("Graphics/Pictures/pokegearbgf"))
    if $Trainer.gender==1 && femback
    @sprites["background"].setBitmap("Graphics/Pictures/pokegearbgf")
    else
    @sprites["background"].setBitmap("Graphics/Pictures/pokegearbg")
    end
    @sprites["command_window"] = Window_CommandPokemon.new(commands,160)
    @sprites["command_window"].index = @menu_index
    @sprites["command_window"].x = Graphics.width
    @sprites["command_window"].y = 0
    for i in 0...commands.length
    x=118
    y=196 - (commands.length*24) + (i*48)
    @sprites["button#{i}"]=PokegearButton.new(x,y,commands[i],i,@viewport)
    @sprites["button#{i}"].selected=([email protected]["command_window"].index)
    @sprites["button#{i}"].update
    end
    Graphics.transition
    loop do
    Graphics.update
    Input.update
    update
    if $scene != self
    break
    end
    end
    Graphics.freeze
    pbDisposeSpriteHash(@sprites)
    end
    #-----------------------------------------------------------------------------
    # update the scene
    #-----------------------------------------------------------------------------
    def update
    pbUpdateSpriteHash(@sprites)
    for i in 0...@sprites["command_window"].commands.length
    [email protected]["button#{i}"]
    sprite.selected=([email protected]["command_window"].index) ? true : false
    end
    #update command window and the info if it's active
    if @sprites["command_window"].active
    update_command
    return
    end
    end
    #-----------------------------------------------------------------------------
    # update the command window
    #-----------------------------------------------------------------------------
    def update_command
    if Input.trigger?(Input::B)
    pbPlayCancelSE()
    $scene = Scene_Map.new
    return
    end
    if Input.trigger?(Input::C)
    if @cmdMap>=0 && @sprites["command_window"].[email protected]
    pbPlayDecisionSE()
    pbFadeOutIn(99999) {
    scene=PokemonRegionMapScene.new
    screen=PokemonRegionMap.new(scene)
    screen.pbStartScreen
    }
    end
    if @cmdPhone>=0 && @sprites["command_window"].[email protected]
    pbPlayDecisionSE()
    pbFadeOutIn(99999) {
    PokemonPhoneScene.new.start
    }
    end
    if @cmdJukebox>=0 && @sprites["command_window"].[email protected]
    pbPlayDecisionSE()
    $scene = Scene_Jukebox.new
    end
    if @cmdPension>=0 && @sprites["command_window"].[email protected]
    pbPlayDecisionSE()
    pbFadeOutIn(99999) {
    scene=DayCareCheckerScene.new
    screen=DayCareChecker.new(scene)
    screen.startScreen
    }
    end
    if @cmdPension>=0 && @sprites["command_window"].[email protected]
    pbPlayDecisionSE()
    pbFadeOutIn(99999) {
    scene=pbVoltorbFlip.new
    screen=pbVoltorbFlip.new(scene)
    screen.pbStartScreen
    }
    end
    return
    end
    end
    end
    Reply With Quote