Split screen platformer WIP

bwwdbwwd Posts: 4Member


Im new to godot and im trying to setup basic mechanics for a platformer in split screen, so far its kinda ok but i have some questions , maybe others encountered these challenges.
Is it normal that audiostreamplayer plays on logo (that first image being shown when game starts) when i dont even have any scene for logo besides custom png , but i do have audiostreamplay for 1st stage, still i dont think it should play on logo, or is there some other way to play the music and not have it played on logo.
I guess it starts playing because it loads the scene when in titlescreen? Id like to disable this.
Also whats the good way to implement jumpland animation ? States ? Are there any examples of this ?
Thanks.

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 2,814Admin

    Welcome to the forums @bwwd!

    How is the AudioStreamPlayer setup? If the playing property is set to true in the scene file, I might instead try telling the AudioStreamPlayer to start playing in the _ready function of the titlescreen scene, as that way it should only start playing when the Titlescreen is loaded and added to the scene.

    Best of luck with your game!

  • bwwdbwwd Posts: 4Member
    edited July 27

    Its like this, on titlescreen but now i have timer to delay the music as temp fix ( i hate it tho) without that timer it plays music on splashscreen which is strange:

    extends Node
    
    func _ready():
    
        Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
        $MarginContainer/VBoxContainer/TextureButton.grab_focus()
        yield(get_tree().create_timer(0.5), "timeout")
        $Music.play()
    

    And i have first scene as intro.tsc , then video plays, no musicplay() in gd script, but that splash screen is even before that first video, so title screen is not even actuive yet but it plays music because of that $Music.play() command from titlescreen, its weird, i remove that play command and music doesnt play on splashscreen but it also wont play at all, its not on autoplay,is there any other way to make godot not play music just because it loaded future scene into memory? titlescreen scene with music is 2nd screne.
    I have intro.tsc then titlescreen.tsc and stage1.tsc. i have musicplay in titlescreen and stage1 but it plays the music before these scenes are onscreen.

    This is my intro, its the scene right after splashscreen

    func _ready():
        pass # Replace with function body.
        Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
    
    func _input(ev):
        if Input.is_key_pressed(KEY_SPACE):
            get_tree().change_scene("res://TitleScreen.tscn")
    
    func _on_VideoPlayer_finished():
        get_tree().change_scene("res://TitleScreen.tscn")
    
    
    
    func _on_TouchScreenButton_pressed():
            get_tree().change_scene("res://TitleScreen.tscn")
    
    func _unhandled_input(event):
        if event.is_action_pressed("fullscreen"):
            OS.window_fullscreen = !OS.window_fullscreen
    
  • TwistedTwiglegTwistedTwigleg Posts: 2,814Admin

    Hmm, strange. I don't know right off what would be causing the audio to play out of sync with the rest of the scene. Maye it's a bug? The _ready function shouldn't be called until the scene is loaded and instantiated into the game.

  • bwwdbwwd Posts: 4Member
    edited July 27

    I think i solved it, the thing was that i had Root node in root scene, and i instanced/linked 3 scenes to that root node (intro,title and stage1) this was loaded when splash screen showed up (i think) causing music toi play , so...
    I removed titlescreen linked scene and stage1 linked scene so they exist in resources but arent loaded into root scene, it look like its working , music doesnt play anymore .
    But this means i cant just go from root to stage1 by clicking on stage1 node from root scene, i have to open stage1 scene manually in file browser to edit it in godot.
    Is this how it should be ?
    So for example i cant have my main ROOT scene, where all my stages and start/gameover scenes are instanced/linked ?
    I have to keep every stage connected only by GScripts and use changescene ?
    Im still learning basics.I suspect thats the case .

  • MegalomaniakMegalomaniak Posts: 2,740Admin

    @TwistedTwigleg said:
    The _ready function shouldn't be called until the scene is loaded and instantiated into the game.

    IIRC _ready() is called when a node and all its dependencies(children and parent nodes for an example) are loaded in the scene/game. Something-something tree-entered or such is the signal called when the node itself is attached to the scene tree, that should happen before _ready() is called in case that comes in handy.

  • MegalomaniakMegalomaniak Posts: 2,740Admin
    edited July 27

    @bwwd said:
    So for example i cant have my main ROOT scene, where all my stages and start/gameover scenes are instanced/linked ?
    I have to keep every stage connected only by GScripts and use changescene ?

    Pretty much, yeah. Or don't have things such as audio start playing on scene load.

  • bwwdbwwd Posts: 4Member

    So how would i start bacgrkound music without having it on scene load ? Whats the syntax to play it only when scene is active and onscreen?

  • MegalomaniakMegalomaniak Posts: 2,740Admin

    I'd make a top level audio manager that would be outside the scenes and possibly always loaded as a singleton. have it queue music and sound effects according to need and context.

Sign In or Register to comment.