- Home /
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.
You can do it anyway you like. I prefer 1 level per scene as it makes organization a lot better and simpler for everyone.
Would this not add massive overhead to the final compiled exe / app?
yes, NOT GOOD ADVICE, especially for mobile, where the scene load time will be more noticeable. How having 100 scenes is simpler than 1, I will never know!
Answer by Seth-Bergman · Jan 10, 2013 at 11:17 AM
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
Hi Seth - no the tiles will not change they will stay where they are but each tile can be rotated by 90 degrees each click
Actually it will be same idea as this video robot repair but the sprites would rotate 90 degrees ins$$anonymous$$d of flip over. However, for each level i need the tiles in specific places. http://m.youtube.com/watch?v=6kt1j9hUs3g
O$$anonymous$$, well that's simple enough. Give me a bit, I'll change my answer to make it relevant
O$$anonymous$$, Answer Updated
Thanks for this Seth - I'm actually trying to make a clone of the game piperoll. You rotate pipes so that they connect together. Lets say my level grew to maybe 100 planes (i.e. pipes) would this cause a massive performance hit, should I be using cubes at this point? I read many planes = bad somewhere and to use quad with 3 triangle but I have no idea how to do that :-D
as for "quad with three tris", I guess you are referring to this issue:
http://answers.unity3d.com/questions/8699/planes-with-less-tris.html
I don't know how much difference it would make, but the idea I guess is just to create a lower-poly plane in your modelling software (such as Blender).
not sure if cubes would be much better..
3D modelling software is complicated, but creating a simple plane should be relatively do-able, if you decide to try (still tricky though) but if you can find someone who knows anything about it, they can bust you out one in about 5 seconds..
again, not sure how much difference it would make ..
(p.s. if my answer solves your question, be sure to accept it by clicking the check mark.. Thanks!)
Your answer
Follow this Question
Related Questions
2D Platformer: Using Tiled? 1 Answer
How to set tile from ScriptedTile script? 1 Answer
Level Chunk for infinte 2D runner 0 Answers
Level builder for iphone 3 Answers
Native iPhone Bluetooth Multiplayer? 1 Answer