Lol you edited to include your own work which nullifies mine. :tongue: :lol:
Oh well. Its still important give it a read over.
Ok well have you started the scene at all. If not I'm going to think you are trying to weasel a request out of me :wink: But you did include the keyword "learn".
Alright where to start. First let's create our scene. So open up the script editor(F11) and insert an empty section above "Main". The scene itself is the most important class from a managerial perspective. He gets the input, the graphics and tells the objects that are contained within the scene to do work. The basic set up for a Scene is the following.
#==============================================================================
# ** Scene_Logo
#------------------------------------------------------------------------------
# This class performs logo screen processing
#==============================================================================
class Scene_Logo
#--------------------------------------------------------------------------
# * Constant Variables WE WILL NEED THESE LATER
#--------------------------------------------------------------------------
Time_Per_Move = 20
Moves = ['move_right', 'move_down', 'move_left', 'move_up']
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create resources.
Graphics.transition # Required to break the last Graphics.freeze
loop do # Main loop that will run until the Scene changes.
Graphics.update # Update the Graphics so we see dynamic elements redrawn.
Input.update # Poll the devices for changes in input.
update # Call our update
break if $scene != self # If the Scene has changed break the loop.
end
Graphics.freeze # Required to properly dispose of resources and lead into next transition.
# Dispose of allocated resources.
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
end
end
That is the bare bones for creating a scene. If you managed to get into this scene it would be an infinite loop of nothing but it would technically qualify as a scene. I guess the most important thing is providing the user some way of exiting this scene. So let's take a look at our update method. Right now nothing is inside of it. The most common way for exiting a Scene in game is through input. Let's make it so if the user presses the B or the C key the scene changes to Scene_Title. To find out what keys are pressed in this circumstance we will sue Input.trigger? which takes in the number representation of the key. So now our update method will look like this:
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
$scene = Scene_Title.new
end
end
Now if you run get into this scene you can at least exit it by pressing either the B or C button. Next you said you wanted an Image to be shown and this image will bounce around for a certain amount of frames. To show an image we need to use a sprite object. These little guys are responsible for all the 2D drawing you see when you run the game. We will create this sprite above our Graphics.transition within our main method of Scene_Logo. But its not just the sprite we need to initialize. We also need to actually load the image we want to show. We will initialize the sprite's bitmap to do this.
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create resources.
@sprite = Sprite.new
@sprite.x = 100
@sprite.y = 50
@sprite.bitmap = RPG::Cache.picture('picture_name_here')
Graphics.transition # Required to break the last Graphics.freeze
loop do # Main loop that will run until the Scene changes.
Graphics.update # Update the Graphics so we see dynamic elements
# redrawn.
Input.update # Poll the devices for changes in input.
update # Call our update
break if $scene != self # If the Scene has changed break the loop.
end
Graphics.freeze # Required to properly dispose of resources and lead
# into next transition.
# Dispose of allocated resources.
@sprite.bitmap.dispose
@sprite.dispose
end
After that you wanted to move the image around the screen. Let's implement those method you were talking about first. Using the array method I described. These methods can be placed right after the update method ends.
#--------------------------------------------------------------------------
# * Move Sprite Right
#--------------------------------------------------------------------------
def move_right
@sprite.x += 1
end
#--------------------------------------------------------------------------
# * Move Sprite Down
#--------------------------------------------------------------------------
def move_down
@sprite.y += 1
end
#--------------------------------------------------------------------------
# * Move Sprite Left
#--------------------------------------------------------------------------
def move_left
@sprite.x -= 1
end
#--------------------------------------------------------------------------
# * Move Sprite Up
#--------------------------------------------------------------------------
def move_up
@sprite.y -= 1
end
Now quickly back to main just below our sprite object creation. We will need to create two more additional variables. One variable will contain the index of the method we are currently calling. If for example the second item in our array of methods was "move_down" and the index variable was set to 1 we would be calling the "move_down" method. The second variable will represent the time till we need to increment or change the index. Let's say that when this variable reaches 20 we change the index.
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create resources.
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture('picture_name_here')
@index = 0
@time = 0
Graphics.transition # Required to break the last Graphics.freeze
loop do # Main loop that will run until the Scene changes.
Graphics.update # Update the Graphics so we see dynamic elements
# redrawn.
Input.update # Poll the devices for changes in input.
update # Call our update
break if $scene != self # If the Scene has changed break the loop.
end
Graphics.freeze # Required to properly dispose of resources and lead
# into next transition.
# Dispose of allocated resources.
@sprite.bitmap.dispose
@sprite.dispose
end
Lastly before we can leave Scene_Logo we need to update to update our timer, change the index when necessary and call the move method. First we will increment the time than if the time equals or exceeds the value we defined elsewhere. We reset the timer and increment the index. If the index equals the size of the array we will have an invalid index so we reset it to zero. Last but not least we call the proper move method in the manner described before.
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
$scene = Scene_Title.new
end
@time += 1
if @time >= Time_Per_Move
@time = 0
@index += 1
@index = 0 if @index == Moves.size
end
eval(Moves[@index])
end
Sadly even with all that work we still aren't done. The last change is making sure Scene_Logo is started in place of Scene_Menu. To do this open up the Main portion and change line 11 from:
to:
I hope I explained everything properly if you have any questions just let me know.
Good luck with it Khoa! :thumb: