Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I made a custom class to display character portrait in RPGMaker XP Here is the class :

class Poser
  attr_accessor :images

  def initialize 
    @images = Sprite.new
    @images.bitmap = RPG::Cache.picture('Character.png') #100x300
    @images.x = 540 #place it on the bottom right corner of the screen
    @images.y = 180
  end
end

Create an event on the map to create an instance as global variable, tada! image popped out. Ok nice. But Im not satisfied, Now I want it to have bobbing-head animation-like (just like when we breathe, sometimes bob our head up and down) so I added another method :

  def move(x,y)
    @images.x += x
    @images.y += y
  end

  def animate(x,y,step,delay)
    forward = true
    2.times {
      step.times {
        wait(delay)
        if forward
          move(x/step,y/step) 
        else
          move(-x/step,-y/step)
        end
      }
      wait(delay*3)
      forward = false
    }
  end

  def wait(time)
    while time > 0
      time -= 1
      Graphics.update
    end
  end

I called the method to run the animation and it works, so far so good, but the problem is, WHILE the portrait goes up and down, I cannot move my character until the animation is finished.

So that's it, I'm stuck in the loop block, what I want is to watch the portrait moving up and down while I walk around village, talk to npc, etc.

Anyone can solve my problem ? Or better solution ? Thanks in advance

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.