Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

"button" event (tapping) question
Started by jbowen Oct 24 2009 06:30 AM

- - - - -
1 reply to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jbowen

[GLOBAL: userInfoPane.html]
jbowen
  • Observer

  • 1 posts
  • Guests

I havce the following code for a card matching game I'm creating to take a look at Corona:

function detectMatch()
    if flipped == 2 then
        if string.match(cards[flips[1]].name, "%d+") == string.match(cards[flips[2]].name, "%d+") then            matches = matches - 1
        else    
            print("hey", cards[flips[1]].name, cards[flips[2]].name)

            cards[flips[1]].alpha = 0
            cards[flips[1]].isVisible = false

            cards[flips[2]].alpha = 0
            cards[flips[2]].isVisible = false

        end
            
        flips = {}
        flipped = 0 
    end     
end

and the function card:tap event which uses it:

drawGameBoard()
for posCard, card in ipairs(cards) do
    function card:tap( event )
        flipped = flipped + 1
        table.insert(flips, posCard)
        transition.to( card, { time = 500, alpha=1.0} )
        detectMatch()
    end

    card:addEventListener( "tap", card)
end

When it is ran through the simulator, it only converts the most recent card to alpha=0, and not the other one that came before it. was wondering if anyone had any insight or further places to look for using the tap event with multiple buttons. i have a 6x6 card game where if two cards match, then they stay visible and untouchable, but if two cards don't, they flip back over.
uid: 3551 topic_id: 192 reply_id: 300192


[TOPIC: post.html]
#2

carlos m. icaza

[GLOBAL: userInfoPane.html]
carlos m. icaza
  • Corona Geek

  • 2,992 posts
  • Alumni

Jeff, after our email exchange and having what looked like a solution to the problem, how is the app coming along?

carlos
uid: 24 topic_id: 192 reply_id: 242



[topic_controls]
[/topic_controls]