Home / Topic / Adding audio and animation to memory game

Adding audio and animation to memory game

Home Kwiksher Forums Kwik4 Adding audio and animation to memory game

Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • aaaiii
    Participant
    #85809

    Hi

    Trying to figure out how to add audio to a memory game
    (the one from the tutorial: https://kwiksher.com/doc/kwik_tutorial/programming/memory_game/).

    When two pictures is a match or not a match I would like an audio file to be played.
    Does someone knows how I can achieve that?

    And I would like an animation to be played when the memory game is completed and all the pictures is matched.
    Could someone help me out?

    Thanks 🙂

    Yamamoto
    Keymaster
    #85810

    You need to add one line of code in memoryGame.lua in the tutorial.

    Create an action which contains playAnim and playAudio
    and you can add the following code to the external code of hitTest () in memoryGame.lua where the second flip in the round. It calls the action.

    
    UI.scene:dispatchEvent({name = "action_YOUR_ACTION_NAME"})
    

    For instance, the action name: act_myAudio

    
    UI.scene:dispatchEvent({name = "action_act_myAudio"})
    

    reference
    https://kwiksher.com/doc/getting_startted/guidelines/migration_from_kwik3/migrating_from_kwik3/

    aaaiii
    Participant
    #85834

    Thanks 🙂👍
    Got the sounds working on -a match and on -not a match.

    Is there a way to have an -onComplete- action when all the memo cards are flipped? If possible, could someone guide me in the right direction? Been trying now for the last 2 weeks and cant figure it out.

    Thanks 🙂

    Yamamoto
    Keymaster
    #85838

    this time you need to add the following code to touchHandler.lua with YOUR_ACTION_NAME

    
    function isAllMatched(group)
    	for i=1, group.numChildren do
    		if group[i].matched == false then
    			return false
    		end
    	end
    	return true
    end
    
    if isAllMatched(layer.gp_photos) then
    	UI.scene:dispatchEvent({name = "action_YOUR_ACTION_NAME"})
    end
    
    aaaiii
    Participant
    #85841

    Thank you so much 🙂
    Worked out great on the memo game. Just needed to add the allMatch end animation in a group so it would show up in front of the memo group.

    Is there an easy method to make the end animation show up in front on the jigsaw puzzle? Tried to use toFront() but the animation is still showing up behind the jigsaw puzzle.

    Thank you for your patience 🙂

    Yamamoto
    Keymaster
    #85842

    are you using Action > Common > Front/Back? if it does not work, can I have you project file ? please send it to support@kwiksher.com

    Or inside isAllMatched function, you may try layer.YOUR_ANIM_LAYER:toFront()

    
    if isAllMatched(layer.gp_photos) then
            layer.YOUR_ANIM_LAYER:toFront()
    	UI.scene:dispatchEvent({name = "action_YOUR_ACTION_NAME"})
    end
    
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.