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

2 1903
mightybob
offline
mightybob
363 posts
Shepherd

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,309 posts
King

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
363 posts
Shepherd

Thanks!

Showing 1-2 of 2