LUA TABLES or CORONA DISPLAY GROUPS -A juggling act!


–globals.lua


CARD\_1 = "card\_1" --imageSheet graphic reference CARD\_2 = "card\_2" --imageSheet graphic reference

–playGUI.lua


–THESE DISPLAY GROUPS ARE THE HEART OF MY QUESTIONABLE “LOGIC” or POSSIBLE DILEMA!

–ADDED TO THE sceneGroup in function scene:create() BEFORE CONTENT IS ADDED TO THEM

local deck = display.newGroup() local hand = display.newGroup() local played = display.newGroup() local discard = display.newGroup()

–KNOWING OBJECTS ARE STACKED ONE ON TOP OF THE OTHER WHEN ADDED TO DISPLAY GROUPS,

–MY LOGIC IS:

–JUGGLE CARDS BETWEEN DISPLAY GROUPS DURING GAME PLAY, SINCE,

–AS CARDS ARE ADDED TO THE “played” DISPLAY-GROUP, ONE BY ONE, THROUGHOUT THE GAME,

–THE STACKING APPEARANCE WILL BE MANAGED

–NOTE: 


–EACH CARD IS A DISPLAY GROUP TOO,

–JUGGLED BETWEEN ABOVE DISPLAY GROUPS 

local card\_1 = display.newGroup() local card\_2 = display.newGroup()

–REDUNDANT? 

–See “makeCards()” below for possible redundancy

–Variable holds a single card displayGroup created above

local card1 local card2

function makeCards()

    --Card1 and Card2 are constructor functions in “aCard.lua”

    --3 ARGUMENTS: imagesheet, graphicREF, and cardGROUP (not DECK or PLAYED groups)

  

 card1 = Card1( cardImageSheet, CARD\_1, card\_1 ) card2 = Card2( cardImageSheet, CARD\_2, card\_2 )

    

    --INSERT CARDS INTO THE “STARTING” DISPLAY GROUP “deck”

  

 deck:insert(card1) deck:insert(card2) end function scene:create( event ) --cardImageSheet CREATED HERE --ADD DISPLAY GROUPS TO "sceneGroup" BEFORE ANY CONTENT IS ADDED TO THEM, --SEE makeCards() ABOVE sceneGroup:insert(deck) sceneGroup:insert(hand) end

–aCard.lua (child of class.lua)


aCard = Class() function aCard:new( imagesheet, thisgraphic, cardgroup ) end Card1 = Class( aCard ) --Card1 constructor function Card1:new( imagesheet, thisgraphic, cardgroup ) end Card2 = Class( aCard ) --Card2 constructor function Card2:new( imagesheet, thisgraphic, cardgroup ) end

Technically, the way I have the cards displayed on the screen,

the only display group where cards are ON TOP OF EACH OTHER,

and thus, must be managed either by toFront which “ACCESS” seems limited,

or by the cumbersome JUGGLING act I have induced.

Is my LOGIC completely in the dark?

If not, and if it is a bit cumbersome, can some one let me know if there is

light at the end of my logic tunnel?

The only soliution still unclear to me is,

“Listeners can be either functions or table/display objects.”

So, if I add the card display groups to LUA tables instead of DISPLAY GROUPS, 

say, in the “tablePlayed{}” then, can a card, when being added to that table be told to “toFront(card1)”"

I am not trying to do things the hard way,I am just trying to do what programming languages allow,

A BILLION APPROACHES!

Any suggestions for either scenerio?

For those curious, I spent the first 45 minutes of my morning typing this.

This was not copied and pasted from my game.

This was designed to walk you through my logic, and I typed every letter, no copy/paste!

Ritalin does that to you!

I am commited to this Corona Buisness, and I look forward to being a CORONA FORUM CONTRIBUTER someday.

I appreciate anyone that reads my long winded mind!

I will learn to be more conscise; in the mean time, I must do my best to communicate.

I wish my language was as streamlined as LUA and CORONA.

PEACE

Chris:)

It seems I need to wrap my brain around creating “CUSTOM EVENTS”;  both Object and Runtime.

However, any suggestions concerning my current thinking above would be great. 

Right now, I am up to my web-browser-tabs in Corona Docs, concerning Event and Dispatch related topics.

And I am loving every letter of it!

The light is slowly dimming ON!

Thanks for any forth coming suggestions.

Chris:)

Is your main issue that the different groups are covering each other or that the cards within any of the groups are covering each other?  In other words, when you do the ‘toFront’ call, are you doing that on the group or the card image???

I see what you are asking. I was trying to avoid ‘toFront’ all together,  I am using display groups for every ‘single card’, as well as, for the different 'theoretical" card locations on the screen; that is, display groups for the DECK, HAND, PLAYED, and DISCARD.

I ‘was’ applying the ‘toFront’ to ‘each card’ in the group, DECK or PLAYED,  as these two areas have overlapping cards.

I do not have the traditional 52 cards to deal with, and I am able to display the HAND and DISCARD areas with each card without overlapping.

I was thinking I could avoid toFront by juggling the cards from one group to the next, and then, the order in which I am adding them controls what ‘toFront’ would accomplish.

It appears I lack the knowledge (though not after today, as I am hitting the Corona Docs hard) to create custom events to be dispatched.

I guess, bottom line, the choice to be made, is to either 1) use strictly LUA TABLES, that is, tableDECK{ },  tablePLAYED{ }, and resort to using toFront, or

  1. use DISPLAY GROUPS, groupDECK(), groupPLAYED() and then juggle the cards between these, thus, controlling the proper SCREEN STACK order.

I ran into confusion, trying to determine the elements in a DISPLAY GROUP and the elements in TABLES. 

Obviously, tables.library is quite robust in these regards. The displayGroup “table/arrays” not so much?

Should  I use:

  1. ONLY LUA tables,

  2. ONLY display groups

  3. BOTH!

Using both seems unnecessary, other than TABLES are logical structures and Display Groups are just pixels!

Chris:)

I don’t know exactly what you’re trying to achieve, but you could do:

local card = {}; for i = 1, 10 do  card[i] = display.newGroup() card[i]:insert(somethingOrOther) end

Which is a table of display groups. Possibly better than doing your card_1, card_2, etc.

Let me know clearly what you are trying to do.  Can you insert an image (a sketch drawing is fine) of what your display is suppose to look like when these 4 display groups are on the screen? 

Maybe some screen shots of when the cards are displaying wrong, so I can see where the issue may be.

If you are applying the toFront to a card image, that is in a display group, that toFront only moves it to the top of that display group stack.  So if your ‘deck’ display group, is composed of 10 cards, then toFront on that card will move it to the top of that display group…  but if your card is in a display group itself, that is yet another layer that it would be moved within.   If each card is in it’s own display group then toFront in that image will do nothing, you would have to do toFront on the group it is in.

I am wondering also, if you positioned the cards in a display group relative to the screen. What I mean is if you want the deck display group of cads to be in the bottom left corner of the screen, and the player display group of card to be at the top right part of the screen, that when you insert those cards into their respective display groups, are you setting their x, y positions set to those places??

there is a way to insert it in the response … but you can just email it to me at    cyberparkstudios@gmail.com

It seems I need to wrap my brain around creating “CUSTOM EVENTS”;  both Object and Runtime.

However, any suggestions concerning my current thinking above would be great. 

Right now, I am up to my web-browser-tabs in Corona Docs, concerning Event and Dispatch related topics.

And I am loving every letter of it!

The light is slowly dimming ON!

Thanks for any forth coming suggestions.

Chris:)

Is your main issue that the different groups are covering each other or that the cards within any of the groups are covering each other?  In other words, when you do the ‘toFront’ call, are you doing that on the group or the card image???

I see what you are asking. I was trying to avoid ‘toFront’ all together,  I am using display groups for every ‘single card’, as well as, for the different 'theoretical" card locations on the screen; that is, display groups for the DECK, HAND, PLAYED, and DISCARD.

I ‘was’ applying the ‘toFront’ to ‘each card’ in the group, DECK or PLAYED,  as these two areas have overlapping cards.

I do not have the traditional 52 cards to deal with, and I am able to display the HAND and DISCARD areas with each card without overlapping.

I was thinking I could avoid toFront by juggling the cards from one group to the next, and then, the order in which I am adding them controls what ‘toFront’ would accomplish.

It appears I lack the knowledge (though not after today, as I am hitting the Corona Docs hard) to create custom events to be dispatched.

I guess, bottom line, the choice to be made, is to either 1) use strictly LUA TABLES, that is, tableDECK{ },  tablePLAYED{ }, and resort to using toFront, or

  1. use DISPLAY GROUPS, groupDECK(), groupPLAYED() and then juggle the cards between these, thus, controlling the proper SCREEN STACK order.

I ran into confusion, trying to determine the elements in a DISPLAY GROUP and the elements in TABLES. 

Obviously, tables.library is quite robust in these regards. The displayGroup “table/arrays” not so much?

Should  I use:

  1. ONLY LUA tables,

  2. ONLY display groups

  3. BOTH!

Using both seems unnecessary, other than TABLES are logical structures and Display Groups are just pixels!

Chris:)

I don’t know exactly what you’re trying to achieve, but you could do:

local card = {}; for i = 1, 10 do  card[i] = display.newGroup() card[i]:insert(somethingOrOther) end

Which is a table of display groups. Possibly better than doing your card_1, card_2, etc.

Let me know clearly what you are trying to do.  Can you insert an image (a sketch drawing is fine) of what your display is suppose to look like when these 4 display groups are on the screen? 

Maybe some screen shots of when the cards are displaying wrong, so I can see where the issue may be.

If you are applying the toFront to a card image, that is in a display group, that toFront only moves it to the top of that display group stack.  So if your ‘deck’ display group, is composed of 10 cards, then toFront on that card will move it to the top of that display group…  but if your card is in a display group itself, that is yet another layer that it would be moved within.   If each card is in it’s own display group then toFront in that image will do nothing, you would have to do toFront on the group it is in.

I am wondering also, if you positioned the cards in a display group relative to the screen. What I mean is if you want the deck display group of cads to be in the bottom left corner of the screen, and the player display group of card to be at the top right part of the screen, that when you insert those cards into their respective display groups, are you setting their x, y positions set to those places??

there is a way to insert it in the response … but you can just email it to me at    cyberparkstudios@gmail.com