Dusk Engine

For collision detection set for example object.myName = “enemy” in objectType.build and if you want to detect collision with player or bullet. Make collision eventlistener for player/bullet and check if event.other.myName == “enemy”.

I think I’ve done exactly this, but where did you place the collision event listener? 'Cause mine was in main.lua, but now I have problems to call the remove-function.

I don’t know does it matter is it in main.lua, but all the player’s data I have in gamedata.lua also… you use remove function as [lua]event.other:removeSelf() event.other = nil [/lua] ? If so then what is the error?

Thank you a lot for the clarification  @Caleb,
I wonder if Dusk is compatible with the composer framework, or should I create my own game framework when working with dusk? 

If we can work with composer and dusk simultaneously, is there any tutorial on how to do it?

Thank you again!  

I feel stupid. I somehow understood that you have to use the remove function of the object culling code :slight_smile:

Thanks!

No problem :slight_smile:

I assume this was the question 2 you needed to explain more to Caleb? I was thinking how to use that function but I found it difficult because it is objectType’s function, not the not the objectType.build function’s object (the child object’s) function .

Mabye now Caleb knows how to reply to this issue :slight_smile:

Dusk works great with Composer - remember that a map is just a glorified display group with a bunch of extra functions and behaviors. With that in mind, all you need to do to get Dusk working with Composer is insert the map into the Composer scene group.

self.view:insert(map)
  • Caleb

Question 2 is done now :wink:

But @Caleb - I’ll get an error here
 

if dontComeBackOrIllShoot[specialKey] then   return -- Never mind, this one's already been destroyed end

main.lua:71: attempt to index local 'obj' (a nil value) stack traceback: main.lua:71: in function '?' Dusk\dusk\_core\layer\objectlayer.lua:232: in function 'constructObject' Dusk\dusk\_core\layer\objectlayer.lua:432: in function 'draw' Dusk\dusk\_core\misc\editqueue.lua:53: in function 'execute' Dusk\dusk\_core\run\culling.lua:142: in function 'update' Dusk\dusk\_core\run\update.lua:126: in function 'updateView' main.lua: 900 in function \<main.lua: 852\> ?: in function \<?:221\>

in main.lua

line 71: obj.mapObject = event.object    (this is the function: addObjectType(params))

line 900: map.updateView()

I wrote the error message - :lol:

EDIT

Don’t know if this a good way, but at least it works:

objectType.build = function(event) &nbsp; local objectid = event.object.x .. "|" .. event.object.y &nbsp; local object = display.newImageRect("image.png", 40, 40) &nbsp; if globals.hitPoints[objectid] == 0 then &nbsp;&nbsp;&nbsp;&nbsp; return object &nbsp; end

Hello again Caleb!

I just made a moving enemy object with physics. Everything works fine, until the enemy (child object from your addObjectType function) goes off screen. Obviously enemy falls because of tile culling destroys the floor where it is walking :smiley:

I don’t want the tile culling disabled, so I was thinking 2 options:

  1. Set gravity off when enemy(child object) off screen. 

Question for this option: is there a method to check if child object off screen? 

  1. Set tile culling begin for example half of the screen later (in a specific tile layer would be nice).

Question for this option: how do I do that?

Or do you have much better method for this? :slight_smile:

Would you mind opening a new topic so we can get started with that approach to new questions :)?

  • Caleb

Thank you a lot for the clarification @Caleb

Hello @Caleb, I am trying to implement enemis in my game based on what you said but there are somethings I could not understand.

The best way to implement enemies in a game that uses dusk is positioning the enemies from within Tiled?

If so, I guess the right steps to do it would be:

1- create the enemy on the map (would it be an object on the  object layer or would it be just one normal tile?)

2- Set some properties (what is that Json positions you posted on the property on tiled?) 

3- create the enemy on the code and import the properties from tiled to the code.(I would equal the enemy var with the object var on Tiled?(How would I do that?))

4- make the enemy move (should I treat the move of the enemy in the same function for every enemy I have on the game?)

Is that right? Sorry for the ammount of questions.

Thank you in advance!!!

Please open a new topic for this :slight_smile:

  • Caleb

Thank you, I opened another topic for the question @Caleb

@Aatos Media:

Good catch. Didn’t even think about that. You can add a nil check in the addObjectType function for that.

You probably don’t want to use up the resources to create an object if the object doesn’t need creating, which is why I was just exiting the function if it was destroyed. So a nil check is probably a better idea than creating the object whether it should be or not. That said, if you don’t mind the wasted memory, that’ll work, too.

@Painconfess: I’ve lost the thread of this latest conversation, sorry; do you still have an open question?

  • Caleb

Yes, I am wondering how can I iterate through child objects? I am having errors with displayed objects when I am changing scene, because some objects has transition’s and timer’s functions which needs to be cancelled before leaving current scene. Is there a easy way to call every displaying object’s remove function when leaving the scene and using map.destroy()?

I just pushed an update to the dev branch that calls the erase listener when each object layer is destroyed. So that should do it for you. Now when you destroy() a map, each currently drawn object calls its erase listener, which is what we hook into in addObjectType.

Also, I’m going to be gone for the next week, so I won’t be able to answer questions.

  • Caleb

Thanks!

I don’t know why but [lua]dusk.setPreference(“virtualObjectsVisible”, false)[/lua] doesn’t seem to work with the new Dusk… Or the reason is somewhere else.

do we have any updates for isometric mapping? i tried isometric map from tile editor to corona using dusk and it looks like a chess board :frowning:

Unfortunately, no, Dusk does not currently support isometric maps. Once I roll out version 1.0 (yes, it’s technically not even out of beta!), with documentation, bug-free-ness (or as close as I can get to that), and other basic foundation stuff like that, I’ll think about adding isometric maps. If you happen to be an isometric wizard, feel free to try adding isometric maps and submit a pull request.

  • Caleb