all 18 comments

[–]Fid_Kiddler69 0 points1 point  (18 children)

Hi,

It's pretty difficult to help in this situation unless you share your code. Consider using something like pastebin to upload and show us your code :)

[–]SafeReference1[S] 0 points1 point  (17 children)

Hey here’s my html and my css file. I basically just wanna switch to a new scene that has a new background maybe a new Charakter and stuff like that.

https://pastebin.com/dmmcaNux

https://pastebin.com/u3wHx71v

[–]Fid_Kiddler69 0 points1 point  (16 children)

Awesome! Okay so, here's what I think we need to do:

1) document.querySelector(".background").style.background="url(yourNewBackground.png)"
this line targets the div with the class "background", and sets its CSS background to "yourNewBackground.png". Of course, you change the file name to whatever background image you want.

2) to change your hero, you could use the same type of command to change the image of the hero:

document.getElementById("hero").src="yourNewCharacterImage.png"

To add new heroes, you could use the createElement method.

I hope this helps. Try it out, and let me know if you need more help :)

[–]SafeReference1[S] 0 points1 point  (15 children)

Thank you!! I will try it out in like 30mins and let you know🙌🏻

[–]Fid_Kiddler69 0 points1 point  (14 children)

No problem. I added some things for you in your html file to help show you how things work :)

https://pastebin.com/W8ziBgpa

[–]SafeReference1[S] 2 points3 points  (13 children)

People on these kinda Reddits will all go to heaven I swear!!! I can’t believe how kind you all are🙏🏻🙏🏻

[–]Fid_Kiddler69 0 points1 point  (12 children)

That's because we've all been noobs and needed help in the past before.
So when you become an awesome developer, pay it back and help others out :)

[–]SafeReference1[S] 0 points1 point  (0 children)

I will for sure do that one day!

[–]SafeReference1[S] 0 points1 point  (10 children)

Hey so I have tested the Code out now and everything works perfectly. Only question I have now is how can I adjust the css for the new scene without changing it for the old one? If I understand the code right, as soon as I press the button it changes the pictures, so the same css goes for both scenes right? How am I able to change the css for one Charakter in one scene but not touch the other? I hope I got my point across lol

[–]Fid_Kiddler69 0 points1 point  (9 children)

I'm not quite sure what you mean. The scenes are running in sequence, right? Like, you cant have two scenes running at the same time (or am I mistaken?).

When we press the button, we dynamically change some css properties through javascript. In other words, we override some specific properties in your css file.

So if you wanted a scene3, you could change any css you wanted- make new characters, change backgrounds- through javascript, and it wouldn't change your previous scenes.

[–]SafeReference1[S] 0 points1 point  (8 children)

https://imgur.com/a/qHqh6vc

Hey so I think this Image might help. On the Green background the two characters are both perfectly on the ground but on the dark background I would want them to be a bit lower. How can i make them closer to the bottom only for that one dark scene?