• 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!
  • Cyndy, May, Hero (Conquest), or Wes - 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.

Help with class AnimatedSprite

xalien95

Developer of Pokémon Omicron
  • 72
    Posts
    14
    Years
    Hello scripters, I'm copying the class AnimatedSprite (in SpriteWindow) to get an animation with a list of frames to be showed (like frame 0,1,2,1,0,3,4,3,etc...).
    I edited only the def update at the end of the class in this way:

    Code:
      def update
        super
        if @playing
          @realframes+=1
          if @realframes==@frameskip*1
            self.frame=0
          end
          if @realframes==@frameskip*2
            self.frame=1
          end
          if @realframes==@frameskip*3
            self.frame=2
          end
          if @realframes==@frameskip*4
            self.frame=1
          end
          if @realframes==@frameskip*5
            self.frame=0
          end
          if @realframes==@frameskip*6
            self.frame=3
          end
          if @realframes==@frameskip*7
            self.frame=4
          end
          if @realframes==@frameskip*8
            self.frame=3
          end
          if @realframes==@frameskip*9
            self.frame=0
          end
          if @realframes==@frameskip*41
            @realframes=0
          end
        end
      end

    What I'm missing? It doesn't show me the animation.
    Thanks in advance!
     
    @realframes is reset to 0 whenever you set self.frame to something. It never has a chance to get higher than @frameskip*1, because when it becomes equal to that, self.frame is set to something and @realframes is reset.

    You need another variable which takes the place of the original self.frame incrementing, and is itself incremented at that time. You can then use an array to decide which frame to use depending on the value of this variable.

    Alternatively, change your animation graphic so that you can use the default class AnimatedSprite for it.
     
    @realframes is reset to 0 whenever you set self.frame to something. It never has a chance to get higher than @frameskip*1, because when it becomes equal to that, self.frame is set to something and @realframes is reset.

    You need another variable which takes the place of the original self.frame incrementing, and is itself incremented at that time. You can then use an array to decide which frame to use depending on the value of this variable.

    Alternatively, change your animation graphic so that you can use the default class AnimatedSprite for it.
    Thank you for the quick reply!
    Could you code it for me? I would learn to use arrays in RPG Maker, if you code that, it will be helpful for me.
    If you wouldn't do it, no problem. Tell me and I'll fix the class without arrays.
    Thanks again!

    EDIT: I fixed the animation removing @realframes=0 from the frame attribute.
    Code:
      def frame=(value)
        @frame=value
        # @realframes=0
        self.src_rect.x=@frame%@framesperrow*@framewidth
        self.src_rect.y=@frame/@framesperrow*@frameheight
      end
    But I still would learn how to use arrays XD
     
    Last edited:
    Back
    Top