ForumsProgramming ForumUnload some things outside of vcam but reload it once its in the screen view? (as2)

2 6396
mightybob
offline
mightybob
360 posts
Peasant

I'm trying to get it so anything some things (like enemies, coins, etc) get unloaded once outside of the vcam view, but once inside the view get reloaded so I don't get a ton of lag because of vcam loading everything at once.

Anyone?

Thanks!

  • 2 Replies
weirdlike
offline
weirdlike
1,299 posts
Prince

well this is what I do to calculate distance between the character and the enemy, maybe you could use it to set the range to the size of the screen then draw only if within range

//set the range
var range:Number = 300;

//calculate distance
var dist:Number = Math.sqrt(Math.pow(heroMC.x-enemyMC.x, 2)+Math.pow(heroMC.y-enemyMC.y, 2));

if(dist &lt range)
{
//do code here
}

all this needs to be in the loop function to work

mightybob
offline
mightybob
360 posts
Peasant

Thanks!

Showing 1-2 of 2