class FunkinSprite
package funkin.graphics
extends FlxAnimate
extended by FlxVideo, ScriptedFunkinSprite, FunkinButton, HealthIcon, NoteSprite, StrumlineNote, StageProp, CharSelectGF, CharSelectPlayer, Lock, BaseFreeplayDJ, FreeplayLetter, InstrumentalSelector, StickerSprite
Available on all platforms
An FlxSprite with additional functionality. - A more efficient method for creating solid color sprites. - TODO: Better cache handling for textures.
Static methods
staticcreate(x:Float = 0.0, y:Float = 0.0, key:String):FunkinSprite
Create a new FunkinSprite with a static texture.
Parameters:
x | The starting X position. |
|---|---|
y | The starting Y position. |
key | The key of the texture to load. |
Returns:
The new FunkinSprite.
staticcreatePacker(x:Float = 0.0, y:Float = 0.0, key:String):FunkinSprite
Create a new FunkinSprite with a Packer atlas animated texture.
Parameters:
x | The starting X position. |
|---|---|
y | The starting Y position. |
key | The key of the texture to load. |
Returns:
The new FunkinSprite.
staticcreateSparrow(x:Float = 0.0, y:Float = 0.0, key:String):FunkinSprite
Create a new FunkinSprite with a Sparrow atlas animated texture.
Parameters:
x | The starting X position. |
|---|---|
y | The starting Y position. |
key | The key of the texture to load. |
Returns:
The new FunkinSprite.
staticcreateTextureAtlas(x:Float = 0.0, y:Float = 0.0, key:String, ?assetLibrary:String, ?settings:Null<AtlasSpriteSettings>):FunkinSprite
Create a new FunkinSprite with an Adobe Animate texture atlas.
Parameters:
x | The starting X position. |
|---|---|
y | The starting Y position. |
key | The key of the texture to load. |
Returns:
The new FunkinSprite.
Constructor
new(x:Float = 0, y:Float = 0, ?path:String, ?atlasSettings:Null<AtlasSpriteSettings>)
Parameters:
x | Starting X position |
|---|---|
y | Starting Y position |
path | The asset path for the graphic |
atlasSettings | The optional settings for the texture atlas |
Methods
clone():FunkinSprite
Ensure scale is applied when cloning a sprite.R
The default clone() method acts kinda weird TBH.
Returns:
A clone of this sprite.
getDefaultAtlasSettings():AtlasSpriteSettings
Gets the default settings for a texture atlas sprite.
Returns:
The default settings for a texture atlas sprite.
getFirstElement(symbol:String):Null<Element>
Returns the first element of a symbol in the atlas.
Parameters:
symbol | The symbol to get elements from. |
|---|
Returns:
The first element of the symbol. WARNING: Can be null.
getFrameLabel(name:String):Null<Frame>
Gets a frame label by its name.
Parameters:
name | The name of the frame label to retrieve. |
|---|
Returns:
The frame label, or null if it doesn't exist.
getFramesWithKeyword(keyword:String):Array<Frame>
Gets every frame on every symbol that starts with the given keyword.
Parameters:
keyword | The keyword to search for. |
|---|
Returns:
An array of frames.
getSymbolElements(symbol:String):Array<Element>
Returns the elements of a symbol in the atlas.
Parameters:
symbol | The symbol to get elements from. |
|---|
hasAnimation(id:String):Bool
Whether or not this sprite has an animation with the given ID.
Parameters:
id | The ID of the animation to check. |
|---|
isAnimationDynamic(id:String):Bool
Parameters:
id | The animation ID to check. |
|---|
Returns:
Whether the animation is dynamic (has multiple frames). false for static, one-frame animations.
loadBitmapData(input:BitmapData, cache:Bool = true):FunkinSprite
Apply an OpenFL BitmapData to this sprite.
Parameters:
input | The OpenFL |
|---|
Returns:
This sprite, for chaining
loadPacker(key:String):FunkinSprite
Load an animated texture (Packer atlas spritesheet) as the sprite's texture.
Parameters:
key | The key of the texture to load. |
|---|
Returns:
This sprite, for chaining.
loadSparrow(key:String):FunkinSprite
Load an animated texture (Sparrow atlas spritesheet) as the sprite's texture.
Parameters:
key | The key of the texture to load. |
|---|
Returns:
This sprite, for chaining.
loadTexture(key:String):FunkinSprite
Load a static image as the sprite's texture.
Parameters:
key | The key of the texture to load. |
|---|
Returns:
This sprite, for chaining.
loadTextureAtlas(key:Null<String>, ?assetLibrary:String, ?settings:Null<AtlasSpriteSettings>):FunkinSprite
Loads an Adobe Animate texture atlas as the sprite's texture.
Parameters:
key | The key of the texture to load. |
|---|---|
settings | Additional settings for loading the atlas. |
Returns:
This sprite, for chaining.
loadTextureBase(input:TextureBase):Null<FunkinSprite>
Apply an OpenFL TextureBase to this sprite.
Parameters:
input | The OpenFL |
|---|
Returns:
This sprite, for chaining
makeSolidColor(width:Int, height:Int, color:FlxColor = FlxColor.WHITE):FunkinSprite
Acts similarly to makeGraphic, but with improved memory usage,
at the expense of not being able to paint onto the resulting sprite.
Parameters:
width | The target width of the sprite. |
|---|---|
height | The target height of the sprite. |
color | The color to fill the sprite with. |
Returns:
This sprite, for chaining.
replaceSymbolGraphic(symbol:String, ?graphic:FlxGraphicAsset, adjustScale:Bool = true):Void
Replaces the graphic of a symbol in the atlas.
Parameters:
symbol | The symbol to replace. |
|---|---|
graphic | The new graphic to use. |
adjustScale | Whether to adjust the scale of new frame to match the old one. |
scaleElement(element:Element, scale:Float, positionOffset:Float = 0, scaleEverything:Bool = false):Void
Scales an element by a certain multiplier.
Parameters:
element | The element to scale. |
|---|---|
scale | The scale multiplier. |
positionOffset | The offset to apply to |