mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-09-12 05:07:06 +00:00
add docs
This commit is contained in:
parent
ace89a44a5
commit
7c46bcb707
|
@ -8,6 +8,9 @@ import flixel.FlxCamera;
|
||||||
import openfl.Lib;
|
import openfl.Lib;
|
||||||
import openfl.display3D.textures.TextureBase;
|
import openfl.display3D.textures.TextureBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single frame buffer. Used by `FrameBufferManager`.
|
||||||
|
*/
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +40,7 @@ class FrameBuffer
|
||||||
public function create(width:Int, height:Int, bgColor:FlxColor):Void
|
public function create(width:Int, height:Int, bgColor:FlxColor):Void
|
||||||
{
|
{
|
||||||
dispose();
|
dispose();
|
||||||
final c3d = Lib.current.stage.context3D;
|
texture = Lib.current.stage.context3D.createTexture(width, height, BGRA, true);
|
||||||
texture = c3d.createTexture(width, height, BGRA, true);
|
|
||||||
bitmap = BitmapData.fromTexture(texture);
|
bitmap = BitmapData.fromTexture(texture);
|
||||||
camera.bgColor = bgColor;
|
camera.bgColor = bgColor;
|
||||||
}
|
}
|
||||||
|
@ -88,13 +90,15 @@ class FrameBuffer
|
||||||
/**
|
/**
|
||||||
* Unlocks the frame buffer and makes the bitmap ready to use.
|
* Unlocks the frame buffer and makes the bitmap ready to use.
|
||||||
*/
|
*/
|
||||||
@:access(flixel.FlxCamera)
|
|
||||||
public function unlock():Void
|
public function unlock():Void
|
||||||
{
|
{
|
||||||
bitmap.fillRect(new Rectangle(0, 0, bitmap.width, bitmap.height), 0);
|
bitmap.fillRect(new Rectangle(0, 0, bitmap.width, bitmap.height), 0);
|
||||||
bitmap.draw(camera.flashSprite, new Matrix(1, 0, 0, 1, camera.flashSprite.x, camera.flashSprite.y));
|
bitmap.draw(camera.flashSprite, new Matrix(1, 0, 0, 1, camera.flashSprite.x, camera.flashSprite.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diposes stuff. Call `create` again if you want to reuse the instance.
|
||||||
|
*/
|
||||||
public function dispose():Void
|
public function dispose():Void
|
||||||
{
|
{
|
||||||
if (texture != null)
|
if (texture != null)
|
||||||
|
@ -104,8 +108,13 @@ class FrameBuffer
|
||||||
bitmap.dispose();
|
bitmap.dispose();
|
||||||
bitmap = null;
|
bitmap = null;
|
||||||
}
|
}
|
||||||
|
spriteCopies.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a sprite copy to the frame buffer.
|
||||||
|
* @param spriteCopy the sprite copy
|
||||||
|
*/
|
||||||
public function addSpriteCopy(spriteCopy:SpriteCopy):Void
|
public function addSpriteCopy(spriteCopy:SpriteCopy):Void
|
||||||
{
|
{
|
||||||
spriteCopies.push(spriteCopy);
|
spriteCopies.push(spriteCopy);
|
||||||
|
|
|
@ -5,6 +5,9 @@ import openfl.display.BitmapData;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
import flixel.FlxCamera;
|
import flixel.FlxCamera;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manages frame buffers and gives access to each frame buffer.
|
||||||
|
*/
|
||||||
class FrameBufferManager
|
class FrameBufferManager
|
||||||
{
|
{
|
||||||
final camera:FlxCamera;
|
final camera:FlxCamera;
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package funkin.graphics.framebuffer;
|
package funkin.graphics.framebuffer;
|
||||||
|
|
||||||
import flixel.util.FlxColor;
|
|
||||||
import flixel.FlxCamera;
|
import flixel.FlxCamera;
|
||||||
import flixel.FlxSprite;
|
import flixel.FlxSprite;
|
||||||
|
import flixel.util.FlxColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A copy of a `FlxSprite` with a specified color. Used to render the sprite to a frame buffer.
|
||||||
|
*/
|
||||||
class SpriteCopy
|
class SpriteCopy
|
||||||
{
|
{
|
||||||
final sprite:FlxSprite;
|
final sprite:FlxSprite;
|
||||||
|
|
Loading…
Reference in a new issue