• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

How to "dispose" a sprite?

rigbycwts

Hmm, hmm.
98
Posts
11
Years
    • Seen Feb 22, 2019
    I was working on improving this tutorial to incorporate an image of a Gym Leader's badge at the start of a battle, similar to the Gen 6 games. At first it worked, like this:
    Spoiler:

    However, when the Pokemon are sent out, the badge image is still left on the screen instead of moving out with the sprite, like this:
    Spoiler:

    What I did is:
    First, I added a new function to PSystem_Utilities:
    Code:
    def pbTrainerBadgeFile(type)
      return nil if !type
      bitmapFileName=sprintf("Graphics/Characters/badge%s",getConstantName(PBTrainers,type)) rescue nil
      if !pbResolveBitmap(bitmapFileName)
        bitmapFileName=sprintf("Graphics/Characters/badge%03d",type)
      end
      return bitmapFileName
    end
    Then I modified setTrainerBitmap to utilise the badge image:
    Code:
    def setTrainerBitmap(file,hasbadge=false,badgefile=nil)
        unless badgefile.nil?
          @bitmap=AnimatedBitmapWrapper.new(badgefile,TRAINERSPRITESCALE)
          @[email protected]
          @badge.ox=(@bitmap.width/2) - 100
        end
        @bitmap=AnimatedBitmapWrapper.new(file,TRAINERSPRITESCALE)
        @[email protected]
        @[email protected]
        #@sprite.ox=(@bitmap.width/2) + 150
        if hasbadge
          @sprite.ox=(@bitmap.width/2) + 60
        else
          @sprite.ox=(@bitmap.width/2) + 150
        end
        if @doublebattle
          if @index==-2
            @sprite.ox-=150
          elsif @index==-1
            @sprite.ox+=150
          end
        end
        @[email protected]/4
        
        self.formatShadow
        @shadow.skew(74)
      end
    In the initialize function under the class DynamicTrainerSprite, I added the following line:
    Code:
    @badge=Sprite.new(@viewport)
    Inside EliteBattle_Scene, I replaced:
    Code:
    @sprites["trainer"].setTrainerBitmap(trainerfile)
    with this:
    Code:
    if @battle.opponent.trainertype > 58 && @battle.opponent.trainertype < 67
        @sprites["trainer"].setTrainerBitmap(trainerfile,true,pbTrainerBadgeFile(@battle.opponent.trainertype))
    else
        @sprites["trainer"].setTrainerBitmap(trainerfile)
    end
    And that's it. So, how do I "dispose" of the badge image when the Pokemon are sent out?
     
    Back
    Top