Difference between revisions of "love.scene"

(Documentation and source code)
 
Line 42: Line 42:
 
{{#set:Keyword=Framework}}
 
{{#set:Keyword=Framework}}
 
[[Category:Libraries]]
 
[[Category:Libraries]]
 
== Other Languages ==
 
{{i18n|profile}}
 

Latest revision as of 09:16, 9 October 2024

love.scene

love.scene is a two-dimensional scene graph library written for the LÖVE game framework (compatible with LÖVE 11.3, 11.4 and 11.5). To install the scene graph, copy the "scene" folder to your game directory and use require:

love.scene = require("scene")

Usage

The scene graph is fairly minimal, relying on just four different types of objects. Scene nodes are created using two different methods:

local view = love.scene.newView()
-- object-oriented style
local s1 = view:newSprite(0, 0)
-- Love2D style
local s2 = love.scene.newSprite(0, 0)
s2:setParent(view)

Images, text and other types of drawable graphics are rendered as follows:

-- image
local image = love.graphics.newImage("mytexture.png")
s1:setGraphic(image)
-- text
local font = love.graphics.getFont()
local text = love.graphics.newText(font, "Hello world")
s2:setGraphic(text)

function love.draw()
  view:draw()
end


Documentation and source code

https://github.com/2dengine/love.scene

https://2dengine.com/doc/scene.html