Advanced Interpolation Plugin

Introduction

The Advanced Interpolation Plugin is a plugin which is designed to simplify advanced interpolation between States. This plugin provides numerous interpolation methods which are applied using the standard InterpolateBetween method provided by Glue. The logic generated by this plugin is available through an overload to the InterpolateToState method.

Just like the regular InterpolateToState method, the method generated by this plugin needs to only be called one time and interpolation will automatically happen over time with no additional custom code needed. In other words, if you are familiar with the InterpolateToState method provided by Glue, you will find this method very similar in usage.

What is State Interpolation?

If you have been using Glue for your projects then you may be familiar with states. If not, you should start by checking out the States page.

Since states can set numerical values, that means that multiple states can be combined to create an intermediary state at runtime. For example, consider a State called “Transparent” which sets the Alpha on a Sprite to 0. Also, consider a second State called “Opaque” which sets the Alpha on a Sprite to 1. These two states can be combed to create values inbetween 0 and 1 for the Sprite’s Alpha. This is the basics behind State Interpolation. For a more complete discussion, see this page and this page.

What Are the Different Kinds of Interpolations

A visualization of the different interpolations can be found on this page.

Obtaining the Plugin

To obtain this plugin, follow this link to GlueVault:

http://www.gluevault.com/plug/69-advanced-state-interpolation-plugin

Once you have downloaded the plugin, it installs just like any other plugin. More information can be found here.

Creating Interpolation Endpoints

Interpolation endpoints are the “start” and “end” of your interpolation. These endpoints are defined using states. For example, you may expose the X value on an Entity, create two states – each of which sets a different X value. Once this is done, you can interpolate between the two states. Common values used in interpolation are:

  • Position values such as X, Y, and Z
  • Alpha values for fading out/in
  • Rotation values
  • Scale values

Enabling Advanced Interpolation

The first step in using advanced interpolation is to enable it on a given Screen/Entity. Since the presence of advanced interpolation adds a small amount of overhead, it must be manually added to Entities/Screens which need it. To add advanced interpolation, set the “HasAdvancedInterpolation” property to true in Glue:

HasAdvancedInterpolation.PNG

Previewing Advanced Interpolation

Once you have created states which represent the “endpoints” (in other words the start and end of how interpolation should appear) of your interpolation, you will be able to preview these in GlueVault.

The first step is to create states which can be interpolated between. For more information on how to create states, see this section in the Beefball tutorials and this general tutorial page.

The next step is to open GlueView and navigate to the States UI. If you select the “Interpolate Between:” option and have set HasAdvancedInterpolation to true, you will see some additional UI for viewing interpolation:

AdvancedInterpolationInGView.png

Once you have set up the two states you want to interpolate between, you can click the button to start the tween. Also, changing the amount of time that the interpolation is to take (the text box to the left of the “Start Tween” button) will make the interpolation be displayed.

GlueView will display the code that is used to play the interpolation below in a text box. This text can be copied and pasted into any function in the current Entity to perform the interpolation. Encapsulating this in a method makes it easy to change in the future and easy to call on the instance:

PastedInterpolationCode.png

Additional Information

Code Reference