spawn_more_overlords Posted February 26, 2018 Share Posted February 26, 2018 Hey guys, im working on a 2D platformer with linear level structure. Between some levels i want to make a cutscene which consists of a background and a single sprite thats moving from left to right. Everything else like my HUD or character should disappear during that cutscene. In my case its just a plane thats flying through the screen. Once the plane has passed the next level should start. Can someone tell me whats the best way to achieve that. Thanks in advance! Link to comment Share on other sites More sharing options...
samme Posted February 26, 2018 Share Posted February 26, 2018 Use a separate state. Link to comment Share on other sites More sharing options...
spawn_more_overlords Posted February 26, 2018 Author Share Posted February 26, 2018 5 hours ago, samme said: Use a separate state. Is there an example code for this? Link to comment Share on other sites More sharing options...
samme Posted February 27, 2018 Share Posted February 27, 2018 It's not separate levels, but this should give you an idea of multiple states: You could call states like: Boot → Game(1) → Cut → Game(2) → Cut → Game(3) etc., passing in the level to Game. spawn_more_overlords 1 Link to comment Share on other sites More sharing options...
spawn_more_overlords Posted February 27, 2018 Author Share Posted February 27, 2018 Thank you, i think i understand how the states work. However i ran into another problem: In the example code, functions are generally written in this format: update: function update () In my current gamestate code which i mostly have from a tutorial, functions are written like this: PlayState.update= function () I dont know if these functions are working differently but when i go from menuState to my PlayState im running into several errors claiming variables cant be found/ are undefined. EDIT: fixed it now -> I forgot to parse some data from one state to another, the functions were working fine. Link to comment Share on other sites More sharing options...
Recommended Posts