Forums

ForumsProgramming Forum

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

Posted Nov 10, '13 at 7:42pm

mightybob

mightybob

351 posts

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!

 

Posted Nov 12, '13 at 7:06pm

weirdlike

weirdlike

492 posts

Knight

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 < range)
{
     //do code here
}

all this needs to be in the loop function to work

 

Posted Nov 14, '13 at 8:38am

mightybob

mightybob

351 posts

Thanks!

 
Reply to Unload some things outside of vcam but reload it once its in the screen view? (as2)

You must be logged in to post a reply!