2D game level building best practice

Hey

I’m building a 2D game with multiple levels. Each level will be setup in a grid say 10x10. When I design the level each tile will be in the correct place, at runtime I will jumble them up. The objective is to click the tiles, they rotate back to their original position.

My question is… Do I need to create one level per scene and ‘place’ each tile visually when building the level or should I do it pragmatically once per scene. or just have one scene called ‘Game’ and load in sprite locations…

Just a bit lost, any help will be much appreciated.

Well, I am recently discovering that using just one single scene can be advantageous (as indicated here), as this requires no load time…

EDIT::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

deleted other stuff cuz it was not relevant

the link (or rather, the game from the link, since your link didn’t quite work) shows a memory-type game. When the card is clicked on, it is “flipped” to show what is on the other side. In this case, they are simply swapping the texture on that object for a different texture.

something like:

var backOfCard : Texture;
var frontOfCard : Texture;

objectInQuestion.renderer.material.mainTexture = frontOfCard;

(just a simple example)

For your main purpose however (rotating the image), it may be easier just to rotate the image itself… But you will not be able to use GUI Textures in this case… You would probably need to create planes to attach the image to, and rotate those instead.

This is pretty simple to set up, and should work fine for your needs. Getting back to your actual question, you can create a set of planes on first load, and from that point on, you are simply re-using the same planes each new “level” without ever needing to change scenes. Just swap out the new texture (this part would be similar to the swap code above), and set the new position, and you’d be good to go! If you have extra planes, you can simply set them aside (outside of the camera view) until you need them.

(the same method would apply to GUI Textures as well, but you would need to save out 4 versions of each image, since GUI Textures don’t rotate)

Hope this helps