Skip to content

Commit

Permalink
How can I check if an object is on screen?
Browse files Browse the repository at this point in the history
  • Loading branch information
KilledByAPixel authored Nov 22, 2024
1 parent 985e5f6 commit c013c51
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ There is just an optional parameter you can pass to the tile function or to Tile
function tile(pos=vec2(), size=tileSizeDefault, textureIndex=0, padding=0)
```

### How can I check if an object is on screen?

You can use the isOverlapping function to check the object against the camera. For culling you maybe want to enlarge the object size slightly to account for attached objects or rotation, I usually do this.size.scale(2).

```javascript
if (!isOverlapping(this.pos, this.size, cameraPos, renderWindowSize))
return;
```

---

## Gameplay and Programming
Expand Down

0 comments on commit c013c51

Please sign in to comment.