Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Wait, Flash, And Others.

Hello Ppl!, I'm here to ask some questions:

Question I: About Waiting

I need to know how to make the script wait before going into the next line.
I used to do this:
@wait = 50

def something

if @wait > 0
@wait -= 1
else
do_something
end

but this ended up being to long, and therefore couldn't be applied to some cases.

So...How can I wait some time before going into the next line?

Question II: Flashing Screen!

color = Color.new(255, 255, 255, 255)
duration = 100
$game_screen.start_flash(color, duration)
I'm trying to do this work for my script, but the screen simply won't flash, what am I doing wrong? BTW, it's on a loop.

More Question Coming Soon (;

-Fallen.
 

Atoa

Member

if it on XP you add these methods to the script:
Code:
  def update_basic

    Graphics.update

    Input.update

    $game_system.update

    $game_screen.update

    @spriteset.update if @spriteset != nil

    @message_window.update if @message_window != nil

  end

  def wait(duration)

    for i in 0...duration do update_basic end

  end

then add in the code the line "wait(x)" to wait x frames.

for the screen flashing, you need also to update the screen, try addind the wait command after the flash line.

I recommend to add this code to an scene, since i didn't test it on other classes.
 
For screen flash, you actually have to make sure that $game_screen.update is also being called every frame, so that the flash will actually show.

As to the wait method, what problems are you having. With a little creative scripting, nearly any case can use similar methods to what you posted, as long as the the wait count is being called in some kind of update method. (One that gets called every frame)

Oh, and for setting the number of frames to wait, you want to use this:

Code:
frames = seconds * Graphics.frame_rate

In that code, seconds is the number of seconds to wait, and Graphics.frame_rate is the target number of frames per second.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top