Skip to content

Commit

Permalink
update the example
Browse files Browse the repository at this point in the history
  • Loading branch information
mreinstein committed Feb 9, 2024
1 parent b8bca6a commit 6297622
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ function rendererSystem (world) {
const RENDERABLE_FILTER = [ 'renderable' ]

// data structure to store all entities that were added or removed last frame
const resultEntries = {
const result = {
count: 0,
entries: new Array(100)
}

const onUpdate = function (dt) {

// optional 3rd parameter, can be 'added' or 'removed'. provides the list of entities that were
// optional 3rd parameter, can be 'added' or 'removed'. populates the list of entities that were
// added since the last ECS.cleanup(...) call
for (ECS.getEntities(world, RENDERABLE_FILTER, 'added', resultEntries)) {
// resultEntries will now be filled in with a reference to all entries added last frame
}

for (ECS.getEntities(world, RENDERABLE_FILTER, 'removed', resultEntries)) {
// resultEntries will now be filled in with a reference to all entries removed last frame
}

ECS.getEntities(world, RENDERABLE_FILTER, 'added', result)
for (let i=0; i < result.count; i++)
console.log('added new entity:', result.entries[i])
// result will be filled in with a reference to all entries removed last frame
ECS.getEntities(world, RENDERABLE_FILTER, 'removed', result)
for (let i=0; i < result.count; i++)
console.log('removed entity:', result.entries[i])
}

return { onUpdate }
Expand Down

0 comments on commit 6297622

Please sign in to comment.