Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update outdated documentation for BitmapFrontEnd. #3313

Merged
merged 11 commits into from
Dec 12, 2024
81 changes: 41 additions & 40 deletions flixel/system/frontEnds/BitmapFrontEnd.hx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package flixel.system.frontEnds;

import openfl.display.BitmapData;
import flixel.graphics.FlxGraphic;
import flixel.graphics.frames.FlxFrame;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.FlxAssets;
import flixel.util.FlxColor;
import openfl.Assets;
import openfl.display.BitmapData;
#if FLX_OPENGL_AVAILABLE
import lime.graphics.opengl.GL;
#end
Expand Down Expand Up @@ -114,27 +114,27 @@ class BitmapFrontEnd
/**
* Check the local bitmap cache to see if a bitmap with this key has been loaded already.
*
* @param Key The string key identifying the bitmap.
* @return Whether or not this file can be found in the cache.
* @param key The key identifying the bitmap.
* @return Whether or not this file can be found in the cache.
*/
public inline function checkCache(Key:String):Bool
public inline function checkCache(key:String):Bool
{
return get(Key) != null;
return get(key) != null;
}

/**
* Generates a new BitmapData object (a colored rectangle) and caches it.
* Creates a new graphic of a colored rectangle and caches it.
*
* @param Width How wide the rectangle should be.
* @param Height How high the rectangle should be.
* @param Color What color the rectangle should be (0xAARRGGBB)
* @param Unique Ensures that the bitmap data uses a new slot in the cache.
* @param Key Force the cache to use a specific Key to index the bitmap.
* @return The BitmapData we just created.
* @param width How wide the rectangle should be.
* @param height How high the rectangle should be.
* @param color What color the rectangle should be (0xAARRGGBB).
* @param unique Ensures that the bitmap data uses a new slot in the cache.
* @param key Force the cache to use a specific Key to index the bitmap.
* @return The created graphic.
*/
public function create(Width:Int, Height:Int, Color:FlxColor, Unique:Bool = false, ?Key:String):FlxGraphic
public function create(width:Int, height:Int, color:FlxColor, unique = false, ?key:String):FlxGraphic
{
return FlxGraphic.fromRectangle(Width, Height, Color, Unique, Key);
return FlxGraphic.fromRectangle(width, height, color, unique, key);
}

/**
Expand All @@ -160,10 +160,10 @@ class BitmapFrontEnd
}

/**
* Caches specified FlxGraphic object.
* Caches the specified graphic.
*
* @param graphic FlxGraphic to store in the cache.
* @return cached FlxGraphic object.
* @param graphic The graphic to cache.
* @return The cached graphic.
*/
public inline function addGraphic(graphic:FlxGraphic):FlxGraphic
{
Expand All @@ -172,20 +172,21 @@ class BitmapFrontEnd
}

/**
* Gets FlxGraphic object from this storage by specified key.
* @param key Key for FlxGraphic object (its name)
* @return FlxGraphic with the key name, or null if there is no such object
* Gets an FlxGraphic object from this storage from its key.
*
* @param key The FlxGraphics key (or name).
* @return The FlxGraphic with the specified key, or null if the object doesn't exist.
*/
public inline function get(key:String):FlxGraphic
{
return _cache.get(key);
}

/**
* Gets key from bitmap cache for specified BitmapData
* Gets a key from a cached BitmapData.
*
* @param bmd BitmapData to find in cache
* @return BitmapData's key or null if there isn't such BitmapData in cache
* @param bmd BitmapData to find in the cache.
* @return The BitmapData's key or null if there isn't such BitmapData in cache.
*/
public function findKeyForBitmap(bmd:BitmapData):String
{
Expand All @@ -201,8 +202,8 @@ class BitmapFrontEnd
/**
* Helper method for getting cache key for FlxGraphic objects created from the class.
*
* @param source BitmapData source class.
* @return Full name for provided class.
* @param source BitmapData source class.
* @return Full name for provided class.
*/
public inline function getKeyForClass(source:Class<Dynamic>):String
{
Expand All @@ -212,12 +213,12 @@ class BitmapFrontEnd
/**
* Creates string key for further caching.
*
* @param systemKey The first string key to use as a base for a new key. It's usually an asset key ("assets/image.png").
* @param userKey The second string key to use as a base for a new key. It's usually a key provided by the user
* @param unique Whether generated key should be unique or not.
* @return Created key.
* @param systemKey The first string key to use as a base for a new key. It's usually an asset key ("assets/image.png").
* @param userKey The second string key to use as a base for a new key. It's usually a key provided by the user
* @param unique Whether generated key should be unique or not.
* @return Created key.
*/
public function generateKey(systemKey:String, userKey:String, unique:Bool = false):String
public function generateKey(systemKey:String, userKey:String, unique = false):String
{
var key:String = userKey;
if (key == null)
Expand All @@ -230,10 +231,10 @@ class BitmapFrontEnd
}

/**
* Gets unique key for bitmap cache
* Gets unique key for bitmap cache.
*
* @param baseKey key's prefix
* @return unique key
* @param baseKey key's prefix.
* @return unique key.
*/
public function getUniqueKey(?baseKey:String):String
{
Expand All @@ -260,11 +261,11 @@ class BitmapFrontEnd
* Generates key from provided base key and information about tile size and offsets in spritesheet
* and the region of image to use as spritesheet graphics source.
*
* @param baseKey Beginning of the key. Usually it is the key for original spritesheet graphics (like "assets/tile.png")
* @param frameSize the size of tile in spritesheet
* @param frameSpacing offsets between tiles in offsets
* @param region region of image to use as spritesheet graphics source
* @return Generated key for spritesheet with inserted spaces between tiles
* @param baseKey Beginning of the key. Usually it is the key for original spritesheet graphics (like "assets/tile.png").
* @param frameSize The size of tile in spritesheet.
* @param frameSpacing Offsets between tiles in offsets.
* @param region Region of image to use as spritesheet graphics source.
* @return Generated key for spritesheet with inserted spaces between tiles.
*/
public function getKeyWithSpacesAndBorders(baseKey:String, ?frameSize:FlxPoint, ?frameSpacing:FlxPoint, ?frameBorder:FlxPoint, ?region:FlxRect):String
{
Expand All @@ -287,7 +288,7 @@ class BitmapFrontEnd

/**
* Totally removes specified FlxGraphic object.
* @param graphic object you want to remove and destroy.
* @param graphic The object you want to remove and destroy.
*/
public function remove(graphic:FlxGraphic):Void
{
Expand All @@ -302,7 +303,7 @@ class BitmapFrontEnd

/**
* Totally removes FlxGraphic object with specified key.
* @param key the key for cached FlxGraphic object.
* @param key Key of the cached graphic.
*/
public function removeByKey(key:String):Void
{
Expand Down
Loading