add the value of a card right away

Get help using Construct 3!

Post » Mon Jul 03, 2017 2:35 am

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
B
4
Posts: 2
Reputation: 204

Post » Mon Jul 03, 2017 10:09 am

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".
B
20
S
8
G
3
Posts: 457
Reputation: 4,053

Post » Mon Jul 03, 2017 2:43 pm

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
B
4
Posts: 2
Reputation: 204

Post » Mon Jul 03, 2017 3:11 pm

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
B
20
S
8
G
3
Posts: 457
Reputation: 4,053


Return to How do I...?

Who is online

Users browsing this forum: beguinner and 0 guests