1 decade 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?
I appreciate everyones help with making me less derpy with this stuff.
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.