[TinyECS] Filtering Doesn't Work
Posted: Mon Feb 01, 2021 4:44 am
Hi, Everyone. I'm currently learning to use the ECS system. I'm using Tiny ECS.
But I am stuck on why my code doesn't work. I have Googled for answers, but no results.
When I gives filter to the Tiny world update, it doesn't work. But If I removed the filter, it works. Am I using the filter correctly?
Thanks.
But I am stuck on why my code doesn't work. I have Googled for answers, but no results.
When I gives filter to the Tiny world update, it doesn't work. But If I removed the filter, it works. Am I using the filter correctly?
Thanks.
Code: Select all
local tiny = require("lib/tiny")
local debugRenderSystem = tiny.processingSystem()
debugRenderSystem.filter = tiny.requireAll('debugRenderable','position','size')
function debugRenderSystem:process(e, dt)
love.graphics.rectangle('line',e.position.x,e.position.y,e.size.width,e.size.height)
end
local bird = {
position = {x = 100, y = 200},
size = {width = 30, height = 20},
debugRenderable = true,
}
local world = tiny.world()
tiny.addEntity(world, bird)
tiny.addSystem(world, debugRenderSystem)
-- Main draw callback
function love.draw()
local dt = love.timer.getDelta()
-- This next line doesn't work
tiny.update(world, dt, tiny.filter('debugRenderable') )
-- But, if no filter applied, it works
-- tiny.update(world, dt )
end