Hello @Caleb, based on the first answer you gave to @Aatos I am implementig this part of code where if the child object has been removed and the player goes offscreen, when he comes back, this child object must not be displayed. You said we have to set the properties of the host object, but how do I reference the host object? I can set and change properties of the child object using the object.“something”…, but I don’t know how to do it for the host object.
For the host object you set custom properties in Tiled and in code in the objectType.build or objectType. remove function you use event.object.“something” to get the property you added in Tiled.
Hello @Painconfess, thank you for the quick reply.
I have already set the property in Tiled but the remove function receives the child object as a parameter and not an event, so when I try to set for example event.object.name, I receive an error “attempt to index event a nill value”
In the build function, as it receives an event as parameter I can print the custom property, but not in the remove function. Do you know what should I do?
Oh I am sorry I have never needed the host objects properties in remove function I just assumed it works there also Make a local variable outside the objectType.build and .remove function and set in build function the value for variable you desire. That should definitely work
EDIT: The better way to do this might be set in build function object.name = event.object.name.
well, i’m not sure if these were asked before or I have a different thought…
is it possible to snap the objects to the respective tiles like most of the simulation games? like you will build a house and you will drag the house to your prospective area, also can we detect if this tile is already occupied?
zooming in and out. can we stretch the tile map for zooming in and out? also stretched for other devices resolution?
Just want to say a big thank you to Caleb! Finally released our game that uses the Dusk engine. The game has been in development for over a year and showcases what Dusk can do. Hurtle the Turtle
Is it possible to change what a tile looks like while playing the game? I want it so when I open a chest, it changes the tile to the tile for an open chest.
When you add animation options to a tile, Dusk builds it as a sprite. Alternatively, when you set the !isSprite! property, it’s a sprite as well.
So the only thing I can imagine that’s wrong is that you have the wrong tile coordinates. If you’re getting them directly from Tiled, remember that the tiles in Tiled are zero-indexed, whereas Lua’s tables are 1-indexed. So if Tiled says the tile is tile (9, 3), it’ll be layer.tile(10, 4).
Also, if you check out the animation sample in the sample maps, you can get an example of the way animated tiles work for reference.
When a tile goes off screen, it’s destroyed. And when it comes back onto the screen, it no longer has it’s animation because it’s a new object. How can I make it so when it comes back on screen it still has the animation?
I think a possible solution would be to replace the closed chest tile with an open chest tile, but I don’t know how to do that.
Is there anyone here who can post some basic “quick access” dusk code for creating a parallax scrolling map with different layers and some tiled objects please? I have some problems figuring out how to make this work.
I’m playing around with Dusk right now and encountered a strange error:
I’m using physics and when the screen is touched applyForce to an object to move it on the x axis. The camera is moving with the object when it is moved. When applyForce is used and the object is moved the following error is stopping the movement after about 1 second:
Attempt to compare nil with number
File: Dusk/dusk_core/misc/functions.lua
Line: 49
stack traceback:
Dusk/dusk_core/misc/functions.lua:49: in function ‘clamp’
Dusk/dusk_core/run/camera.lua:212: in function ‘processCameraViewpoint’
Dusk/dusk_core/run/update.lua:112: in function <Dusk/dusk_core/run/update.lua:111>
?: in function <?:205>
Any idea what I have to look at to fix this?
Somehow it seems like the map.setCameraFocus is causing the problem. When turned off everything works fine BUT when turned on it looks like the error appears exactly where the object normally would leave the screen (when the cam movement is turned off). Can it be a object culling problem?
Hello Caleb! I’m new in Corona SDK and I need to do a little 2D game for a class in my school, so I found Dusk and created my map with Tiled, so I exported it in .json and in .lua, my tiles are in the corona project folder, I could make it and put my map into corona but the thing is it shows enormous in emulator, how I can create a map to the size for the phone? Or what I need to do to fit in the phone? My map looks like this and shows up like this:
I still can’t figure out the problem (see last post). It looks like a culling problem with the object. The camera is holding the object in the center of the screen, but the error appears when the map (background) is moved the distance from the centered object to the screen borders. It seems like the object is “culled” even when the camera is following the object and keep it centered. Could this be it?