-
Notifications
You must be signed in to change notification settings - Fork 35
Sprite Methods
Before sprites can be created, a layer must be retrieved with the GetLayer(name) method. Layers are used to organize sprites of an effect, making groups of sprites reorderable in the editor.
Sprites can be created from that layer with the following method:
CreateSprite(path, layer, origin, initialPosition);
Example:
var layer = GetLayer("Main");
var sprite = layer.CreateSprite("bg.jpg");
Change the position of a sprite over time. Commands similar to MoveX are available for MoveY.
Move(easing, startTime, endTime, startPosition, endPosition)
Move(easing, startTime, endTime, startX, startY, endX, endY)
Move(startTime, endTime, startPosition, endPosition)
Move(startTime, endTime, startX, startY, endX, endY)
Move(time, position)
Move(time, x, y)
MoveX(easing, startTime, endTime, startX, endX)
MoveX(startTime, endTime, startX, endX)
MoveX(time, x)
Change the size of a sprite over time. 1 is the normal size, 0.5 is half the size and 2 is twice the normal size.
Scale(easing, startTime, endTime, startScale, endScale)
Scale(startTime, endTime, startScale, endScale)
Scale(time, scale)
ScaleVec(easing, startTime, endTime, startScale, endScale)
ScaleVec(easing, startTime, endTime, startX, startY, endX, endY)
ScaleVec(startTime, endTime, startScale, endScale)
ScaleVec(startTime, endTime, startX, startY, endX, endY)
ScaleVec(time, scale)
ScaleVec(time, x, y)
Turn a sprite over time. Angles are in radians.
Rotate(easing, startTime, endTime, startRotation, endRotation)
Rotate(startTime, endTime, startRotation, endRotation)
Rotate(time, rotation)
Change the opacity of a sprite over time. 1 is fully visible and 0 is not visible.
Fade(easing, startTime, endTime, startOpacity, endOpacity)
Fade(startTime, endTime, startOpacity, endOpacity)
Fade(time, opacity)
RGB coloring: red green and blue are between 0 and 1.
Color(easing, startTime, endTime, startColor, endColor)
Color(easing, startTime, endTime, startRed, startGreen, startBlue, endRed, endGreen, endBlue)
Color(startTime, endTime, startColor, endColor)
Color(startTime, endTime, startRed, startGreen, startBlue, endRed, endGreen, endBlue)
Color(time, color)
Color(time, red, green, blue)
HSB coloring: hue is an angle from 0 to 360°, saturation from 0.0 to 1.0 and brightness from 0.0 to 1.0. This is a much more convenient color space to pick colors, see https://en.wikipedia.org/wiki/HSL_and_HSV.
ColorHsb(easing, startTime, endTime, startHue, startSaturation, startBrightness, endHue, endSaturation, endBrightness)
ColorHsb(startTime, endTime, startHue, startSaturation, startBrightness, endHue, endSaturation, endBrightness)
ColorHsb(time, hue, saturation, brightness)
Flip a sprite horizontally/vertically or activates additive mode.
FlipH(startTime, endTime)
FlipV(startTime, endTime)
Additive(startTime, endTime)
Repeat commands loopCount times until EndGroup() is called.
Command times inside the loop are relative to the startTime of the loop.
LoopCommand StartLoopGroup(startTime, loopCount)
Example:
sprite.StartLoopGroup(0, 10);
sprite.Fade(0, 500, 1, 0);
sprite.Fade(500, 1000, 0, 1);
sprite.EndGroup();
Loop (L) Command on osu!'s wiki
Commands declared until EndGroup() is called will be active on the sprite when the triggerName event happens.
Command times inside the loop are relative to the time at which the trigger is triggered.
TriggerCommand StartTriggerGroup(triggerName, startTime, endTime, group)
Example:
sprite.StartTriggerGroup("HitSoundFinish", 0, 10000);
sprite.Fade(0, 500, 1, 0);
sprite.EndGroup();
Trigger (T) Command on osu!'s wiki
The following methods can be used to retrieve the state of a sprite at a specific time. These do not take into account unfinished loops (for which EndGroup() hasn't been called yet) or triggers.
PositionAt(time)
ScaleAt(time)
RotationAt(time)
OpacityAt(time)
ColorAt(time)
AdditiveAt(time)
FlipHAt(time)
FlipVAt(time)
Need help with something that isn't in the wiki? Try contacting Damnae in osu! or Discord.