• 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.

Help with class AnimatedSprite

xalien95

Developer of Pokémon Omicron
76
Posts
13
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!
     

    Maruno

    Lead Dev of Pokémon Essentials
    5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    @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.
     

    xalien95

    Developer of Pokémon Omicron
    76
    Posts
    13
    Years
  • @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:

    Maruno

    Lead Dev of Pokémon Essentials
    5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    There are programming tutorials all over the Internets which can tell you what arrays are and how to use them.
     
    Back
    Top