create objects dynamically

Get help using Construct 2

Post » Thu Oct 03, 2013 2:10 pm

to clarify the purpose of this application:

I am making a lottery picker where you select 4 numbers from 1 to 35 and press go, upon go I make a ajax request to my server who will respond with the winning combination, then a wining animation will be displayed on those winning numbers.
.
to make 35 buttons and have them highlighted when clicking is no problem but now I muust take result from server and generate selected winning numbers animation but how can I reach these objects who are all instances but have an instance variable (between 1 and 35 as identifier)
How do I capture an object based on instance variable?
B
9
S
2
Posts: 76
Reputation: 709

Post » Thu Oct 03, 2013 2:30 pm

What is the action you want to perform and what is the event that triggers that action?

Instead of using the name you use the instance variable.
Even simpler would be to make a function and add the variables as parameters.

So the winning numbers you get from your ajax request will be send to a function. This function will use those numbers to select the right buttons to play the animation.

You could also just choose to use the idea @sainsy gave. Use animationframes for the different numbers and check those against the winning numbers from your ajax request.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Oct 03, 2013 2:33 pm

It isn't that hard to do if you understand what you are doing.

system compare two values - Sprite.instancevariable = winning number - sprite set animation to "win"

Okay, you'd need a for each here to not have every sprite go to the animation win, but these are the basics.LittleStain2013-10-03 14:49:30
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Previous

Return to How do I....?

Who is online

Users browsing this forum: blackhornet, ezgaming420, marcinkowski and 2 guests