Kanzi  3.9.7
Kanzi Studio API
StateTransition Interface Reference

Configure transitions between states. More...

Inheritance diagram for StateTransition:
[legend]
Collaboration diagram for StateTransition:
[legend]

Public Member Functions

void ClearAnimations ()
 Deletes all animations in a state transition. More...
 
TransitionAnimation CreateAnimation (string targetPath, Property property)
 Creates an animation in a state transition. More...
 
void DeleteAnimation (TransitionAnimation animation)
 Deletes an animation from a state transition. More...
 

Properties

IEnumerable< TransitionAnimation > Animations [get]
 
StateTransitionAnimationType AnimationType [get, set]
 Gets or sets the easing function for the transition between states. More...
 
DirectionType Direction [get, set]
 Gets or sets whether the transition applies to the transition from the StartState to the EndState, or to the transitions from both states: More...
 
string DisplayText [get]
 
double Duration [get, set]
 Gets or sets the length of the transition between states in milliseconds. More...
 
State EndState [get, set]
 Gets or sets the state where the transition ends. More...
 
State StartState [get, set]
 Gets or sets the state from which the transition starts. More...
 
double StartTime [get, set]
 Gets or sets the start time of the transition. More...
 
InterruptTimePolicy TimePolicy [get, set]
 Gets or sets how how Kanzi handles interruption of the transition: More...
 

Detailed Description

Configure transitions between states.

When you configure transitions between states you can set the start and end states of a transition, transition duration, how you want Kanzi to handle interruptions of a transition, the direction to which the transition applies, and manage transition animations.

Examples

To configure a state transition:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named MyStateManager in the State Managers library.
var myStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Create a state group named MyStateGroup in the MyStateManager state manager.
var myStateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
myStateManager.GenerateUniqueChildName("MyStateGroup"),
myStateManager);
// Create five states in the MyStateGroup state group
var myStates = new List<State>();
for (int i = 0; i <= 4; i++)
{
myStates.Add(studio.ActiveProject.CreateProjectItem<State>(
myStateGroup.GenerateUniqueChildName("MyState" + i),
myStateGroup));
}
// Create a transition between the first and second state in the MyStateGroup state group.
var stateTransition = myStateGroup.CreateTransition(myStates[0], myStates[1]);
// Configure the transition between states you just created.
// Set the state from which the transition starts to the third state.
stateTransition.StartState = myStates[2];
// Set the state with which the transition ends to the fifth state.
stateTransition.EndState = myStates[4];
// Set the transition to last 1500 milliseconds.
stateTransition.Duration = 1500;
// Wait 1000 milliseconds before starting the transition.
stateTransition.StartTime = 1000;
// When an interruption occurs use the entire time set in the Duration to transition to the state.
stateTransition.TimePolicy = InterruptTimePolicy.COMPLETED_IF_INTERRUPTED;
// Make the transition only from the start state to the end state.
stateTransition.Direction = DirectionType.UNIDIRECTIONAL;
// Use the Smooth Step easing function for the transition.
stateTransition.AnimationType = StateTransitionAnimationType.SMOOTH_STEP;
}
See also
State, StateGroup, StateObject, StateBase, Project.StateManagerLibrary

Member Function Documentation

void ClearAnimations ( )

Deletes all animations in a state transition.

See also
DeleteAnimation
TransitionAnimation CreateAnimation ( string  targetPath,
Property  property 
)

Creates an animation in a state transition.

A state transition animation animates the value of a property in a node which the animation targets. Before you can create an animation in a state transition, make sure that both states in the state transition contain a state object which targets the same node and the same property.

Parameters
targetPathThe path to the node to which Kanzi applies the animation.
propertyThe property to which Kanzi applies the animation.
Returns
The transition animation.
See also
DeleteAnimation

Examples

To create an animation in a state transition:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.ActiveProject.StateManagerLibrary;
// Create a state manager named MyStateManager in the State Managers library.
var myStateManager = studio.ActiveProject.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Create a state group named MyStateGroup in the MyStateManager state manager.
var myStateGroup = studio.ActiveProject.CreateProjectItem<StateGroup>(
myStateManager.GenerateUniqueChildName("MyStateGroup"),
myStateManager);
// Create a state named MyState1 with a state object.
var myState1 = studio.ActiveProject.CreateProjectItem<State>(myStateGroup.GenerateUniqueChildName("MyState1"), myStateGroup);
var myStateObjectState1 = studio.ActiveProject.CreateProjectItem<StateObject>(
myState1.GenerateUniqueChildName("MyStateObject"),
myState1);
// Add the Node.Opacity property to the state object. This is the property you animate with the transition animation you create at the end of this snippet.
// If you do not set a value when you add a property, the property uses its default value. In this case, the value is 1.
// Leave the value of the property set to the default value. You set a different value in the other state object.
myStateObjectState1.AddProperty(Properties.NodeOpacity);
// Create a state named MyState2 with a state object.
var myState2 = studio.ActiveProject.CreateProjectItem<State>(myStateGroup.GenerateUniqueChildName("MyState2"), myStateGroup);
var myStateObjectState2 = studio.ActiveProject.CreateProjectItem<StateObject>(
myState2.GenerateUniqueChildName("MyStateObject"),
myState2);
// Add the Node.Opacity property to the state object.
myStateObjectState2.AddProperty(Properties.NodeOpacity);
// Set the value of the Node.Opacity property to 0.
myStateObjectState2.Set(Properties.NodeOpacity, 0);
// Create a transition between the MyState1 and MyState2 states in the MyStateGroup state group.
var stateTransition = myStateGroup.CreateTransition(myState1, myState2);
// Set the transition to last 1500 milliseconds.
stateTransition.Duration = 1500;
// Wait 2000 milliseconds before starting the transition.
stateTransition.StartTime = 2000;
// Create an animation which animates the value of the Node.Opacity property in the node to which you attach the state manager.
stateTransition.CreateAnimation(".", Properties.NodeOpacity);
}
void DeleteAnimation ( TransitionAnimation  animation)

Deletes an animation from a state transition.

Parameters
animationThe animation you want to delete from a state transition.
See also
ClearAnimations, CreateAnimation

Property Documentation

StateTransitionAnimationType AnimationType
getset

Gets or sets the easing function for the transition between states.

The type of the animation.

DirectionType Direction
getset

Gets or sets whether the transition applies to the transition from the StartState to the EndState, or to the transitions from both states:

  • UNIDIRECTIONAL applies the transition only to the transition from the StartState to the EndState.
  • BIDIRECTIONAL applies the transition to the transition from the StartState to the EndState, and from the EndState to the StartState.

The direction.

double Duration
getset

Gets or sets the length of the transition between states in milliseconds.

The duration.

State EndState
getset

Gets or sets the state where the transition ends.

The end state.

See also
StartState
State StartState
getset

Gets or sets the state from which the transition starts.

The start state.

See also
EndState
double StartTime
getset

Gets or sets the start time of the transition.

The start time.

InterruptTimePolicy TimePolicy
getset

Gets or sets how how Kanzi handles interruption of the transition:

  • COMPLETED_IF_INTERRUPTED uses the entire time set in the Duration to transition to the state after the interruption occurs.
  • ELAPSED_IF_INTERRUPTED uses only the remaining time set in the Duration to transition to the state after the interruption occurs.

The time policy.