Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Picture delayed with RGSS!
Ganon77
post May 22 2012, 09:36 AM
Post #1



Group Icon

Group: Member
Posts: 3
Type: Event Designer
RM Skill: Intermediate




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!

This post has been edited by Ganon77: May 22 2012, 02:28 PM
Go to the top of the page
 
+Quote Post
   
brewmeister
post May 23 2012, 03:01 AM
Post #2


Paste above Main
Group Icon

Group: Revolutionary
Posts: 408
Type: Scripter
RM Skill: Skilled




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


__________________________
Go to the top of the page
 
+Quote Post
   
Ganon77
post May 23 2012, 04:55 AM
Post #3



Group Icon

Group: Member
Posts: 3
Type: Event Designer
RM Skill: Intermediate




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?

This post has been edited by Ganon77: May 23 2012, 04:57 AM
Go to the top of the page
 
+Quote Post
   
brewmeister
post May 24 2012, 03:13 AM
Post #4


Paste above Main
Group Icon

Group: Revolutionary
Posts: 408
Type: Scripter
RM Skill: Skilled




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.


__________________________
Go to the top of the page
 
+Quote Post
   
Ganon77
post May 24 2012, 08:28 AM
Post #5



Group Icon

Group: Member
Posts: 3
Type: Event Designer
RM Skill: Intermediate




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 post has been edited by Ganon77: May 24 2012, 04:53 PM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 12:51 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker