Can You Assign Values to Frames Inside a Sprite?

Get help using Construct 2

Post » Wed Apr 03, 2013 11:36 pm

I was wondering is it possible to give frames within a sprite values? Currently I am trying to figure out how to have the game check that when a number inside a box matches the value of an image on the screen (randomly generated) here is a screen for better context:



Basically what I am working on right now is giving the number on the bottom values 0-9 and when the piece is dragged and dropped it snaps into the box which is all set up and working. When the number snaps in I want it to check the value of the image above to see if they match or not and trigger a correct or wrong icon.

The random coin images are setup in a sprite. It then stops the animation and picks a random frame. Is assigning the values to those frames possible or would I need to go about this another way? Sorry my programming is very poor so I am not sure.
B
7
Posts: 18
Reputation: 486

Post » Thu Apr 04, 2013 12:18 am

The frames start counting at 0, so checking the Sprite.AnimationFrame value will give you the actual value also, assuming your frames are in order.
ImageImageImage
B
67
S
19
G
122
Posts: 3,206
Reputation: 73,399

Post » Thu Apr 04, 2013 1:03 am

Agree @blackhornet. If all you want to pass is a number, then you can just use the frame number as the value.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Apr 04, 2013 3:06 pm

Thanks for the help I appreciate it.
B
7
Posts: 18
Reputation: 486

Post » Tue Apr 09, 2013 10:56 pm

Hey guys I am still a bit stuck with this issue now for about 3 days and could use a little more help.I am still very confused how to approach this and I have been reading tutorials and watching videos but I really stuck.

Basically I've tried many things and right now what I have done is make each of the bottom numbers a variable and the coin is a sprite that randomizes. Now the issue I am still having is getting the number and sprite to check each other. I have it setup right now where when you drag a number to the box it snaps to the center and this is when I am trying to get it to check when the number is released to the box where the answer goes.

So with the first number I set it like this



Now when I place the number into the box it gives me the check mark that I want but it does that every time meaning it probably isn't reading anything just doing it as number 1 works on six. If anyone can help me out some more I would appreciate it.
B
7
Posts: 18
Reputation: 486

Post » Wed Apr 10, 2013 4:15 am

Not really sure what your having trouble with. Anyway you can post a capx?
Also if all you need to do is compare animation frames you can do it like this....example
Its set up so the bottom boxes are destroyed on mouse click if the animation frame number is equal to the frame number one on top.
I'm not certain this will be of much help, without seeing a capx, its a bit hard to determine.
B
20
S
2
Posts: 257
Reputation: 2,431

Post » Wed Apr 10, 2013 7:05 am

You could also assign an instance variable and set the frame based on that, I know it is sort of the reverse of what you are asking, but has the same end result, the frame is now tied to a value.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Wed Apr 10, 2013 11:35 pm

Thanks for that example I have not seen that one yet.That is along the lines of what I want to do. Mine is like that but drag and drop in the box but that will come in handy and should help.

I will also try your suggestion Blue as well thank you.

Here is my capx if you wanna see it.
https://www.dropbox.com/s/h20yzshqv81g3og/Trixie.capx
(This is an earlier build and only the counting section is enabled and art is alot of placeholders)

Thank you for all your help guys I really appreciate it. I know when I get things working I will write up a nice good tutorial for this stuff and share it with others who are figuring stuff like this out as well.

JustinR1232013-04-11 00:20:13
B
7
Posts: 18
Reputation: 486

Post » Thu Apr 11, 2013 2:47 pm

I made the example with the simple mouse click trigger, could probably be triggered a ton of ways. I'm going to go check your capx now.
B
20
S
2
Posts: 257
Reputation: 2,431

Post » Thu Apr 11, 2013 2:49 pm

I could not open your capx sorry.
B
20
S
2
Posts: 257
Reputation: 2,431

Next

Return to How do I....?

Who is online

Users browsing this forum: dieblume86, Kagubro and 2 guests