Can You Assign Values to Frames Inside a Sprite?

0 favourites
  • 11 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • 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:

    <img src="http://img.photobucket.com/albums/v322/cmagus/help-2_zps48d08199.png" border="0" />

    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.

  • 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.

  • Agree If all you want to pass is a number, then you can just use the frame number as the value.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the help I appreciate it.

  • 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

    <img src="http://img.photobucket.com/albums/v322/cmagus/stuck_zps1b3b1017.png" border="0" />

    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.

  • 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.

  • 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.

  • 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.

    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.

  • 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.

  • I could not open your capx sorry.

  • dragDropMatchFrame.capx (r125)

    I made one Numbers sprite with 9 frames. On drop -> compare Numbers.AnimationFrame to CoinsSprite.AnimationFrame. Also I just set the CoinsSprite to a random frame on start of layout. The way you were doing it (spawning when the layer was visible) was spawning CoinsSprites continuously.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)