+ 4

Please solve my query ?

I am making a 2d platformer game with javascript. I have made 2 different levels in different script files. I wanted to ask how i can change the level. In my game when the player touches the right end i want to change the background and obstacles. For the first page i have a script file. When the player teachers right end i have a different script file. Is there any way i can change background in level-2.if yes-how I fried to change the src attribute of script tag when player's x position reaches right end but it didnt work .Please tell a solution.

10th Oct 2020, 5:12 AM
Raghu Rao
Raghu Rao - avatar
3 odpowiedzi
+ 4
Well... Usually, you put all your scripts in one big file. If everything is in one file, then that would be so much easier. However, if it’s in two scripts, load both scripts but in the second script, put everything inside a function which can be called by the first script when the player touches the right side. Would you mind sharing your code? That would be super helpful. Thanks!
10th Oct 2020, 5:28 AM
Rowsej
Rowsej - avatar
+ 2
Thanks Rowsej I would surely share my code after finishing the game. But it's a pc screen size game so run the game on computer when I send
10th Oct 2020, 10:08 AM
Raghu Rao
Raghu Rao - avatar
+ 2
Raghu Rao That’s fine; send whenever you feel like it.
11th Oct 2020, 12:25 AM
Rowsej
Rowsej - avatar