The tileset I’m using has 64x64 tiles, with a spacing of 8 pixels between each of them. There is also a gap of 8 pixels between them and the edge of the page.
I just tried using a tileset with no margins or spacing, and that worked fine.
Hi Caleb,
I have been having some issues trying to add physics to my tilemap.
I followed the documentation and added the properties physics:enabled = true and tiles:bodyType = static to a layer, but when I load it in my scene all the tiles in the layer disappear.
I looked at the example projects, and some of my other Dusk projects, and I can’t see what I am doing wrong.
Does your tileset fit correctly with the dimensions? That is, is 8+8+(64*num columns)+(8*(num columns - 1)) = the width of your tileset and the same for height? Sometimes Tiled loads a tileset fine when dimensions are wrong but I’m not so sure about Dusk…
If everything looks good, can you PM me your map file so that I can take a better look?
As for physics, try doing this and see if it still happens.
-
Make a new map with your tile size, and load your tileset in it.
-
Draw tiles in your map, blah blah blah
-
Set physics:enabled and tiles:bodyType in the layer properties
-
Load in project
What you’re doing here is just making the most basic map you can. I just did the same thing and it worked fine for me (programmer’s worst nightmare :)). If it’s still not for you, make sure you have the most recent version of Dusk and post again.
- Caleb
Hello, everyone!
If you haven’t already done so, please (please, please, please!) take the Dusk survey I made. I really need your feedback. You can find it here: http://goo.gl/forms/N1SVTCNAJa . This is seriously very important. Thanks!
The forum post is here: https://forums.coronalabs.com/topic/54887-dusk-engine-survey/
- 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.
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.
Just posting to tell everyone about the really cool new features I’ve added to the dev branch of Dusk: OBJECT CULLING! FINALLY! Besides that, I’ve also added tile state listeners (“Hey Dusk! Tell me when this tile gets drawn, ok?”) and tile data construction (“I know this tile doesn’t exist yet, but can you generate the data it would have if it did exist?”).
These new features are alpha-quality, so they’re in the dev branch on GitHub. Please download it and see if everything works for you. If you find any bugs, post away! Also, be aware that some things might not be fully complete (i.e. there’s currently no way to stop objects from being culled apart from a map-wide Dusk preference, and all objects are culled, even data objects, etc.).
- Caleb
maschietto.jr:
Sorry to ask this, but i searched for the entire forum before.
Whats is the properties i need to set on an object, tile, or layers to make then a body. They dont colide with my sprite. I was using lime and was working.
I found the properties objects:bodyType and tile:… here in forum. But i think is missing something or i am using wrong. Where do i use this properties? Is on Properties on Tiled right?
Caleb P:
This is actually the original old post… The new one is http://forums.coronalabs.com/topic/42355-dusk-engine/. If you’ll post there instead, that would be good.
However, to answer your question, the properties you’re looking for are the physics: properties. You can make a single object or tile physical by adding physics:enabled = true to your object or tile properties, or the entire layer physical with physics:enabled = true as a property on the layer. Each parameter you need to add to the physics options (bounce, density, etc.) are all just the name prefixed with physics: - physics:bounce, physics:density, etc.
I think I have something about this in the docs; just open docs/index.html (from the main Dusk project folder) up in your browser and go to FAQ.
- Caleb
Now in the right topic.
Thanks, it’s worked.
I do not cheked the FAQ section, sorry.
But there is something wrong when I build the map.
- First the objects aren’t being drawned on the right position. They appear more on the right and lower than they really are on tiled.
- The second thing is the colission detection. In “hybrid” mode i can see the collisions area in the right place. But it reallys occur a tile before. For example: In a platform, the first tile has no collision ( but in hybrid mode i can see te box ). And there is ghost tile ( with no box on hybrid mode ) thats has colission.
I uploaded a printscreen.
I have some questions regarding the creation of a side scroller with dusk:
-
how can I use different tile sizes for different layers of one level? Like for example: big background image blocks (like 512x512px image files) for the scene background (mountains etc.) or even bigger images, midground images in another resolution and foreground tiles, like 64x64px tiles for platforms etc.
-
Is there an existing sample for a sidescroller available somewhere?
-
How do I manage the different speeds of layers?
-
What are the camera options I have for such a game and how can I use them? (follow player, zoom in, zoom out, easing cam…)
Thank you for your help Caleb!
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
- 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!
Some of what’s happening sounds like you may have your player outside your map. Did you call map.layer[xyz]:insert(player)? The player has to be inserted into a layer for everything to work correctly.
And as for the objects not being drawn correctly, can you give me a little more information? You’re just creating the objects in a Tiled object layer, then loading them with dusk.buildMap(), and they appear off-center like that? Do they have any other properties other than physics:enabled?
-
Different tile sizes are not currently supported, but you can still make a background easily by just using smaller tiles. Alternatively, the most recent version of Dusk on the Dev branch also supports object culling, so you can use objects and draw/erase as needed.
-
Not currently. Dusk’s #1 weakness (and #1 requested feature) is lack of documentation and examples.
-
Dusk comes with built-in parallax scrolling. It’s in the docs. (Yay! I’ve always wanted to say that!)
-
Dusk comes with a camera system as well. It doesn’t have full documentation available, but it is touched upon in the Careening into Dusk guide.
- Caleb
I’m having the same problem with object layer. Object are not at the right position compared to my tile layer.
Object are offset buy about 16 - 24px depending on the scaling…
@Caleb P
Found something in the file /Dusk/dusk_core/layer/ objectlayer.lua
Around line 166, your setting the x and y position of the object based on the tileset size… I think it’s wrong since the object layer can be used for image that are not the same size as the tileset… At least, that’s what I’m doing
So instead of this line:
obj.x, obj.y = o.x + (mapData.stats.tileWidth \* 0.5), o.y - (mapData.stats.tileHeight \* 0.5)
I’ve changed the line to this:
obj.x, obj.y = o.x + (obj.width \* 0.5), o.y - (obj.height \* 0.5)
Correct me if I’m wrong.
P.
Ok. Didn’t know Tiled supports other-sized image objects. I need to check for other features I don’t know about
Right now I’m not able to “officially” fix this, but I’ll do it when I can.
- Caleb