add the value of a card right away

0 favourites
  • 4 posts
From the Asset Store
Kids Game
$49 USD
New Sounds Added Update: 115 new sound effects added for no additional cost!
  • Hello everyone, I have been racking my brain for days. I am creating a game where the player will click a button and randomly a card with a number from 1-10 will be shown. How do I add that card value to their score instantly when the card is shown. I am using 9 different sprites one for each card and I am declaring the card value for each sprite/card.

    i am using :

    system > card=1 > card > set animation frame to 0

    System > cardvalue=1

    system > card=2 > card > set animation frame to 1

    System > cardvalue=2

    etc.. for each card after it is randomly generated..

    so far the value from the last card shown is added to the total when the button is clicked..it is not reflecting it right away

    similar to blackjack. you know when the dealer gives you a card and you look at it you add that to your total.

    any help would be great

    thanks

    mark

  • Create one card object with 10 frames (0-9), one for each card value. Make sure the animation speed is set to zero.

    Create a global variable "score".

    Create a text object "txt_score"

    On button clicked:

    spawn card

    On card created:

    set card.animationFrame to floor(random(10)

    add card.animationFrame+1 to global variable "score"

    set txt_score text to "score".

  • Hi, thanks for the help. I tried the code you sent me, but it does not work properly. It appears that the animation is not randomly changing the card

    thanks

    mark

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Like so:

    https://www.dropbox.com/s/b3oprhlsmstee ... t.c3p?dl=0

    You need to ensure the animation speed on the card is set to zero in the sprite editor

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)