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

Get help using Construct 2

### » 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

### » 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
58
S
25
G
19
Posts: 304
Reputation: 13,858

### » 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,867

### » 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
141
S
31
G
88
Posts: 5,744
Reputation: 61,501

### » 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