looping title screen script. help needed please.

● ARCHIVED · READ-ONLY
Started by SpacedOddity 12 posts View original ↗
  1. After a very long morning trying to figure out how to do this on my own, I have finally given up and registered with your forum for some help. This is my first post, please be gentle.

    Ok, so what I have been working on is an animated title screen with a flashing "press start" that plays for 20 seconds or so before switching to a scrolling "high scores" table. I want this on a loop until player input button C, at which point it takes the player to Scene_Map and it starts the game. You know, like an old arcade game.

    What I have achieved so far:

    I have my animated title screen (labelled Scene_Intro not Scene_Title because the actual title menu comes later on) and a functioning scrolling high scores table (Scene_HighScores). I have written them so that they each wait and play their animations for a while before switching to the other. So I have my loop.

    My problem:

    I can not figure out how to break the loop on button C input. I'm sure their is a simple solution, but i'm very new to this scripting lark.

    Here is the script that creates the loop and animates the elements in the scene:

    def wait(duration) duration.times { Graphics.update } end def update super for i in 1..1000 update_object_animation update_object2_animation update_object3_animation @background.ox+=2 @clouds.ox+=1 wait(1) end SceneManager.goto(Scene_HighScores) endIt plays all animations for 1000 frames with a waiting time of 1 between each frame, and creates a loop with Scene_HighScores which has pretty much the same piece of script but with "SceneManager.goto(Scene_Intro)" instead.

    How do I get Input C to start the game?
  2. To check if the C key is pressed, use Input.trigger?:)C)
  3. Thanks for your help, but I've tried that. I added an "if Input.trigger?:)C)" line but it still didn't work. But to be honest, i'm not sure if how to correctly use it. I'm very new to scripting. Would I just add an "if" statement to the page? or would I need a "break if" somewhere?


    It seems to be ignoring all button input whether I add a "if Input.trigger?:)C)" or not. It seems to be prioritizing the "for i in 1..1000" over the button input. Any thoughts?
  4. break if Input.trigger?:)C)
  5. if i put "break if Input.trigger?:)C)" under "for i in 1..1000" it's still ignoring the input.
  6. what key have you set for :C ?


    That is defined in the configuration screen, and it is NOT automatically the same as C.
  7. C is configured to space or return.
  8. OK, so i'm going to post the whole page of script. If someone can tell me what's going wrong I will be their best friend forever. Sorry if its a bit sloppy. 
     

    Code:
    class Scene_Intro < Scene_Base  def start    super    SceneManager.clear    Graphics.freeze    create_background    create_animated_object    create_animated_object2    create_animated_object3    create_foreground  end  def transition_speed    return 20  end    def terminate    super    SceneManager.snapshot_for_background    dispose_background    dispose_animated_object    dispose_animated_object2    dispose_animated_object3    dispose_foreground  end    def create_background    @background=Plane.new    @background.bitmap=Cache.parallax("clouds")    @clouds=Plane.new    @clouds.bitmap=Cache.parallax("clouds2")    @logo=Plane.new    @logo.bitmap=Cache.picture("logo")  end    def create_animated_object      @object_index = 0      @object_animation_speed = 0      @object = Sprite.new      @object.z = 98      @object.opacity = 0      @object.blend_type = 1      @object.zoom_x = 0.3      @object.zoom_y = 0.3      @object_image = Cache.title2("Animated")      @object_frame_max = @object_image.width / @object_image.height      @object_width = @object_image.width / @object_frame_max        @object.bitmap = Bitmap.new(@object_width,@object_image.height)      @object.x = 120      @object.y = 87       make_object_bitmap    end          def create_animated_object2      @object2_index = 0      @object2_animation_speed = 0      @object2 = Sprite.new      @object2.z = 98      @object2.opacity = 0      @object2.blend_type = 1      @object2.zoom_x = 0.1      @object2.zoom_y = 0.1      @object2_image = Cache.title2("Animated")      @object2_frame_max = @object_image.width / @object_image.height      @object2_width = @object_image.width / @object_frame_max        @object2.bitmap = Bitmap.new(@object_width,@object_image.height)      @object2.x = 420      @object2.y = 117       make_object2_bitmap    end      def create_animated_object3      @object3_index = 0      @object3_animation_speed = 0      @object3 = Sprite.new      @object3.z = 98      @object3.blend_type = 0      @object3.zoom_x = 1      @object3.zoom_y = 1      @object3_image = Cache.title2("PressStart")      @object3_frame_max = @object_image.width / @object_image.height      @object3_width = @object_image.width / @object_frame_max        @object3.bitmap = Bitmap.new(@object_width,@object_image.height)      @object3.x = 180      @object3.y = 225      make_object3_bitmap end    def create_foreground    @foreground_sprite = Sprite.new    @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)    @foreground_sprite.z = 100    draw_game_title if $data_system.opt_draw_title  end  def draw_game_title    @foreground_sprite.bitmap.font.size = 48    rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2)    @foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1)  end  def dispose_background    @background.bitmap.dispose    @background.dispose    @clouds.bitmap.dispose    @clouds.dispose    @logo.bitmap.dispose    @logo.dispose  end    def dispose_animated_object    @object.bitmap.dispose    @object.dispose  end    def dispose_animated_object2    @object2.bitmap.dispose    @object2.dispose  end    def dispose_animated_object3    @object3.bitmap.dispose    @object3.dispose  end  def dispose_foreground    @foreground_sprite.bitmap.dispose    @foreground_sprite.dispose  end  def center_sprite(sprite)    sprite.ox = sprite.bitmap.width / 2    sprite.oy = sprite.bitmap.height / 2    sprite.x = Graphics.width / 2    sprite.y = Graphics.height / 2  end    def play    SceneManager.clear    Graphics.freeze    DataManager.setup_new_game    $game_map.autoplay    SceneManager.goto(Scene_Map)	end    def wait(duration)    duration.times { Graphics.update }  end    def update    super    if Input.trigger?(:C)      play    end    for i in 1..1000    update_object_animation    update_object2_animation    update_object3_animation    @background.ox+=2    @clouds.ox+=1    wait(1)    break if Input.trigger?(:C)    end    SceneManager.goto(Scene_HighScores)  end    def make_object_bitmap      @object.bitmap.clear      src_rect_back = Rect.new(@object_width * @object_index, 0,@object_width,@object_image.height)      @object.bitmap.blt(0,0, @object_image, src_rect_back)      end      def make_object2_bitmap      @object2.bitmap.clear      src_rect_back = Rect.new(@object2_width * @object2_index, 0,@object2_width,@object2_image.height)      @object2.bitmap.blt(0,0, @object2_image, src_rect_back)    end  def make_object3_bitmap      @object3.bitmap.clear      src_rect_back = Rect.new(@object3_width * @object3_index, 0,@object3_width,@object3_image.height)      @object3.bitmap.blt(0,0, @object3_image, src_rect_back)    end    def update_object_animation      @object.opacity += 2      @object_animation_speed += 1      if @object_animation_speed > 5         @object_animation_speed = 0         @object_index += 1         @object_index = 0 if @object_index >= @object_frame_max         make_object_bitmap       end     end    def update_object2_animation      @object2.opacity += 2      @object2_animation_speed += 1      if @object2_animation_speed > 3         @object2_animation_speed = 0         @object2_index += 1         @object2_index = 0 if @object2_index >= @object2_frame_max         make_object2_bitmap      end    end      def update_object3_animation      @object3_animation_speed += 1      if @object3_animation_speed > 5         @object3_animation_speed = 0         @object3_index += 1         @object3_index = 0 if @object3_index >= @object3_frame_max         make_object3_bitmap       end    endend
  9. what if instead of break you made a scene change?
  10. what do you mean by a scene change? Sorry, I'm pretty new to this. Something like this?

    if Input.trigger?:)C) SceneManager.goto(Scene_Map)endinstead of the "break if" statement? Because this doesn't work either. Its just not recognising any button press whilst its waiting for the animation time to pass.
  11. problem solved!! :guffaw:   It just needed an Input.update. I knew it would be something really simple.

    def play SceneManager.clear Graphics.freeze DataManager.setup_new_game $game_map.autoplay SceneManager.goto(Scene_Map) end def wait(duration) duration.times { Graphics.update } end def update super for i in 1..1000 update_object_animation update_object2_animation update_object3_animation @background.ox+=2 @clouds.ox+=1 wait(1) Input.update SceneManager.goto(Scene_HighScores) break if Input.trigger?:)C) end play endThanks for the help all the same guys.  :)
  12. I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.