How do I create sprites thats contains number to operate?

Get help using Construct 2

Post » Tue Sep 01, 2015 6:38 pm

Hello, I want to create objects that can to be operated like,for example, sum, subtract, divide and multiply. The idea is the following one: A box that jumps must clash with coins (as mario bros). These coins have numbers as for example as 2. After must hit with another coin with an operator as +, then must hit with another coin with the second number as 3. Finally 2 coins must appear with 2 possible solutions, example 5 and 7. If it hits with the coin that contains 5, the game continues, if it hits with the coin that contains 7, the game ends. ¿How I can assign numbers to the sprites of coins that can operate and give a result?

Thats is an example (the image not shows complete, please open the image in other tab)
Image

Thanks
Last edited by crynof on Wed Sep 02, 2015 12:13 am, edited 1 time in total.
B
4
Posts: 50
Reputation: 290

Post » Tue Sep 01, 2015 9:53 pm

Use "instance variables" on those sprites, then you can add, subtract, etc on those variables of any given sprite instance.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Wed Sep 02, 2015 12:48 am

Thanks you, but ¿ is posible use a randoms numbers assigned to sprites?, for example once time the first coin gets 2 and in other moment gets 5, currently when the game restart. I not want create sprites of numbers, because when i operate for example 3 x 6, this result give 18, and i cannot to create a sprite for each number of range 1-100. For this raeson i want to asign random values in coins.
Is possible?
B
4
Posts: 50
Reputation: 290

Post » Wed Sep 02, 2015 8:44 pm

Something like this?

Image

Example.capx
Image
B
63
S
23
G
7
Posts: 1,479
Reputation: 10,784

Post » Thu Sep 03, 2015 5:32 pm

Yea, you can do anything you want with those variables (within the typing constraints).

random() is a good system expression to learn.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822


Return to How do I....?

Who is online

Users browsing this forum: Apollo14, Meqara, mrkaio and 2 guests