Dusk Engine

Sorry for the delay in answering, I was in China :slight_smile:

Dusk actually does support non-square physics shapes, simply use the physics:shape property (as you would in normal Corona) and a JSON table prefixed with !json!.

physics:shape = !json! [0,0, 100,0, 0,100]

  • C

I am looking for a way to modify the layer/tile properties for friction.

I tried within the layer properties in Tiled t oset the friction with

layer.props:friction = 0.5

and I also tried

tiles:friction = 0.5

but none of the properties worked.

is there someone who can give a hint?

thanks sooo much in advance

Cheers,

johannes

physics:friction = 0.5
On the tile properties should work

Dont know how to do it from the layer…

That same thing’ll work for the layer, since the layer itself isn’t given physics.

  • C

Update on that bounce issue (box 2d).

You can completely get rid of that bounce by displaying another rectangle/ image/ something (with a physics body), and position it on the same place as that corner tile or wherever the bounce is occurring in your case.

If there are more physics objects stacked on the same spot, they will have enough force to counteract the player or some other force that collides with them.

Thank you so much guys - this really helps me to speed up :slight_smile:

Hi all -  I’ve created a tilemap using Tiled and I’m using the Dusk engine to display it. According to the Dusk documentation I think I need to reference objects created in Tiled using:
layer.object[name]
but I get Corona Simulator Runtime errors reporting nil values.

I’ve added a rectangular object called ‘startmarker’ and I want to use the x position of that marker to insert the player at the start of the game.

significant lines of my lua file is as follows (sorry if it’s disorganised, I’m still learning how to work with this…):
[lua]
local dusk = require(“Dusk.Dusk”)
require(“Plugins.mapcutter”)

local map = dusk.buildMapFromLayers(“map.lua”, {3,3})
map.x = display.contentCenterX - (display.actualContentWidth/2)
map.width = display.actualContentWidth * 3
map.y = display.contentCenterY - (display.actualContentHeight/2)
map.height = 265

map.layer[“markers”]:insert(startmarker)
local startmarker = map.layer.object[“startmarker”] <-- tried these two lines to help identify ‘startmarker’ object within the map layer but it doesn’t seem to help

map:scale(1, 1)
map.updateView()
map.setTrackingLevel(0.3)

local sheetData = { width=40, height=40, numFrames=12, sheetContentWidth=480, sheetContentHeight=40 }
local mySheet = graphics.newImageSheet( “boss.png”, sheetData )

local startmarker = mySheet.layer.object[“startmarker”] <-- tried this too but it’s not working

local t = 1000;
local sequenceData = {
{ name=“boss”, start=1, count=12, time=t, loopCount = 0 },
}

local boss = display.newSprite( mySheet, sequenceData )
boss.myName = “boss”

boss.x = -30;
boss.y = 165
boss.xScale= 3.5
boss.yScale= 3.5
boss:setSequence( “run” )
boss:play()
transition.to( boss, { time=6000, alpha=1, x = startmarker.x }) <-- I want the destination of the transition.to to be the x value of the Tiled rectangle object
[/lua]

I’d be really grateful if you could offer me any advice, I seem to be getting nowhere…

Many thanks

map.layer holds map layers, so you need to identify a layer to access with map.layer[x].object[“startmarker”].

Hope it helps :slight_smile:

  • C

Thanks Caleb. So, the object layer in Tiled is called ‘markers’, so I’ve entered the following:

[lua]

transition.to( boss, { time=6000, alpha=1, x = map.layer[“markers”].object[“startmarker”].x }

[/lua]

I’m not getting any success and when I use the above in line 28 and comment out lines 8, 9 and 15, I get:

'Attempt to index field ‘markers’ (a nil value)

Do I need to declare something earlier?

Thanks a lot for your help.

– edit  – I’ve been playing around with different local declarations at the beginning of the file but without any luck. I found another thread that mentions inserting the character into the map layer, which seems logical but that doesn’t fix it…

@Caleb P:

Is it possible to make objects static? They keep falling down to the floor.

I want to create a door that floats in the air and disapears after a few seconds, but it keeps falling down :slight_smile:

Also, I think I’d be handy if tiles (not just objects) could have the ‘layer.nameIs’ function, so I can select the object and change it.

Are you sure you’re not “cutting” out the layer with MapCutter?

  • C

@Sneeuw

Select your door tiles on your tile set, and add a property with a name  physics:enabled and make the value  false.

It will float there, not affected by the gravity, and it won’t collide with other objects.

EDIT:

If you want them to be able to collide with other objects, you can add a property, name it bodyType  and write  static for the value.

Thanks, that works :slight_smile:

Can you please tell me why the masking isn’t correct of objects like:

corona.png

The white box just hangs (doesn’t fall like falling off a stairwell). I illustrated the problem with the red line. The tile is handled as a block instead of a triangle. The block has physics, it drops from the air and stops right there (see image)

(I also followed this tutorial of Tiled: https://github.com/bjorn/tiled/wiki/Using-the-Terrain-Tool)

So the block is supposed to slide down that slope?

Yes, the slope tiles are getting handled as blocks. All tiles get handled as blocks, even if only half of the tile has a texture on it.

The transparent part will collide with other objects as well.

I don’t think there is a way to add physics to only half of the tile.

As far as I know Tiled doesn’t have that option, nor does the Dusk engine. Not at the moment…

What you could do to solve that problem is you could remove the physics body from the slope tiles, just make them float there, not colliding with anything.

And then display objects (rectangle or something), position them where the slope is, and rotate them to match the slope angle (Note that you can make those objects fully transparent, so they’re invisible and it looks like the objects are colliding with actual slope).

To get the coordiantes of the slope tiles, you can use map.tilesToPixels, instead of trying random coordinates till you get it right.

We discussed map.tilesToPixels a few pages back (Page 4 of this topic), if you need to know how it works.

Assuming you’re a Pro/Enterprise subscriber, you can use png2box2d to get an accurate shape:

http://coronalabs.com/blog/2014/01/28/tutorial-create-physics-bodies-from-texture-assets/

@tilen.curin:

Thank you for that answer. Your answer will do, but I really wonder how so many people create games and make the masking possible. Perhaps they used the same trick, but I doubt that.

@Panc software:

No I am not (look at my profile ;)). I just program things in Corona as a hobby. Though, I do have my own software company but its specialized in almost any WEB2.0 programming language.

Yeah, I know about many sidescrollers that have slopes and the characters just normally walk on them.

Idk maybe they don’t use tiles for collisions at all and they just make paths where the character can walk.

Maybe they’re using some similar system to that png2box2d…not sure.

Anyways, glad I could help.

@Tilen.curin:

True, there are several (paid) software solutions to make side scrollers with correctly masked tiled. I hope Dusk Engine will ever support it. 

Seeing the forum I would think you’ve done much with the Dusk Engine yourself. Would you care to share what you’ve made? 

I’m actually using Dusk engine only for platforms and enviroment where character can collide.

Backgrounds are just scrolling images.

So far I have only one simple map where I can test character movements and sprite animations, cause there are other things I plan to implement before going into level design.

But I may soon upload some footage of my game. Maybe here on this thread as an example of how well Dusk does.

I don’t think I’m cutting the layer…?

I’m using composer (probably not very well) and here’s the file in which I’d like to reference the position of an object from Tiled to use as a positioning reference for the game character:

[lua]

local composer = require( “composer” )

local scene = composer.newScene()

local mydata = require( “mydata” )

local physics = require( “physics” )

physics.start( )

local gameStarted = false

display.setStatusBar(display.HiddenStatusBar)

local textureFilter = “nearest”

display.setDefault(“minTextureFilter”, textureFilter)

display.setDefault(“magTextureFilter”, textureFilter)

local topY = display.screenOriginY

local rightX = display.contentWidth - display.screenOriginX

local bottomY = display.contentHeight - display.screenOriginY

local leftX = display.screenOriginX

local dusk = require(“Dusk.Dusk”)

require(“Plugins.mapcutter”)

local map = dusk.buildMapFromLayers(“level.lua”, {3,3})

map.x = display.contentCenterX - (display.actualContentWidth/2)

map.width = display.actualContentWidth * 3

map.y = display.contentCenterY  - (display.actualContentHeight/2)

map.height = 265

map:scale(1, 1)

map.updateView()

map.setTrackingLevel(0.3)

local sheetData = { width=40, height=40, numFrames=12, sheetContentWidth=480, sheetContentHeight=40 }

local mySheet = graphics.newImageSheet( “character.png”, sheetData )

local sequenceData = { 

   { name=“characterrun”, start=1, count=12, time=1000, loopCount = 0 },

}

local character = display.newSprite( mySheet, sequenceData )

character.myName = “character”

character.x = -30;

character.y = 165

character.xScale= 3.5

character.yScale= 3.5

character:setSequence( “characterrun” )

character:play()

transition.to( character, { time=6000, alpha=1, x = 500 })

return scene

[/lua]

In line 49 I’d like to replace ‘x = 500’ with ‘x = x position of object made in Tiled

What would you type there to reference that?

I realise I’m not identifying a layer as per your previous post - I couldn’t get that to work. I kept getting nil value errors however I tried… perhaps you could give an example?

The layer in Tiled with the objects is called ‘markers’ and the object within that layer I’d like to reference is called ‘startmarker’.

Thanks for your help, it’s really appreciated - I’m not a programmer so it’s not obvious to me how to implement this but I’m sure once I’ve got this I’ll be able to apply it elsewhere in the project…

Many thanks