Dealing with touch input and the "slide off" phenomena

Hi,

I’ve been working with Corona for a while now and I recently got myself a copy of Level Director.

I have been using it to make a side-scroller. I found that implementing Level Director greatly changed how I made my game (I am sure in the end for the better) but at the moment I often reach complications that may have to do with my understanding of the how the level object is loaded and how to access object properties after it is loaded.

My current problem is as follows:

I have at the moment a dpad ( a circle object that listens for touch events) that gives the 360 degree control depending on the input. I also have a jump button (circle object with a tap listener). At first this all worked fine and I was able to have the dpad and jump events happen at the same time as I one would in a game. A common problem (which i have found other posts about) is if I begin a touch event on my dpad and slide off the dpad and release outside of it then my “ended” phase is never reached and the dpad remains active.

I attempted to use focus to solve the problem and it seemed to work but then i lost the ability to both jump and control the dpad simultaneously.

The next solution I believe should work is that I created another larger and invisible circle behind my dpad and I want it to check for move events that happen outside the dpad and deactivate the dpad when this occurs.

Similar to the process described here: 

http://coronalabs.com/blog/2014/02/04/tutorial-continuous-actions-in-corona/

The problem I seem to be having is that I can’t get the invisible circle to be behind my dpad. ie. when I enter a move event on my dpad it’s registering a moved event also on the invisible circle (i have isHitTestable turned to true for the invisible circle). I tried to move the invisible circle and dpad circles to different levels in my Controls layer in LD but it still did not work as I desired. For reference though does lower on the list of the layer mean closer to the front of the display?

I basically need the dpad circle to have listener prominence over the circle behind it. So that the moved phase is only activated on the halo created by the intersection of my invisible circle and my dpad. Using the corona code toBack() does not work either because it fiddles with all the other objects such as my background and the like.

Any help on my specific problem or a solution to the slide off problem in general would be greatly appreciated.

Thanks.

 

In LD it draws the layers from top to bottom so the first layer will be drawn first and the last in the list will appear on top.

It is quite hard to see what your problem might be without some example code.

thanks for the quick reply.
 

A follow up question:

Are objects within a layer also hierarchical? ie. if  i have a “controller” layer that had a two circle objects the first one in the list called top and the second one called bottom will bottom be drawn after top?

as for the above problem I was able to finally get the touch handlers to work correctly, but my problem is still not solved I will add some code if I am unable to fix it soon.

I have one more question. Can LD easily handle having objects such as lines or circles drawn from straight Lua/Corona? Can it be implemented into the LD collision detection scheme or easily be added the the levels view group?

Why i ask:

I have a player object who will be able to cast a grappling hook type device, I could create this using straight Lua and drawing on the screen but I am not sure how to incorporate this into the LD frame work. I know you can create layer objects in your LUA code using  myLevel:createObject(“object”,objProps) but I am not sure if I can use this to make a line that grows in a particular direction and  extends from my player until a maximal length is reached or it collides with an object.

My only thought for implementing in LD would be to have a segment of this line as an asset in LD and then adjoin many of these segments together while the line is growing, but it would be much easier if i could somehow marry LD and native display commands in Corona.

Sorry again if no code samples make this vague.
 

In LD it draws the layers from top to bottom so the first layer will be drawn first and the last in the list will appear on top.

It is quite hard to see what your problem might be without some example code.

thanks for the quick reply.
 

A follow up question:

Are objects within a layer also hierarchical? ie. if  i have a “controller” layer that had a two circle objects the first one in the list called top and the second one called bottom will bottom be drawn after top?

as for the above problem I was able to finally get the touch handlers to work correctly, but my problem is still not solved I will add some code if I am unable to fix it soon.

I have one more question. Can LD easily handle having objects such as lines or circles drawn from straight Lua/Corona? Can it be implemented into the LD collision detection scheme or easily be added the the levels view group?

Why i ask:

I have a player object who will be able to cast a grappling hook type device, I could create this using straight Lua and drawing on the screen but I am not sure how to incorporate this into the LD frame work. I know you can create layer objects in your LUA code using  myLevel:createObject(“object”,objProps) but I am not sure if I can use this to make a line that grows in a particular direction and  extends from my player until a maximal length is reached or it collides with an object.

My only thought for implementing in LD would be to have a segment of this line as an asset in LD and then adjoin many of these segments together while the line is growing, but it would be much easier if i could somehow marry LD and native display commands in Corona.

Sorry again if no code samples make this vague.