Tiled Map Engine

I have simple side scrolling game setup. The camera follows the player. This centers the camera on the player. Is it possible to set an offset to position the camera view in front of the player? 

I didn’t see this in the docs, so I’m assuming it’s not a feature (yet…). I’m thinking of two systems to implement this. 

a) create a dummy object that always sits in front of the player object. I was thinking of using an empty group, and setting it’s position on enterframe

b) Modify Ceramic. I figure I’d add two variables for offset_x, and y. Change the signature of setCameraFocus to setCameraFocus(f, ox, oy). Set some default values of 0 here. The tricky part is modifying view.updateCamera(). From what’s there I’m guessing I can just add the offset to targetX and targetY at the end. Something like:

map.viewX=targetX+offset_x

map.viewY=targetY+offset_y

I probably could have tried this in the time it took me to write this post… Let me get back to you…

If it’s alright with you, I’m going to hurry up and finish Dusk, then all these questions can be asked and answered consistently (such as “do this”, rather than “with Ceramic, do this, but when Dusk comes, do this”). With Dusk, camera offsets work, “getting” a tile from an XY position works, etcetera, so if you can hang in there until I publish Dusk (not long now!), I can answer these for sure. That way, you won’t have to edit the library yourself :slight_smile:

In the meantime, (also for everyone else), check out the Dusk documentation (work in progress) here, to get a feel for the way Dusk works.

  • Caleb

Wow great, I can’t wait! Don’t feel you have to answer all of my questions, I’m just thinking out loud on the  forum. I understand you guys are working on the next version and the current version is sort of a beta that will be replaced. 

I teach a class on Corona and mobile app design, and was making some examples, and looking for ideas to show my students. 

Where is the dusk beta Caleb?

Ok… The big day is coming up. The release is scheduled for this weekend (unless something unexpected happens). This release will be the public beta; feel free to pitch in with bug reports :). All that’s left right now is the final look-over and wrapping up for release.

Wish me luck :slight_smile:

  • Caleb

Been a lurker for a while, and I’m excited to see your hard work!

Woo hoo! Can’t wait. Thanks again! 

If you want to be a part of the beta testers, send me a PM and I’ll get you a copy when I get everything together.

  • From earlier

A number of people PM’d me, and I gave them access to it for testing.

If you’d like to join the testers, I’ll send you a copy - just say :).

  • Caleb

I’m replacing lime with Dusk in my android game Olethros and it is very impressive so far.
I hope version 1.9 will be Dusk Powered :smiley:
Good job guys!!

As a Christmas surprise, I’ve decided to release it early, namely…

Right now.

It’s live on GitHub at the normal repository, so give it a go.

@no2games:

The repository name and the description haven’t been changed yet, because I don’t have the permissions necessary to change it. If you would, kindly change it :slight_smile:

I’ve also closed a bunch of the bugs; thanks to everyone for sticking with Ceramic (and now Dusk) through the absence of updates lately - from now on, updates should be much more common.

  • Caleb :slight_smile:

By the way, I’ve opened up a new topic for it here; please comment on it to follow up.

http://forums.coronalabs.com/topic/42355-dusk-engine/

  • Caleb

Quick question for anyone who is knowledgeable with manipulating tiles / grids.

Im building a 3D engine which takes a tiled map and then draws it in 3D, with a camera, screen etc… Comparable to mode 7 I suppose.

To keep the processing down to a minimum I’m doing a field of view on the grid, simple Octant stuff depending on camera angle.

Its working ok but its still providing many more tiles than are visible with the camera, meaning I’m wasting cycles calculating stuff that won’t be seen.

What I really need is a way of getting all the tiles between at a given angle / fov. No point using any real fov scripts as that usually calculate walls / blocked tiles and are too slow. Need something fast.

I just ran into Ceramic and Tiled. This is a great tool! I’m following the, excellent, video tutorial and ran into a problem.

When I create an object on an object layer, Ceramic should create a vector shape. But this doesn’t happen for me. I don’t see anything. Though if I create an image on the object layer it will show. Though, if I activate physics, I’ll see the outline of the object in hybrid draw mode. 

I notice that the objects created for physics are offset to the upper let by half their width and height. I’m guessing that this is related to changes in the latest version of Corona and the Graphics 2.0 changes. 

@Matthew Pringle:

I, quite honestly, can help you not. I’ve never done anything in 3D (or even pseudo-3D). You might look into this (don’t know, didn’t look into the code); it runs pretty fast.

@soggybag:

[lua]

ceramic.virtualObjectsVisible = true

[/lua]

Should help you with the invisible things.

As for the offsets, that is a problem with Ceramic and G2.0 and will be fixed with Dusk.

Thanks for the reply. 

I noticed, what I thought was some strange behavior. I created a scene with two layers, foreground and background. I have two “player” type objects that move in the scene. I added the objects to the scene via: 

map.layer["foreground"]:insert( player )  

I also set the camera focus on one of these with:

map.setCameraFocus( player )  

The object that has camera focus is always in front of objects in the foreground. While the object that does not have the camera focus is in front of some tiles in the foreground layer while behind others. 

I’ll just answer my own question here, and point that I should probably make a layer for these objects and place it in front of the foreground layer if I want them to always be in front. I’m guessing it’s something to do with culling. The as new tiles come in view they are added to the layer and end up on top. 

@soggybag:

You can fix that issue by adding a line of code here:

[lua]

– Ceramic.lua line 495

layer:insert(tile)

tile:toBack() – Add this

[/lua]

Again, as soon as Dusk gets out, all these issues will receive “official” support (as in pushed to the repository, rather than advice to fix it given).

  • Caleb

Thanks again! I’m having a great time with this, Ceramic works really well. 

I had a question about Tiled. I’d like to draw a shape like a star or triangle. I remember reading something in this thread that shapes other than rectangles don’t always work. Either way I’d like to give it a try. The problem I’m having at the moment is, using the line tool in Tiled I can never get the shape to finish. I tried double clicking, pressing escape? 

– Edit –

After a couple tests it seems that shapes other than the rectangle and circle don’t work. I get an error in Ceramic something about reversePolygon not found. 

Another question, is it possible to fill a shape object with a tile pattern? Seems this might be possible with Graphics 2.0? 

The Platformer sample works fine but, there seems to be something missing from the tmx file. If I edit this file and export a new json file I get an error. I isolated it to the playerSpawnPosition. If comment this line there no error. 

player.x, player.y = map.tilesToPixels( map.layer["layer\_1"].playerSpawnPosition )  

I can’t seem to get this sorted out. There is a rectangle on the objects layer named “playerSpawnPosition”.  The following doesn’t work:

map.layer["objects"].playerSpawnPosition  

print( map.layer['objects'] ) -- shows nil  

What am I missing here? In another sample, where I created the map, I created an objects layer name “objects” and map.layer[“objects”] finds this layer. 

If I create a physics object in Tiled, and want to set the values for physics properties like friction and bounce, using the property dialog would the proper form be? 

Name:

physics:friction

Value: 

0.3

This seems to work. While I’m experimenting here I’ll point out that

bodyType, dynamic 

and 

physics:bodyType, dynamic both work.