Dusk Engine

You can use Dusk’s JSON or Bang (I recommend Bang!) notation to do that (in tile properties):

physics:filter = !!! categoryBits: 4 maskBits: 1

You can use one of the collision filter helper charts (one is on the docs page at https://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html) to find the correct values for tiles to collide.

  • Caleb

Okay I got this far but how do you use Bang notation to change the physics:filter of each tile?

for tile in map.layer["tiles"].tilesInRange(1, 1, 32, 32) do            if(tile.bodyType and tile.bodyType == "static" ) then             --physics:filter     =     !!! categoryBits: 4 maskBits: 1 ?????         end end​

Also, how do you return  how many tiles are in the map? When I iterate through this code it seems I have 832 tiles in the map. But its a 32x32 map size. Shouldn’t the map tiles size be 1024? Am I using “tilesInRange” wrong??

The dusk engine is awsome everthing worked perfect unti added the code for the Player  to fire bullets. There was collision between the player and the bullts ugh.

Thanks for all your help Caleb

Hi Caleb and thank you from the earlier response of my previous problem! :slight_smile:

But once again there is something I need your help.

I want to achieve the same thing Aatos Media wanted awhile ago:

So the question is: where do I add the nil check? I have tried right before the error and in the beginning of the addObjectType function and many other places, but then occurs more dusk_core errors.

@burnsj002:

The filter notation will go in the tile properties from Tiled. With the most recent version of Tiled (0.13.0 at the time of this writing), click on the tile you want to have a filter, then add a property from the properties menu.

@Painconfess:

The nil check’ll be in the object type building code. After you create your object via the params.build function, check for if the object was created. If it was, proceed, otherwise, cancel and clean up or whatever. Then, add another nil check in the object type removal code erase listener.

  • Caleb

Thanks Caleb:)

Thank you Caleb!

How can I name the whole layer’s tiles ? simply putting name = floor or tiles:name = floor won’t do the trick. Or is there a way to check from what layer tile is from? OR do I just need to manually name the tiles from tileset? :smiley:

How is tiles:name not working? You’re putting it in the layer properties and the tiles aren’t getting the property?

Aside, an easier way might be to use tile.parent: the Corona ‘parent’ property points to whatever group the tile is inserted into, which’ll be the layer. Dusk stores the layer name set in Tiled as “_name”, just like for objects. So you can easily check ‘if tile.parent._name == “whatever” then’.

  • Caleb

Hello I seem to be having a very basic problem using the engine, so I think I must be missing something very basic. Tried using the engine and it gives me an error “attempt to perform arithmetic on local ‘gid’ (a nil value)”. I initially had it in slightly more complex code, but I’ve narrowed it down to a test project with just the snippet below in an attempt to see what was wrong. 

local physics = require("physics") local dusk = require("Dusk.Dusk") physics.start() local map = dusk.buildMap("testmap2.json") map.y = display.contentCenterY map.x = display.contentCenterX

I’ve definitely put the map and tileset image into the same project folder and the dusk folder is in there as well of course, so what am I missing here?

I’ll need a little more information - can you give me the whole error, including line numbers?

  • Caleb

Hello guys, 

could anyone tell me if the Dusk Engine is still being worked on, or it is depreciated. If so, could anyone tell me any other tile based engine to use for 2d games?

Thank you a lot!

Carlos, the developer of Dusk just replied to a post a few hours before your message (Caleb) :wink: So yeah - it is. I think that Dusk is the only tile engine for Corona at the moment.

Yeah sure. Thanks for the reply.

What you saw is the entire file, but the error is in line 142 of Dusk\dusk_core\layer\tilelayer.lua: attempt to perform arithmetic on local ‘gid’ (a nil value)

Full stack traceback from corona simulator:

Dusk\dusk_core\layer\tilelayer.lua:142 in function ‘?’

Dusk\dusk_core\layer\tilelayer.lua:324: in function ‘_edit’
Dusk\dusk_core\layer\run\update.lua:59:in function ‘register’
Dusk\dusk_core\core.lua:370:in function ‘buildMap’
Dusk\Dusk.lua:54:in function ‘buildMap’
main.lua:5: in main chunk (line 5 is the line on which buildMap is called of course, not much I can say about the rest of it.)

Hm. And what about your map file? Feel free to PM it to me if you don’t want to post it publicly.

Also, can you see if using the dev branch of Dusk fixes this? In GitHub, click on “Branch: master”, switch to “dev”, and re-download the ZIP.

  • Caleb

Switching to the dev version did not seem to work. It just got me slightly different line numbers with a similar traceback. Posting it just in case it might be helpful.
 

Dusk\dusk_core\layer\tilelayer.lua:267: attempt to perform arithmetic on local ‘gid’ (a nil value)

 

stack traceback:

Dusk\dusk_core\layer\tilelayer.lua:267 in function ‘?’

Dusk\dusk_core\layer\tilelayer.lua:532: in function ‘_edit’

Dusk\dusk_core\layer\run\culling.lua:225: in function ‘initialize’
Dusk\dusk_core\layer\run\update.lua:57:in function ‘register’
Dusk\dusk_core\core.lua:392:in function ‘buildMap’
Dusk\Dusk.lua:46:in function ‘buildMap’
main.lua:5: in main chunk (line 5 is the line on which buildMap is called of course, not much I can say about the rest of it.)

 

The map was a typical .json exported from tiled. The map itself was just a simple 10x10 block of tiles (64x64 tiles), as I was making it as simple as possible just to make something appear on screen. The tiles themselves were from a colleague, made for the project that I’m looking to use Dusk for. So do you just need to examine the exported map data or do you need to see/mess with the map itself? The former isn’t a problem, so I’ve attached it to this post as a txt file (doesn’t like json apparently). The latter I’ll PM to you if you need them, since it probably would be better to err on the side of caution there.

 

 

Aha! Set the “Tile Layer Format” dropdown list in the Tiled map properties window to either XML or CSV. This is a common pitfall. I’ll add an error message for this until I can code a Base64 zlib or gzip decoder.

  • Caleb

That did it, thanks a lot for the help. Might also want to add that detail to the documentation’s quickstart bit as well.

  hi,

I am currently using MTE Tile engine for my game. I have few issues with this engine, especially when my camera moves fps is getting dropped in most of the devices. Faster the camera moves greater the fps drops.

So i am currently thinking to switch over to this engine and my game is not physics based. I have few questions, 

  1. does the same issue occur in this engine. .

  2. I am using map , which has tile size of 10 * 10  and it almost has 1000 tiles. Can this engine accommodate this map.

  3. Is it possible to use the Spine with this engine.

More over i could not find the documentation for this anywhere. The link which is specified says page not found.

Thanks,

Kumar KS.

Hello, the “some layer” should be the name of the layer that I created on Tiled? Or is it the name of the map? I am having the sema problem and I believe if a group the player to the layer, the collision will occur.

Thank you in advance

Hello Tilen, 

where do you put the name “tile”? 
Is it in your code, or in some property of the sw where we create the maps?

@kumarks102:

  1. I think any tile engine would have issues with 10x10 tiles. It’s just that there are so many more tiles than there are with, say, a 32x32 map. Rounding 32x32 down, there are approximately nine 10x10 tiles for every 32x32 tile, so if you have a map completely filled with tiles that fills an iPad screen with 32x32 tile dimensions (32x24 or 768 tiles) and you switch to 10x10, you’ll have almost 8000 tiles on the screen. Moving the map will result in a frame drop because you’re drawing and erasing tiles as needed, and, again, you’re drawing and erasing a lot more tiles than you are with a 32x32 map. Potentially, when I complete the tilemap shader, you’ll be able to move some of your tiles to a shader layer and they’ll render much faster. You can follow the progress of the tilemap shader here: https://forums.coronalabs.com/topic/59174-making-a-tilemap-shader/

  2. 1000 tiles is by no means to much for Dusk to handle. The most I’ve ever done is twenty-five million, so you’re good ;).

  3. Integrating Spine and other libraries isn’t so much a “can Dusk do it” as a “can I do it”. Dusk just builds the framework for you, and you’re left to make the rest of the game. Spine objects can be inserted into Dusk layers, if that’s what you’re asking - I’m doing that in my game.

@carlos.rafael:

“some layer” will be the name of the layer. Also, custom properties on tiles will be placed in the “Tile properties” window in Tiled. Dusk then loads them and you can access them on the tile.

  • Caleb