Thanks Caleb,
I have already solved above issue which i was facing in MTE. I hope we will be experimenting the Dusk Engine in our next game.
Thank you for your response.
~Kumar KS.
Thanks Caleb,
I have already solved above issue which i was facing in MTE. I hope we will be experimenting the Dusk Engine in our next game.
Thank you for your response.
~Kumar KS.
Thank you @Caleb, I access the name of the layer using this: print(“testando”, map.layer.teste.name) //meaning “teste” the map.name, and “name” the property I set on Tiled.
I also set a name for the tile on TILED, so I can check if the player is colliding with it or not. My question now is, how would I access this name?
Because I was trying to check collisions using event.object1.name and event.object2.event, but the object2 is giving me null, so I don’t know how to access the name of the tile.
Hope you undersatnd my question, and thank you for the fast response last time.
Hi Caleb,
I have a question, how would I approach changing the tilesets images programmatically?
For example, I have a map that enables the users to change it’s skin (using other images as the tilesets).
I was thinking to edit the “image” property from “tilesets” (in the “data” variable) that gets loaded in core.loadMap and replace the image I need in there.
What would you recommend?
Thanks,
Radu
So I’m now having a problem with getting the camera to focus on my player’s sprite. When I add in the code to have it follow the player the map’s collision starts behaving as if it were in a slightly offset location. Also the camera doesn’t keep him centered on screen and will even allow him to fall off the edge of the screen, though it will continue skewing downwards. I noticed someone earlier in this thread mentioned a similar issue, though I have some slightly different symptoms and the solution you mentioned for him (inserting the sprite into the map) didn’t seem to affect it.
I define it as follows:
sprite = display.newImageRect( "guy.png",64,96) sprite.x, sprite.y = 160, 100 sprite.rotation = -2.5 physics.addBody(sprite, {density = 1, friction = 5, bounce=0}) map.layer["player"]:insert(sprite) sprite.isFixedRotation = true sprite.bodyType = "dynamic" map.setCameraFocus(sprite) map.setTrackingLevel(1.0)
I also have a runtime listener and a function to updateView() every frame.
Any ideas on what I’m missing?
I’ve moved this to Caleb’s own forum “Gymbyl Coding”. Might I suggest starting new threads for specific questions regarding the Dusk engine instead of continuing this very long and multi topic forum thread.
Thanks
Rob
Nice job on Dusk Caleb!
I started playing with Dusk this evening by converting one of my previous games from Lime to Dusk. In less than 30 minutes I had the map loading. Still have some more to do, but it looks like you have built a solid tool.
I am starting the process of updating one of my textbooks and will be switching the tool use for the chapter on tile-based games to Dusk.
Can anyone give me info how to load a tile map,
I trying but, show nothing in simulator, also in terminal dosnt show any issue,
maybe i missed something, please help !!! :(
All Dusk does to load properties is process the value, which converts it to a number, Boolean, table, etc., and add it to the object with the exact same key as was specified in Tiled. So if you add a property called “name” to a tile in Tiled, each tile will have that property. If you’re not picking up the property in your collision listener, all I can say is that your collision listener is acting up. Here’s a working collision function (global because it seems that’s what you’re using):
local function onCollision(event) local tile, object = event.object1, event.object2 if not tile.tileX and not tile.tileY then tile, object = object, tile -- We mixed the tile and the object up; switch them end -- Use tostring() in case the name of either object is nil print("The tile's name is " .. tostring(tile.name) .. ", and the object's name is " .. tostring(object.name)) end Runtime:addEventListener("collision", onCollision)
Yay, a use case for plugins! I’ve been on the fence with them for a while. I just pushed a commit to the dev branch which actually calls plugin callbacks (previously, you could add plugins all you wanted, but they did absolutely nothing :D). What you’ll do now is this:
local tilesetChanger = {} -- Create the plugin table tilesetChanger.onLoadMap = function(data, stats) -- In here, 'data' will look approximately the same as Tiled exported map data. The only difference is that Dusk adds some extra properties in. -- Look at your map file to see the structure. data.tilesets[1].image = "../blahblahblah.png" -- Notice that the path is relative to the map file, not the root. end -- Later somewhere, BEFORE you load your map dusk.registerPlugin(tilesetChanger)
Notice that this will only work with the dev branch (I really need to get a stable release out!).
I know you said it’s not, but this seriously sounds like a prime case of object-not-in-map-layer. Are you sure you’re not inserting the object into something else after you insert it into the layer? Corona only allows objects to be in a single display group, so any insertions remove it from the previous group and insert it into the new one. I ask because I know someone who had this same problem - all the symptoms of notinmapitis, but they were inserting the object into the map correctly. It turned out that later they inserted it into another display group, so it was getting removed from the map after all.
@Dr Brian Burton:
Wow, great! Let me know if you need any help at any time.
Heelo @Caleb. It just worked really well.
I just would like to understand how the var dusk know that tile.name will get exactly the name of the Tile on my map, I don’t know if it is a clear question. How tile.name is not set to null but for the tile’s property on my map.
Also, can I keep improving this function to deal with other types of tiles?
Thank you in advance
Dusk reads the map data from the file exported from Tiled, and builds the map accordingly. Tiled includes the tile properties you set in the data. Thus, when Dusk reads the data, it knows that tile #xxx in the tileset gets the property “name” set to “blahblahblah” or whatever. Each tile in a layer is a separate display object, so when Dusk builds the tile, it adds that property.
For an alternative way of looking at it, imagine that you’re creating ten rectangles in your app, each of which has a different ‘name’ property. When a rectangle collides, you want to print out its name. That’s all Dusk is really doing - creating a bunch of little objects, each of which has different properties according to what you set in Tiled.
You should be able to just check for other names to deal with other types:
if tile.name == "flamingSpikesOfDeath" then -- Player dies elseif tile.name == "friendlyCloudWithTeeth" then -- Player looks quizzically at it elseif tile.name == "portraitOfNapoleon" then -- Player reflects on French history end
@Caleb P,
can you check the Bang notation to add collision filters. This is the property I added in the Tiled app but it doesn’t seem to work.
physics:filter = !!! categoryBits: 4 maskBits: 1
This is a screenshot of the property I added in Tiled so you can see if I did it right:
https://www.dropbox.com/s/0fv0za2jhdaflm4/Screenshot%202015-10-05%2016.53.27.png?dl=0
I know I got the CategoryBits and the Bitmask right because I tried the collision filter between the player, bullets, and a static crate image and it works.
Should be fixed. Try the new master branch or just add “filter = true” to the physicsKeys tables on lines 44 and 41 of objectlayer.lua and tilelayer.lua, respectively.
Edited, realized mistaken assumption:
That was it, I was trying to insert the sprite into the composer scene group even though I’d already inserted it into the map. Thanks!
Thanks Caleb! It works perfect now 
Thank you a lot for the clarification @Caleb,
I wonder if Dusk is compatible with the composer framework, or should I create my own game framework when working with dusk?
If we can work with composer and dusk simultaneously, is there any tutorial on how to do it?
Thank you again!
Dusk works great with Composer - remember that a map is just a glorified display group with a bunch of extra functions and behaviors. With that in mind, all you need to do to get Dusk working with Composer is insert the map into the Composer scene group.
self.view:insert(map)
Hello again Caleb!
I just made a moving enemy object with physics. Everything works fine, until the enemy (child object from your addObjectType function) goes off screen. Obviously enemy falls because of tile culling destroys the floor where it is walking 
I don’t want the tile culling disabled, so I was thinking 2 options:
Question for this option: is there a method to check if child object off screen?
Question for this option: how do I do that?
Or do you have much better method for this? 
Would you mind opening a new topic so we can get started with that approach to new questions :)?
Hello @Caleb, I am trying to implement enemis in my game based on what you said but there are somethings I could not understand.
The best way to implement enemies in a game that uses dusk is positioning the enemies from within Tiled?
If so, I guess the right steps to do it would be:
1- create the enemy on the map (would it be an object on the object layer or would it be just one normal tile?)
2- Set some properties (what is that Json positions you posted on the property on tiled?)
3- create the enemy on the code and import the properties from tiled to the code.(I would equal the enemy var with the object var on Tiled?(How would I do that?))
4- make the enemy move (should I treat the move of the enemy in the same function for every enemy I have on the game?)
Is that right? Sorry for the ammount of questions.
Thank you in advance!!!