Dusk Engine

are you adding it on the object?

object:addEventListener(“collision”,coinCollision)

do not include the “()” in the eventlistener.

if you have specified that the object names within “objects” layer are named coin it will find them.

right click on the object name in tiled, select properties, under the name column type name under value type coin

You can also set the type of the objects in Tiled (where it has name and type), then use the Dusk iterator .typeIs():
[lua]
for object in map.layer[“LayerCoins”].typeIs(“coin”) do
– Whatever
end
[/lua]

  • Caleb

Hi again, I can solve this problem, in the tiled map editor, i need write properties " name : coin" for each object or not found…

I have a other problem, can I center the camera, and when the player move, map move with him?

I do it:

[lua]

function reloadMap()

map:setReferencePoint(display.CenterReferencePoint)

map.setCameraFocus(circle)

end

Runtime:addEventListener(“enterFrame”, reloadMap)

[/lua]

And well, found the moves, but not good, I see the player more up, and map more down, the map move if I move the player, but I have collisions out of tiles walls(image). 

Sorry for all questions, and for bad english, maybe someone know a guide of this dusk engine?

Thx, regards!

The object properties window in Tiled with ‘Name’ and ‘Type’ correspond to the object properties ‘_name’ and ‘_type’. I would recommend using the ‘Type’ field to identify your objects as coins, then using the Dusk built-in typeIs(“coin”) iterator.

map.setCameraFocus should work fine, just remember you’ll need to call map.updateView() each frame to keep it updated.

As for a guide, sorry, there isn’t an up-to-date one right now :(.

  • Caleb

caleb are we able to zoom with the camera in dusk?

Thx caleb, you can see my problem here:

Captursda.png

Without map.setCameraFocus() I have good the tiles and physics, but with this function all map(images) are moved.

The player is the red rect.

Some idea?

Thx!

@tommowas: Yes, just set the map’s xScale/yScale

@jcarlosnunezperez: Can you turn on physics hybrid draw mode and show what it looks like?
[lua]
physics.setDrawMode(“hybrid”)
[/lua]

  • Caleb

See, so rare…

Captursda.png

EDIT: I have now the code of map.setCameraFocus() in the function scene:createScene( event ), now the physics are good, the player walk on the ground (green rect) but no on the ground tiles (images).

SEE:

Captursda.png

One question more, can I have position of enemys in a tile selected, maybe

pos = map.layer[].tile[x][y] 

enemy.x = pos.x

enemy.y = pos.y

???

Or too if I have a enemy , do one for each object?

I try :

 for object in map.layer[“layer”].objects() do

 enemy = display.newRect(100, 100, 50, 80)

enemy.x = object.x

enemy.y = object.y

end

But not found, I have 4 objects but only one enemy is created.

And the last question, can I move the camera with the player, only in the y-axis?

Thx

Getting the pixel position of a tile is done like so:
[lua]
local pixelX, pixelY = map.tilesToPixels(x, y)
[/lua]
The two arguments are the X- and Y- locations of the tile.

You can also get an actual tile object like so:
[lua]
local tile = map.layer[“layer”].tile(x, y)
[/lua]

And yes, you can move the camera in a single axis by setting the bounds to 0 in that axis:
[lua]
map.setCameraBounds({
xMin = 0,
xMax = 0,
yMin = whatever,
yMax = whatever
})
[/lua]

As for your physics issue, can you open a GitHub issue for that?

  • Caleb

@Caleb P

Let me suggest a feature the will make camera handling much easier to configure for the end user when it comes to setCameraBounds(). Let users configure the bounds manually (like it is now) or let them use an “automatic” mode. By this I mean, Dusk already knows the maps width and height and already knows the player position. It would be great if you could just tell Dusk to track the user with a certain amount of “padding”. This padding would be the amount of points from the edge of the map inwards that Dusk should internally set the camera bounds to so that you prevent the camera to track the user all the way to the edge of the map. In essence Dusk would be internally be just setting the camera bounds but doing some math like “mapbounds minus padding”.

It only saves the user from doing a bit of math, but I think it goes with the “easy to configure/use” Dusk motto. Plus, user code would look cleaner without this calculation.

Anyways, great job! I’m starting to use it and found it great!

Caleb, are we able to bring the fps to 30 with dusk? tried it runs very laggy…

How big are your tiles? How many are on-screen at any given time?

  • Caleb

Don’t forget to include device info…

tiles are 70x70 running a lg g2, lag is also present in the simulator.  this is with your bob demo with tile culling enabled etc… exact jittery frame-rate present in my games aswell… smooth at 60fps though

I think what you’re seeing is 30 FPS. After seeing 60 FPS for a while, changing to 30 FPS can make it look jittery. Since Dusk is running at 60 FPS (requires more speed), it should run fine at 30 FPS, too.

  • Caleb

hmm… whats defined in the config.lua is 60fps. so im seeing 30fps when defined at 60fps?

exact jittery frame-rate present in my games aswell… smooth at 60fps though

According to your post, it sounded like the game is smooth at 60 FPS but jittery at 30 FPS. Is that not what you meant?

  • Caleb

yeh thats what i meant. were you saying when defining 60fps in the config im really seeing 30fps due to the amount of resources dusk chews?

If, when config.lua says 60 FPS, it’s smooth, but when config.lua says 30 FPS, it’s jittery, then you’re just seeing the difference between 30 and 60 FPS. If, however, when config.lua says 60 FPS, it’s jittery, but when config.lua says 30 FPS, it’s smooth, then Dusk is running slowly. What situation do you have?

  • Caleb