just place things at “bigger-than-viewport” coordinates, fe:
local camera = display.newGroup() local tile = display.newImage(camera, "tile.png", 10000, 10000) -- you'd need to scroll a LOT before this comes on screen
just place things at “bigger-than-viewport” coordinates, fe:
local camera = display.newGroup() local tile = display.newImage(camera, "tile.png", 10000, 10000) -- you'd need to scroll a LOT before this comes on screen
Ok I see so you just give them x and y positions beyond the viewport. Makes sense. Now I see why so many people use a level editor since it’s hard for a human to really picture it all and design it otherwise. I’m glad I know the mechanics behind it all now.
You can build levels without using levels editors in Corona SDK.
Code for camera which follow character you can find in Sticker-Knight-Platformer in game.lua It uses ponytiled module for levels.
Post: Level module will be useful for you I think.
Good luck:)
Well yes I’ve seen that, that’s why I asked specifically about doing it without level editors. Is that really the only way to do it in Corona? Is that what everyone uses?
Also in your game.lua I can’t see how you’ve set the size of the camera? If you wanted to add camera shake too would that be possible?
It is one way doing this I know about. May be try Perspective Virtual Camera System.
You don’t set size of camera in game.lua. I think you can add shake effect usingponyfx.lua
Sticker Knight is based on using Tiled, a free tile map maker which provides a visual way to layout game levels. Corona, itself doesn’t have a visual layout tool and many people do not use a level editor.
You can create multiple background images that make a wide level and position them so they look seamless. There are size limits to images so you can’t really have a 10,000 pixel wide image. You can setup multiple backgrounds that when your camera moves, move at different speeds to create parallax if you want. Once you have that, its simply a matter of creating your various objects using the various display.* APIs and position them where you want. If you’re using physics, add the physics bodies to them, all through code.
Rob
Oh right, so where do you set it then? I assume you must set it otherwise how will it know what size to be?
Parallax scrolling is the next step from what I’m describing. What I mean is you have a level and instead of seeing the whole level at once, you have a camera, or viewport set up to show only a small part of the level. Not sure how the camera is set up and it’s size etc.
Since all the tutorials I’ve been through so far are indeed set up so that you can see the entire map on one screen because that suited the type of game they were. ie they’re just single screen games and you can’t go anywhere else.
The camera is a virtual concept. In the games I’ve made that use a camera concept, the whole screen is the viewport. You just move objects on or off screen as needed. Generally, this involves using a display.newGroup(), inserting your objects that you want to move around and then you move the whole group around and what comes on screen is in the camera view.
Rob
If you are comparing it to something like Unity, where you set the type of camera and either size/field of view, then there’s nothing like that in Corona - not built in anyway.
Corona’s screen is like a Unity UI Canvas set to Screen Space - Overlay. Basically objects are either within the ‘bounds’ of the screen and therefore the ‘camera’, or they aren’t.
If you wanted to zoom in Unity, you would change the size of the camera. In Corona, you would scale a group containing all of the objects so that more/less of them are visible on screen.
If you wanted to scroll the level right in Unity, you would move the camera right. In Corona, you would move the group containing all of the objects left.
Oh right I see, I didn’t realise that. So basically if the screen size is set to 320x480 in config.lua then if I make a level that is 1000x480 then by default it will be several times bigger than the camera?
in almost all programming environments (whether 2d or 3d) a “camera” is merely an abstraction (if even provided) - there really is no such thing as a camera, all that a “camera” represents is a transform between world coordinates and view coordinates, and you can easily make your own.
experiment:
take a sheet of 8.5"x11" paper and imagine that that is the extent of your world. hand-draw some tiles and little sprites around it, if it helps.
now take a 3"x5" index card and cut the middle out of it, leaving only a narrow frame around the edge, and imagine that that is the extent of your view (ie, imagine this as your phone, the cutout area is its screen)
now position the index card on top of the paper and slide it around - that’s what a “camera” does. (aside: in 2D, “viewport” is perhaps a better term than “camera” since there’s no perspective or etc)
but now, let’s get practical, for programming purposes: hold the index card fixed, because you can’t actually move the device with your code. so instead, move the paper underneath in the opposite direction to which you wish the “camera” to move. because what you can move is your world. it’ll have exactly the same visual effect, and that’s how “cameras” are actually implemented. (this is true even in 3D/OpenGL/Unity/etc, though the process is more ‘complicated’)
if it helps, simply name your master display group “camera”. now you can move your “camera” (just remember the opposite directions)
Hi. If you can take some time to read these questions and provide clear and concise answers, you’ll get better assistance:
I know this probably seems like I’m asking a lot, and that the answers may seem ‘obvious’, but they are not.
You’ve asked two big questions (level editing and cameras) in one thread. The concepts of levels and level design are specific to genres and games. There is no universal level design methodology that fits all game styles.
I am not clear you know what a camera is (in the mathematical and rendering sense), and while you really don’t need to know, it is helpful to have at least a high level understanding.
(Above statement not meant to be insult or condescending. The facts are: 1. Not everyone participating in the forums has a background in the fundamentals of rendering which is where you would learn about this concept in depth. 2. There is no agreed upon vocabulary for discussing them and this makes talking about topic difficult.)
I’m working on my own project today, but there is some relation to your questions. So, based on the response I see and my own schedule I’ll see if I can’t give some concrete answers when I know more about what you’re really looking for.
Till then, be aware that SSK2 has a camera module. You can see the code and assuming you understand basic Corona concepts like display groups, enterFrame listeners, and discrete and/or physics based movement you can figure it out.
(In my experience, cameras that track objects moved with transition.* do not work well.)
Finally, SSK2 has with a validation suite (tests), and includes four camera tests (SOURCE):
https://www.youtube.com/watch?v=_9ardhNwNRw&feature=youtu.be
That’s a really good explanation. I guess engines like Unity and Gamemaker Studio make it seem like it’s a real camera moving about. Having the background scroll in a scrolling shooter would seem obvious to program for me but to have it follow a player seems a bit more fiddly. But I guess it’s just always going in the opposite direction that the player is.
I don’t have an exact game in mind yet, I just want to make a relatively simple game albeit one that I can actually release to the iOS store. I’ll probably make a vertically scrolling space shooter of some sort.
Any simple vsseu really. Once I have the basic engine made I’ll work on it from there to make it something worthwhile.
A level loaded at once.
A camera following the player like in a simple platform game. Things like the slight delayed tracking and also camera shake would be interesting to learn about too.
I’m a lot clearer on everything after the explanations given here. It’s certainly a friendly and helpful community.
vsseu ? Typo or acronym I don’t know.
Roger that. Note A vertical scrolling space shooter does not use a ‘load at once’ level unless you scroll to the end and the level ends. Also, this would have to be a small level or you may find it lags during loading.
I’ve built a couple of scrolling shooters and I never once thought about a camera. I just have my backgrounds that I scroll at a certain speed. When I detect background1 is off screen I move it to the other side of background2 or 3 or 4 (depending on how many backgrounds). You have to use a repeating set of images to make this work. If I have parallax backgrounds, they will move the same way as the background just a little bit faster and use the same “detect when off screen and reposition” technique.
For game objects I create them just off screen then their move code moves them across the screen as needed.
Rob
@Rob - Yeah, that’s why I’m trying to tease out exactly the game the OP wants to make.
I see folks asking questions based on their assumptions regarding what they need, instead of simply asking,
“How do I make this game (or one like it) and where can I learn more about how it is made using Corona?”
i.e. The OP assumed that a camera is involved in making a shooter and depending on the shooter type, that may or may not be the case. :\
I gotta stop reading and answering the forums… but I found some possible leads for you on things to investigate for the purpose of learning:
There are a ton of these out there. I tried these google searches:
VSSEU = Vertical scrolling Shoot 'Em Up. :lol:
Yes I realise that, my question was also about general platform games. Just cameras generally. Not necessarily in regard to exactly the first game I will make now.
Thanks for all the replies. I’m clear now that the camera size basically equates to the screen size set in config.lua.