Dusk Engine

I now ended up using a value of +1 for the character moving to get the best optical results.

While testing on the device I discovered something strange: When using for example a TrackingValue of 0.05 in the Corona Simulator the camera is moving to the character when the character movement has ended, centering the character in the center of the screen. But when testing the code on the device the camera stops with the character and is not centering the character. I updated to the latest version of dusk… is it possible it has to do with changes in the last version?

The character being blurry is not an issue with Dusk. That’s (I’m fairly sure) because of fractional pixels.

The flicker you mentioned: Is it the same flicker that happened between tiles?
The non-centered camera you mentioned: It didn’t happen with the version you had prior to this version?

  • Caleb

@thomas6: Yep. :smiley:

@Everyone Else:

I’m going to be out of town until April the 21st, so I won’t be able to answer any questions in that time. Sorry if you just came up against a wall or anything :).

  • Caleb

I bought your game today btw :slight_smile:

The blurry character I think I can avoid by moving with rounded values.

Regarding the flicker I guess it is the same what happens between tiles.

And the version I have used should be the one prior to the latest… it still had the manual code dusk.setPreference(“experimental:roundCameraPosition”, true) and it was working.

I will do some more tests tomorrow. Maybe someone can confirm/unconfirm a difference between the camera tracking in the simulator and on the device?

Damn man… That’s insane. Supercool that you’re giving so much to the community. I’d love to help out more, but I’m so short on time working on my game (almost three years in the making now) that I need focus on finishing that project in this lifetime first…

Caleb, I confirmed a different behavior in the simulator compared to device camera movement with the latest version of Dusk. I changed back to my ‘old’ Dusk version and the movement on the device worked fine like in the simulator.

There has to be something which handles the camera movement differently on a device (iPad4) in the latest Dusk version.

Anyone else can confirm this?

UPDATE:

I experimented with the rounding and noticed it maybe is the problem here. So please forget the post above and I will first look further into it!

Hi, is there a way to add blendMode to tiles or a tile layer?

@d.mach: Ok, let me know if you need anything more. And thanks for buying my game; I appreciate it :).

@sakid.farid: Yep. Just put it in your layer properties:
[lua]
tiles:blendMode : add
[/lua]

Or, for a single tile in the tileset, add it to the tile’s properties:
[lua]
blendMode : add
[/lua]

  • Caleb

Awesome! Thanks Caleb.

I just noticed when looking at a map generated with dusk doing nothing else the system memory is counting up. It’s not much, but I wonder if this can create some problems when for example a game is played for some hours straight?

Are you sure it’s Dusk doing that? I just tested on multiple maps and I can’t see that happening.

  • Caleb

Mhh… I don’t have anything else going on, but it could be something in the debug code which wasn’t written by me. When you don’t see a memory problem I’m sure it is something on my end then.

Sorry for the trouble!

No problem :slight_smile:

  • Caleb

Hi

Im a little confused as to how the parallax works in Dusk. I know you can add parallax.x and parallax.y values on a layer. Problem on a tile layer is that you cant add something beyond the end of the map which would then scroll in as you reach the end. Also hard to tell where things would end up. With the image layer you can only have a single image. A repeat option for the image layer would be great where you could repeat the image for a set number or unlimited.

Or maybe im missing a trick here…

I can’t get an animation to work when I’m using a second tileset. Here is some code from the json map file for the tileset and the animation settings.

The animation on the first tileset is running, but the second isn’t. Maybe you can see some error here?

"tilesets":[        {          "firstgid":1,          "image":"..\/graphics\/tiles\_set\_1\_64x64.png",          "imageheight":990,          "imagewidth":990,          "margin":1,          "name":"tiles\_set\_1\_64x64",          "properties":             {             },          "spacing":2,          "tileheight":64,          "tileproperties":             {              "18":                 {                  "bodyType":"static",                  "name":"treasurechest",                  "physics:bounce":"0",                  "physics:enabled":"true"                 },              "3":                 {                  "anim:enabled":"true",                  "anim:options":"!!! start: 1 count: 2 time: 1000"                 }             },          "tilewidth":64         },         {          "firstgid":226,          "image":"..\/graphics\/tiles\_FOW\_1\_64x64.png",          "imageheight":204,          "imagewidth":1020,          "margin":2,          "name":"FogOfWar",          "properties":             {                              },          "spacing":2,          "tileheight":64,          "tileproperties":             {              "226":                 {                  "anim:enabled":"true",                  "anim:options":"!!! start: 227 count: 3 time: 1000"                 }             },          "tilewidth":64         }],  "tilewidth":64,  "version":1,  "width":16

Ah… found the problem. After putting all the tiles into one tileset (which was NOT necessary I guess!) I noticed I have to subtract 1 from the frame number to make the sprite work. Means in the example above it should work with 225 instead of 226

"225": { "anim:enabled":"true", "anim:options":"!!! start: 227 count: 3 time: 1000" }

even when the tilemap number for using the tile is 226!

I have one question regarding accessing a sprite tile…

When setting a frame the animation is still running. How can I stop (pause) a sprite animation on one specific tile?

UPDATE: I guess accessing one tile is not possible, so my question is now :)… How can I make sure the sprite animation is not played, but still can be accessed with :setFrame() ?

UPDATE2: Looking into dusk_core/run/anim.lua I found from line 142 on the following code:

if d.watchTile then                         d.watchTile:setFrame(((d.currentFrame + 1) % d.frameCount) + 1)                         d.watchTile:play()                         anim.sync(d, d.watchTile.frame) end

I think this code is preventing accessing :setFrame() and :pause() correctly, because whenever I try to use it the frames still are jumping or the animation still is running. I tried to pause() the animation to jump between different frames, but I’m not able to pause the sprite animation from the beginning. The animations is running for some frames before pausing OR not pausing at all.

Is anyone else accessing the sprite animation and give me some tips on how to handle frame changing and pausing animations correctly?

(Sure I could change the code in anim.lua, but then it would influence all sprite animations and with an update I have to keep track of my own code changes.)

AND ONE MORE THING: I noticed when playing with the anim.lua when removing the “d.watchTile:play()” and then setting a sprite anim frame with “:setFrame(1)” things seem to work BUT when moving the map forth and back all the tiles which were outside the visible screen borders are using a different sprite frame when being back on screen or moving on the screen for the first time. So culling tiles and setting frames seem to be a problem. Any idea on how to use culling but also the correct set frames on all tiles (visible and off screen)?

Is it possible calling the function to get a tile by coordinates like this:

tile=map.layer"tiles".tile(PosX,PosY)

is very slow?

If so, is there a way to speed up this part to make it possible to get this kind of tiles fast?

I’m using this to get tiles by having for example the player X-Position and player Y-Position, but when I’m getting more tiles this way in a short time it is slowing down the performance a LOT.

UPDATE and one more question:

The speed in the simulator is faster now… don’t know why, but maybe the function call isn’t the problem at all!?

One more important question:

I’m using

map.layer["tiles"].\_lockTileDrawn(x,y)

when I have loaded the complete map. There are a lot of tiles outside the visible screen area and because I have to access them I’m cycling through all tiles with a for loop and doing the lockTileDrawn above to make sure they all stay.

BUT when accessing tiles outside the screen they aren’t known sometimes. Is there a way to access tiles outside the visible area correctly?

I need to give each tile a :setFrame() value, even when not on screen. And I have to check the tiles for their frame value outside of the screen sometimes. But this is causing problems.

@sakid.farib:

Map wrapping is something I’d love to add when I have time. At the moment, you can try keeping a placeholder object to keep the layer from “snapping” and swapping their locations when you need to wrap. Kind of a kludgy workaround, though :(. I’ll add this to my list of Dusk features to work on.

@d.mach:

Hm… I assume that it’s being offset like that because Tiled uses zero-indexing and Dusk uses Lua’s 1-indexing. That’s just my initial guess, though. I’ll check into this.

Also, you can currently not have control over a sprite when you’ve set it to be animated. Instead, you can use !isSprite!, which builds the tile as a sprite object, then set the frame accordingly. If you need a tile to be both animated and editable, you’ll have to wait until I implement that (not so long, I *hope* - I’ve got it just about fully implemented in my personal version). The watchTile troubles you’re having are because of Dusk’s animation method. Basically what it does is wait until a tile is created, then targets it as the “watch tile”. Every time that tile changes frames, Dusk changes the other tiles in the map with that animation scheme to the correct frame. If the watch tile is removed, Dusk takes care of the switching with a runtime event to wait for the next frame time. When you stop the watch tile from playing, the other tiles also stop from playing. The version I’m developing on allows you to “decouple” a tile from the animation system and keep it from syncing with the watch tile.

[EDIT:] The ‘get tile’ method should be taking almost zero time. It’s just an “if tile exists return it” method.

Also, if you’re locking a tile, it shouldn’t be being culled. Are you sure you’re locking the same tile? Optionally, you could also, when you need to query the frame, draw the tile, get the frame, and delete it; Dusk ought to take care of the frame setting automatically. It might be faster or it might be slower than your current approach, depending on how many tiles you have.

  • Caleb

Thank your for all the useful information and tips. I will try some changes to my code and will wait for the animated and editable tiles then :slight_smile:
Regarding the culling I used _lockTileDrawn(x,y) for each tile I’ve changed the frame on and I had no problems since then. I don’t know why cycling through all existing tiles and locking them didn’t have the same effect, but my guess is this has all to do with the “watch tile”, so I will wait for your new version to look into this again.

At last let me tell you that working with dusk really is great and until now I don’t see any bigger problems with creating the game I want to make :slight_smile: Cool stuff!