snippet:
Usages:
1. enlarging or shrinking actors, For example, a very high resolution actor that is 4x the intended size. This will allow use of higher resolution sprites without using 4x thus helps to save some spaces also for custom-built zoom systems.
2. flipping actors; which is very useful for some background, we use this snippet to produce more tile directions and patterns back in the "infinite" scene generation which is still techinically finite, procedural generation for the tiles all versions. https://stencyl-nator.blogspot.com/p/endless-scenes.html
Pleasse take note that the flipping axis is set relative to the rotation of the actor. More about rotation:
In this case, flip on vertical axis, the axis will follow actor roitation.
codes and computational shortcuts
actor.growTo(-100/100, 100/100, time_sec * 1000, Easing.linear);
for instant scaling which is good for custom-built zoom systems.
Preview code: actor.growTo(-100/100, 100/100, 0, Easing.linear);
Preview code: actor.growTo(-100/100, 100/100, 0, Easing.linear);
computational shortcut level 1 , removing the dividing 100,
actor.growTo(-1, 1, 0, Easing.linear);
computational shortcut level 2 - not tested with flipping but works in normal usage.
actor.tweenProps.realScaleXY.tween(1,-1,1,1,null,0);
for case to double the actor size:
actor.tweenProps.realScaleXY.tween(1,2,1,2,null,0);
computational shortcut level 3 : expand actor.tweenProps.realScaleXY.tween(1,2,1,2,null,0);
actor.tweenProps.realScaleXY.endValue1 = 2;
actor.tweenProps.realScaleXY.endValue2 = 2;
actor.tweenProps.realScaleXY._tween(null,0);
computational shortcut level 4 expand actor.tweenProps.realScaleXY._tween(null,0);
requires import com.stencyl.easing.motion.TweenManager;
actor.tweenProps.realScaleXY.endValue1 = 2;
actor.tweenProps.realScaleXY.endValue2 = 2;
TweenManager.markActive(actor.tweenProps.realScaleXY);
actor.tweenProps.realScaleXY.easing = Easing.linear;// game crashes if the easing is not defined.
actor.tweenProps.realScaleXY.duration = 1; // game crashes of the duration is undefined or =0;
TweenManager.finish(actor.tweenProps.realScaleXY);
computational shortcut level 5: bypass TweenManager
actor.tweenProps.realScaleXY.endValue1 = 2;
actor.tweenProps.realScaleXY.endValue2 = 2;
actor.tweenProps.realScaleXY.easing = Easing.linear; // game crashes if the easing is not defined.
actor.tweenProps.realScaleXY.duration = 1; // game crashes of the duration is undefined or =0;
actor.tweenProps.realScaleXY.update(actor.tweenProps.realScaleXY.duration - actor.tweenProps.realScaleXY.time);
computational shortcut level 6 expand actor.tweenProps.realScaleXY.update...
actor.tweenProps.realScaleXY.endValue1 = 2;
actor.tweenProps.realScaleXY.endValue2 = 2;
actor.tweenProps.realScaleXY.easing = Easing.linear;
actor.tweenProps.realScaleXY.duration = 1; // the duration you set.
actor.tweenProps.realScaleXY.time = actor.tweenProps.realScaleXY.duration;
actor.tweenProps.realScaleXY.updateValue();
actor.tweenProps.realScaleXY.updated = true;
if(actor.tweenProps.realScaleXY.time >= actor.tweenProps.realScaleXY.duration) // uodate function
{
actor.tweenProps.realScaleXY.active = false;
actor.tweenProps.realScaleXY.finished = true;
if(actor.tweenProps.realScaleXY.onUpdate != null){actor.tweenProps.realScaleXY.onUpdate();}
if(actor.tweenProps.realScaleXY.onComplete != null){actor.tweenProps.realScaleXY.onComplete();}
}
else
{
if(actor.tweenProps.realScaleXY.onUpdate != null){actor.tweenProps.realScaleXY.onUpdate();}
}
computational shortcut level 7 bypass actor.tweenProps.realScaleXY.updateValue();
actor.tweenProps.realScaleXY.endValue1 = 2;
actor.tweenProps.realScaleXY.endValue2 = 2;
actor.tweenProps.realScaleXY.easing = Easing.linear;
actor.tweenProps.realScaleXY.duration = 1;
actor.tweenProps.realScaleXY.time = actor.tweenProps.realScaleXY.duration;
actor.tweenProps.realScaleXY.value1 = 2; // horizontal
actor.tweenProps.realScaleXY.value2 = 2; // vertical
actor.tweenProps.realScaleXY.updated = true;
if(actor.tweenProps.realScaleXY.time >= actor.tweenProps.realScaleXY.duration) // uodate function
{
actor.tweenProps.realScaleXY.active = false;
actor.tweenProps.realScaleXY.finished = true;
if(actor.tweenProps.realScaleXY.onUpdate != null){actor.tweenProps.realScaleXY.onUpdate();}
if(actor.tweenProps.realScaleXY.onComplete != null){actor.tweenProps.realScaleXY.onComplete();}
}
else
{
if(actor.tweenProps.realScaleXY.onUpdate != null){actor.tweenProps.realScaleXY.onUpdate();}
}
computational shortcut level 8 remove unwanted items.
Since this is an instant actor scaling, time, start and end is not needed. So does easing.
actor.tweenProps.realScaleXY.value1 = 3; // horizontal
actor.tweenProps.realScaleXY.value2 = 2; // vertoical.
if(actor.tweenProps.realScaleXY.onUpdate != null){actor.tweenProps.realScaleXY.onUpdate();} //does not work without this.
if(actor.tweenProps.realScaleXY.onComplete != null){actor.tweenProps.realScaleXY.onComplete();} //may reduce performance withoit this.


No comments:
Post a Comment