-
Notifications
You must be signed in to change notification settings - Fork 8
Object Methods
- Moving
- Moving X/Y Separately
- Fading
- Scaling
- Vector Scaling
- Rotating
- Coloring
- Method Suffix "To" and "Rel"
- Method Suffix "Slow Down" and "Speed Up" (easing)
- Flipping/Additive-Blend (since Beta 3)
- Storyboard Loops
The following methods can modify an object, like a picture/an animation in the storyboard. Let's say we have defined a sprite with the name pic for the following examples.
Object pic = new Sprite("pic.jpg");move(int easing, int startTime, int endTime, int startX, int startY, int endX, int endY);Moves an object from a specific position to a specific position on the playfield.
Note: The size of the playfield is (640,480), with (0,0) being top left corner.
Optional parameters: easing, startTime, endTime, endX, endY
Examples:
pic.move(10,20); moves the picture to the position (10,20) at 0 ms (Usefull in at-blocks or in loops)
pic.move(100,10,20); moves the picture to the position (10,20) at 100 ms
pic.move(100,200,10,20,20,40); moves the picture from the position (10,20) to the position (20,40), animation starts at 100 ms and ends at 200 ms
pic.move(1, 100,200,10,20,20,40); the same as before, but now using an easing value of 1, which means "start the animation fast, then slow down with time"
pic.move(2, 100,200,10,20,20,40); the same as before, but now using an easing value of 2, which means "start the animation slowly, then speed up with time"
moveX(int easing, int startTime, int endTime, int startX, int endX);
moveY(int easing, int startTime, int endTime, int startY, int endY);Moves an object from a specific X/Y position to a specific X/Y position on the playfield.
Examples:
pic.moveX(0,100,50,70); moves the picture from x=50 to x=70, animation starts at 0 ms and ends at 100 ms
pic.moveY(100,200,10,20); moves the picture from y=10 to y=70, animation starts at 100 ms and ends at 200 ms
fade(int easing, int startTime, int endTime, float startOpacity, float endOpacity);Fades an object from a specific opacity to a specific opacity.
Note: Opacity = 0 means invisible, 1 means fully visible
Optional parameters: easing, startTime, endTime, endOpacity
Examples:
pic.fade(0.5); makes this picture 50% visible at 0 ms
pic.fade(100,0.5); makes this picture 50% visible at 100 ms
pic.fade(100,200,0,1); fades in the picture, animation starts at 100 ms and ends at 200 ms
scale(int easing, int startTime, int endTime, float startScaling, float endScaling);Scales an object from a specific scaling to a specific scaling.
Note: Scale = 0.5 means 50% size of the original picture, 1 means original size
Optional parameters: easing, startTime, endTime, endScale
Examples:
pic.scale(0.5); scales the picture to 50% of it's original size at 0 ms
pic.scale(100,0.5); scales the picture to 50% of it's original size at 100 ms
pic.scale(100,200,0,1); expand the picture to it's original size, animation starts at 100 ms and ends at 200 ms
scaleVec(int easing, int startTime, int endTime, float startXScaling, float startYScaling, float endXScaling, float endYScaling);Scales an object from a specific vector scaling to a specific vector scaling, which means you can change the scaling of the width and height separately.
Note: Scale = 0.5 means 50% size of the original picture, 1 means original size
Optional parameters: easing, startTime, endTime, endXScaling, endYScaling
Examples:
pic.scaleVec(0.5,1); scales the picture to 50% of it's original width and 100% of it's original height at 0 ms
pic.scaleVec(100,0.5,1); scales the picture to 50% and 100% of it's original height of it's original size at 100 ms
pic.scaleVec(100,200,0,1,1); expand the picture to it's original size, animation starts at 100 ms and ends at 200 ms
rotate(int easing, int startTime, int endTime, float startAngle, float endAngle);Rotates an object from a specific angle to a specific angle.
Note: Angle values are in radians, for a rotation of 180 degrees to the right, the correct value would be 3.1415 (Pi)
Optional parameters: easing, startTime, endTime, endAngle
Examples:
pic.rotate(3.1415); rotates the picture 180° to the right at 0 ms
pic.rotate(100,3.1415); rotates the picture 180° to the right at 100 ms
pic.rotate(100,200,-3.14,3.14); rotates the picture from 180° left to 180° right, animation starts at 100 ms and ends at 200 ms
color(int easing, int startTime, int endTime, int startRed, int startGreen, int startBlue, int endRed, int endGreen, int endBlue);Colors an object from a specific color to a specific color. Bright, grey-scale pictures are working well.
Note: Values from 0 to 255 can be used as colors.
Optional parameters: easing, startTime, endTime, endRed, endGreen, endBlue
Examples:
pic.color(128,255,0); colors the picture in the color (128,255,0) = green-yellow
pic.move(100,128,255,0); colors the picture in the color (128,255,0) at 100 ms
pic.move(100,200,255,0,0,0,255,0); colors the picture from (255,0,0) = red to (0,255,0) = green, animation starts at 100 ms and ends at 200 ms
get<Attribute>(time);With 0 parameters: Gets the last changed value for this attribute. This means the last command which changed this attribute.
With 1 parameter: Gets the value for this attribute at a specific time. If the time is "in the middle" of an animation, the value will be calculated exactly, also if this animation has 1 or 2 as the easing value.
Optional parameters: time
List of attributes:
- X, Y
- Scale, ScaleX, ScaleY
- Rotation, Opacity
- Red, Green, Blue
Note: This can be very usefull if you don't know the last position/scale/... of the object, e.g. if you chose random values in previous methods.
Examples:
pic.move(0,1000,10,50,20,60);
pic.getX(); // Returns 20
pic.getY(); // Returns 60
pic.getX(500); // Returns 15 ((10+20)/2)fliph(int startTime, int endTime);
flipv(int startTime, int endTime);
blenda(int startTime, int endTime);Flips a picture horizonally (fliph) or vertically (flipv), or makes an effect described as "additive-blend colour (as opposed to alpha-blend)", which means that the color values are "added", so the picture gets brighter.
Examples:
pic.fliph(0, 100); flips the picture horizontally, this lasts from 0 ms to 100 ms
startLoop(int startTime, int loopCount);
or
startTriggerLoop(Trigger trigger, int startTime, int endTime);
...
endLoop();Creates normal or triggered storyboard loops. Commands in the loop are timed non zero-based.
Note: For trigger loops, the following triggers can be chosen: HitSoundClap, HitSoundFinish, HitSoundWhistle, Passing, Failing
Example:
Object pic = new Sprite("pic.jpg");
pic.startLoop(100, 4);
pic.fade(100,600,1,0);
at (100) pic.scale(0,500,1,1.5);
pic.endLoop();This will return the following storyboard code:
Sprite,Foreground,Centre,"pic.jpg",320,240
L,100,4
F,0,0,500,1.0,0.0
S,0,0,500,1.0,1.5
Most of this commands are based and were specified in the "[Official Specifications] Storyboarding by Scripting" - Thread, written by Echo.