• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Create sprites (in script)

  • 961
    Posts
    8
    Years
    • Age 22
    • Seen Nov 28, 2022
    I know most things about Ruby, but since Ruby is for text, sprites and things like that are what I'm struggling with.
    I was trying to create a new Pause menu, built off of this script: https://www.pokecommunity.com/showthread.php?t=344875
    I started off trying to create the sprites this way for the menu (Above Main):
    Code:
    class PokemonMenu_Scene
      def pbStartScene
        @MenuScene=1
        pbSetViableDexes
        @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
        @viewport.z=99999
        
        @sprites={}
        @sprites["slots"]=IconSprite.new(0,0,@viewport)
        @sprites["slots"].setBitmap("Graphics/Pictures/CustomMenu/slots")
    
        @sprites["panel1full"]=IconSprite.new(0,0,@viewport)
        @sprites["panel1full"].setBitmap("Graphics/Pictures/CustomMenu/panel1full")
      end
    end
    Is there anything already wrong here? This is giving me the following error:
    Code:
    Exception: NoMethodError
    
    Message: undefined method `viewport=' for nil:NilClass
    
    PScreen_PauseMenu:5:in `pbShowCommands'
    PScreen_PauseMenu:145:in `pbStartPokemonMenu'
    PScreen_PauseMenu:144:in `loop'
    PScreen_PauseMenu:270:in `pbStartPokemonMenu'
    Scene_Map:192:in `call_menu'
    Autosave:131:in `update'
    Scene_Map:67:in `main'
    Scene_Map:64:in `loop'
    Scene_Map:71:in `main'
    Main:49:in `mainFunctionDebug'

    The main question I'm having is this: How can I easily add a sprite which I can toggle visible=true or false? I'm trying to create a custom pause menu, but it's turning out to be incredibly difficult with all these errors. If someone who knows their code well, please hook me up or post below.
     
    Last edited by a moderator:
    That error you posted is not occuring within the code you posted. It's occuring within a method called pbShowCommands in the section PScreen_PauseMenu. Likely saying something along the lines of
    Code:
    something.viewport=somethingelse
    Likely because the something hasn't been initialized to a class that has a viewport
     
    Back
    Top