Dusk Engine

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. 

Could you help me?

Thank you in advance!!!

@carlos.rafael

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 :smiley: 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 :stuck_out_tongue:

EDIT: The better way to do this might be set in build function object.name = event.object.name. 

Thank you for your help @Painconfess, I am trying to implement and make it work, soon I will post here what I was able to do.

well, i’m not sure if these were asked before or I have a different thought…

  1. 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?

  2. zooming in and out. can we stretch the tile map for zooming in and out? also stretched for other devices resolution?

tnx

Hey Caleb,
It’s been a while since I’ve been on the forum. Does Dusk support orthongonal maps from tiled?

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

@joshuacalebbryan:

I’m assuming “orthogonal” is a typo and you mean “isometric,” correct? If so, unfortunately no. Dusk only supports orthogonal maps.

@sakid.farid:

Congratulations! Looking good!

  • Caleb

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.

@mylegguy721

you can use animation by setting the chest tile’s properties like this:

[lua]

anim:options = !!! {name: closed start: 1 count: 4 time: 1000 loopCount: 1}, {name: opened start: 5 count: 9 time: 1000 loopCount: 1 }

[/lua]

And when you want to chest to be opened just set sequence “opened”

Don’t the tiles need to be sprite objects for that to work? Either they aren’t sprite objects, or my code is wrong.

Here’s my code:

[lua]

local chestSheetOptions =

{

    width = 16,

    height = 16,

    numFrames = 2

}

local chestSheet = graphics.newImageSheet( “chestSheet.png”, chestSheetOptions )

map.layer[“Solids”].tile(9,3):setSequence(“chestSheet”)

[/lua]

When I try it, I get:

attempt to call method ‘setSequence’ (a nil value)

Or, or do you set the animations in tiled? If so, how?

Well, I figured out I have to set the animations in tiled, but how do I make it go to the closed animation?

I can’t do object:setSequence…

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.

  • Caleb

You’re right!

One last question though.

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.

Hello Caleb,

First, many thanks for your hard work on the Dusk engine.

I’m working on a game concept using Tiled and your library help me a lot.

I’m quite new to Corona (and lua), working usually more with C/C++ and embedded systems.

I have few questions about your engine, hoping you can enlight me (I didn’t find answers in this forum yet :).

Context: I build a 120x40 tiles map (16*16 pixels each) and move inside of it

              using the camera _setViewpoint() _function

  1. I’m trying to use the tiles access function: layer.tile(x,y)

    or the direct tiles table: map.layer[“myLayer”].tiles[x][y]

    

    My problem: it seems I can only get back tiles that are in the range: [0,0] <-> [display.width, display.height]

    When I try to access tiles at others positions (ex: [100, 10]), I always get a NIL value.

    I tried to print the tiles table content and, indeed, it stops at something like [31, 21] (i.e. my display size).

    Changing camera viewport doesn’t seem to update the table content either.

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.

Thx in advance for all help!

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:

HkO4bAT.png

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?

Do you have an idea what this could be Caleb?

Thx in advance for any hint!