Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

7 years ago by BBreitenbach

When I specify my own draw function, do I need to specify if the item should be draw only when visible to the player, or does the engine handle it automatically?

Right now, I did some testing with items outside of the screen area, and they still ran the draw function. I added some code to draw of my particles to reduce the counts, but the total draws still seems high. I figured it would shoot up when I removed my draw view area only code, but it hardly changed at all.

See below. Assuming my screen size is 960x720, and particles have an active/inactive state. Do I need to put the if statement, or is it handled automatically?

draw: function () {

if (this.active && this.pos.x > ig.game.screen.x && this.pos.y > ig.game.screen.y && this.pos.x < ig.game.screen.x + 960 && this.pos.y < ig.game.screen.y + 720) {

//DRAW STUFF
}
}

I appreciate everyones help with making me less derpy with this stuff.

7 years ago by Joncom

When I specify my own draw function, do I need to specify if the item should be draw only when visible to the player, or does the engine handle it automatically?
You shouldn't need to check that. It's handle automatically by the canvas itself. If you try drawing to the canvas "outside of the canvas", I believe it just disregards the command (and doesn't cost the same performance hit it otherwise would).
Page 1 of 1
« first « previous next › last »