Help - Search - Members - Calendar
Full Version: Picture delayed with RGSS!
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Ganon77
Hi! I'm scratching my head, dealing with RGSS:

When I display a picture with the command:
@img.show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
(i don't use the method from Sprite_Picture, because the one from Game_Picture has more functionality, such as moving the picture.)

this picture appears only AFTER the completion of the next commands of the class ohmy.gif , whereas I want the opposite.
I even placed a loop as a wait command between them, that changes nothing!

For instance in this script, the text pops up FIRST then the picture shows up:

CODE
class Imgtest

def initialize
@wait = 100
@img = Game_Picture.new(1)
@img = $game_screen.pictures[1]
@img.show("Your_Picture", 0, 50, 200, 100, 100, 255, 0)
loop do
     @wait += 1
     Graphics.update
         if (@wait > 100)
            break
         end
  end  
print "hello world!"
end
end



So, has anyone an idea on how to solve that issue?

Thank you!
brewmeister
You need to update the sprite. The "show" method only queues up the picture to be displayed, the update method actually displays it.

CODE
class Scene_Map
  attr_accessor :spriteset
end

class Imgtest

  def initialize
    @wait = 100
    @img = Game_Picture.new(1)
    @img = $game_screen.pictures[1]
    @img.show("Your_Picture", 0, 50, 200, 100, 100, 255, 0)
    $scene.spriteset.update
    loop do
     @wait += 1
     Graphics.update
         if (@wait > 100)
            break
         end
    end  
    print "hello world!"
  end
end
Ganon77
Thank you,brewmeister!!
That works like hell! However, when I put the command to move the image ( @img.show(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type) )
a similar problem appears:
yes the picture now shows up first biggrin.gif , but my script moves it only at the end. mad.gif

So, I've tried to update the picture motion by pasting $scene.spriteset.update after it, but that doesn't work.

What should I do?
brewmeister
Make the "wait" longer?

As I said, the "show" method only tells the screen.update / spriteset.update to start the display or move.

Your "print" statement, however gets executed immediately.

What, exactly, do you plan to do in place of the "print" statement?
The problem may be using a print statement to determine when "after" occurs.
Ganon77
Erratum: I meant I wanted to move the image with @img.move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type) instead of @img.show(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)

Indeed, I've already increased the wait command. Unfortunately, doing so renders things even more strange:
which, upon testing, makes (in temporal order): Pic displayed => waiting => print statement => Pic moving huh.gif

In fact, I want to do a custom picture menu myself: with the current map as a background and a picture appearing by moving towards a definite position. So I've rewritten the Scene_Menu class. While testing, everything is OK except the fact that the picture moves only when I leave the menu. wacko.gif , hence i've taken the print command as a test for next commands.

Basically, my stuff is something like this:

CODE
class Scene_Menu

   attr_accessor :spriteset

   def main
  
  @spriteset = Spriteset_Map.new   # to display the current map as background
  @picture_n1 = Game_Picture.new
  show @picture_n1 (initial co-ordinates, initial size)
  @picture_n1 = $game_screen.pictures  
  move @picture_n1 (to new co-ordinates, new size, duration)
  #after movement completed=>
  loop do
      Graphics.update
      Input.update
      update
      if $scene != self
          break
      end  
  end
  Graphics.freeze
  dispose picture_n1
end


def update
  image_n1 update
  update_command
end


def update_command
   if Input.trigger?(Input::B)
        $scene = Scene_Map.new
        return
   end
end
end









================== E D I T ================================

After days of pondering on the scripts of RGSS classes, I've finally found the solution.
Obviously, the key thing is movement duration. In classic event commands, one could easily precise how long the movement lasts in number of frames.
Well... in RGSS language, this duration is a variable that may be found in Game_Picture class as @duration. What one must do is making the script check if the movement completion before executing to the next command, in other words checking if @image.duration = 0.

Problem: one cannot read this variable in this script, and RGSS returns an undefined method error.
So, going back to Game_Picture class, attr_reader :duration must be indicated at the beginning.

Consequently, the script for moving a picture might looks like this:


CODE
class Make_an_Image_Move
  
  attr_accessor :spriteset
  
def initialize
    
    @img = Game_Picture.new(1)
    @img = $game_screen.pictures[1]
    @img.show(name, origin, x, y, zoom_x, zoom_y, opacity, blender_type)
    $scene.spriteset.update
    
       @img.move(duration, origin, x, y, zoom_x, zoom_y, opacity, blender_type)

    loop do      # loop for checking the value of @img.duration, as long as it's > 0, the script keeps on updating the pic              
      $scene.spriteset.update
      @img.update
      Graphics.update
      if @img.duration == 0
         break
      end
     end
    
    $scene.spriteset.update
    @img.update
        #insert [i]wait command[/i] here#
       print "hello world!"
      
      end
end


Now, each command appears at the right time! wink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.