Skip to content

Class "Beam"⚓︎

An example mod using the Beam class can be found here.

This class provides more streamlined access to the BeamRenderer used internally for rendering cords, ie Evis, Gello, Vis Fatty, etc. Note that this is a low-level class that strictly handles rendering. We hope to later provide an extension of this class capable of handling the physics calculations and automatic point adjustment required for cords, but this is a complex system that will require a non-trivial amount of effort to implement.

Constructors⚓︎

Beam ()⚓︎

Beam Beam ( Sprite Sprite, int Layer, boolean UseOverlay, boolean UnkBool )⚓︎

Beam Beam ( Sprite Sprite, string LayerName, boolean UseOverlay, boolean UnkBool )⚓︎

Warning

The Sprite used in the Beam must be in the same "scope" as the Beam. For example, a global Sprite and local Beam works, but local Sprite and global Beam won't. They can also both be global/local or in the same table.

Example Code

Here is an example of how you would use this class:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
local spritesheetHeight = 64

local sprite = Sprite()
sprite:Load("gfx/1000.193_anima chain.anm2", true)
sprite:Play("Idle", false)

local layer = sprite:GetLayer("chain")
layer:SetWrapSMode(1)
layer:SetWrapTMode(0)

local chain = Beam(sprite, "chain", false, false)

mod:AddCallback(ModCallbacks.MC_PRE_PLAYER_RENDER, function(_, player)
    local origin = Isaac.WorldToScreen(Game():GetRoom():GetCenterPos())
    local target = Isaac.WorldToScreen(player.Position)
    local coord = target:Distance(origin)
    chain:Add(origin,0)
    chain:Add(target,coord)
    chain:Render()
end)

Functions⚓︎

Add ()⚓︎

void Add ( Vector Position, float SpritesheetCoordinate, float Width = 1.0 )⚓︎

void Add ( Point Point )⚓︎

Adds a point to the beam. Points are stored in order of adding.

Info

SpritesheetCoordinate is, to our current understanding, the Y position of the spritesheet that should be drawn by the time this Point is reached. For example, two points of 0 and 64 SpritesheetCoordinate will render the spritesheet starting from y 0 to y 64, while an additional third point of 0 will draw it in reverse from y 64 to y 0. Width acts as a multiplier for how wide the beam should be. A non-zero value will scale the spritesheet width accordingly. This is interpolated between points.


GetLayer ()⚓︎

int GetLayer ( )⚓︎


GetPoints ()⚓︎

Point[] GetPoints ( )⚓︎

Returns a table of the Points currently stored.


GetSprite ()⚓︎

Sprite GetSprite ( )⚓︎


GetUnkBool ()⚓︎

boolean GetUnkBool ( )⚓︎


GetUseOverlay ()⚓︎

boolean GetUseOverlay ( )⚓︎


Render ()⚓︎

void Render ( boolean ClearPoints = true )⚓︎


SetLayer ()⚓︎

void SetLayer ( int LayerID )⚓︎

void SetLayer ( string LayerName )⚓︎


SetPoints ()⚓︎

void SetPoints ( Point[] Points )⚓︎

Sets the Points used by this.


SetSprite ()⚓︎

void SetSprite ( Sprite Sprite )⚓︎

void SetSprite ( Sprite Sprite, string LayerName, bool UseOverlay )⚓︎

void SetSprite ( Sprite Sprite, int LayerID, bool UseOverlay )⚓︎


SetUnkBool ()⚓︎

void SetUnkBool ( boolean UnkBool )⚓︎


SetUseOverlay ()⚓︎

void SetUseOverlay ( boolean UseOverlay )⚓︎