[Solved]How do I - Math - Sprite.Count*10*SpriteVariable

Get help using Construct 2

Post » Thu Jul 16, 2015 7:52 pm

Could someone point me in the right direction as how I would do this?


I have a sprite, and this sprite has a variable (Level 1, 2, 3, etc)

I want to set a global variable = The amount of sprites on screen multiplied by 10, and then altered again by the sprite's variable.

I want level 1 = 10, 2 = 20, and so on.

I used = sprite.Count*10*sprite.level but nothing seems to be changing after the 10, no matter what I input, so I'm going to assume I'm doing it wrong.
Last edited by SwatHound on Mon Jul 20, 2015 5:57 pm, edited 1 time in total.
B
6
S
2
Posts: 60
Reputation: 1,242

Post » Thu Jul 16, 2015 9:50 pm

Well, the expression seems accurate enough, the only thing I can think of is if you have multiple of the same sprite from the get go, only the variable of (IIRC) the oldest one will be taken into account. So if you have 2 sprites and the initial value of the first one is level=1, and the second one is level=2, the expression will calculate as 2*10*1. This shouldn't be a problem if you're changing the value through events.

I *think*.
B
53
S
24
G
18
Posts: 295
Reputation: 13,115

Post » Fri Jul 17, 2015 9:03 pm

Did you assign the sprite.level variable somewhere? What is it's value by default?
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"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
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Sat Jul 18, 2015 6:07 am

Ensure they are all numerical by forcing to Int() maybe?

Although "enemy1.Count*10*Level" works for me (Level is the Global holding current level value).

Maybe show your .capx or event sheet?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
87
Posts: 5,490
Reputation: 60,266

Post » Mon Jul 20, 2015 5:57 pm

Thank you guys for replying, I think its working, but to be honest I don't know why.

I think I just had to make sure I had both local variables and global variables set in place.

I think I just got ahead of myself before I actually set up the variables. Thanks again guys.
B
6
S
2
Posts: 60
Reputation: 1,242


Return to How do I....?

Who is online

Users browsing this forum: DolyGamesCosmos and 26 guests