Jump to content
Exile03330

Example Spriter/Capx using animation Events/Variables

Recommended Posts

Hello,

 

I posted this topic in the Scirra forums too. (https://www.scirra.com/forum/viewtopic.php?t=154034)

 

Does anyone have an example of using the Spriter animation variables with Construct 2? I am able to get Events to trigger in C2 and tags to work. However, I am having trouble getting expected variable values. The variables that I set are in the meta data section at the bottom of the time line. Oh at one point I had an integer that for some reason incremented throughout the animation, but I dont know why. All I did was change the current value a couple different times on key frames. 

 

I am trying to have an Event fire a couple time throughout the animation and on the same key frame to change a variable. So in C2 I can get the variable value when it changes with the Event trigger.

 

An example with a couple variable types that change over the animation would be greatly appreciated or a link to an example capx! 

 

Thanks! 

Share this post


Link to post
Share on other sites

Hi again Exile03330,

Here are a few facts which might help you get things working he way you'd like.

1) Numerical variables set in Spriter that are different from each other in different key frames actually TWEEN in value over time from one keyframe to the next. For example, if you have a value called HEAT and its set to zero in the first keyframe and ten in the next keyframe, then halfway between both keyframes the variable HEAT would have a value of 5

2) To retrieve metadata (a variable) from a specific object as opposed to the entire animation then you need the following: .val("mult","UPDATED") just using : .val("mult") looks for a variable in the main animation called "mult" in your Spriter file, which does not exist.

3) Because you already are using a text (string) based variable type in Spriter, you do not need to use the "str()" function in C2, which is used to convert numeric values to strings.

4) IMPORTANT! You found a legitimate bug in the plug-in relating to variables which Edgar has fixed, he'll post the fix shortly. Basically it was what was causing the value of 3 to not trigger at the beginning of the animation.

Here's a tweaked capx which/ in combination with the update to the plug-in will fix your issues: https://dl.dropboxusercontent.com/u/61721248/FixedSpriterVariables.capx

cheers.

Share this post


Link to post
Share on other sites

Oh great!

 

1) The TWEEN in value you mention makes sense now :). At one point the integer value shown in the text box was counting up between values, but I wasn't sure why. I didn't realize it is supposed to. 

 

2) Aha, so that's how I can reference that particular value. I noticed you can have the same variable assigned to different objects, but didn't know how to get them. 

 

3) Right, I was doing that because at one point I was trying integers values.

 

4) Great! Speaking of bugs I have seen another. I can create a new post if need be.

 

             Just try to evaluate the Spriter_Object.key action. I wasn't sure what it is supposed to do so I set a text box to display Timer.key. I get an error when I launch it. Using C2 R213. 

 

Thanks for all your help!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...