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]
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?
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 :(.
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).
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?
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!
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.
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?