-
Loading/Unloading
Hi, so in my game I got frame rate to smoothen out more using some techniques. Problem is it wont help forever because I am planning on making the world huge so im trying to think of a good way to hide/unhide tiles.
So far I tried alphaing out tiles that are not seen by the vcam that went horrible and turned out really laggy.
Than I tried making the vcam act as a giant hit test to my tiles making them go to a blank keyframe when not in use. That didn't really help.
I found how ever that like above ^ making tiles go to empty keyframes helps ALOT, but having the constant hit test uses alot of resources.
So please I cant go to much into code because its complicated, maybe ill have too but I need some ideas from you guys. Thanks.
if nothing works I am considering having a "room like design" example: I walk to the edge of the map I am now in the next map while the other one is gone etc. I don't think splitting maps though is a good user experience because in reality having a big map you can walk around in feels way better "I think".
-
I don't understand really well what you are trying to do, or what you really need, but reading your thread I suppose that's fixed removing the tiles movieclip when no using them, and attaching them when using them. attachMovie/removeMovieClip is the only option. Or you can have the tiles as an external .swf and loadMovie/unLoadMovie.
-
but will they remove and re attach in the same position as they were removed in?
-
Yeah, because you specify the last _x _y coordinates with a variable.
PHP Code:
//create
function create(){
_root.attachMovie("bookMC", "bookMC", _root.getNextHighestDepth());
bookMC._x=lastX
bookMC._y= lastY
bookMC.onPress=function(){
startDrag(this, false);
trace(bookMC._x);
trace(bookMC._y);
}
bookMC.onRelease=function(){
this.stopDrag();
lastX=bookMC._x
lastY=bookMC._y
}
}
//remove
function remove(){
bookMC.removeMovieClip();
}
//secondary buttons
buu.onPress=function(){
remove();
}
buu2.onPress=function(){
create();
}
In that example i made for you, there is 2 buttons, one creates a movieclip and the other removes it. When creating it, i tell flash that the _x and _y coordinates of my movieclip is equal to lastX and lastY.
Then, on my movieclip press it start Dragging it. When release, it stop dragging it and tell flash that lastX is equal to my movieclip's last _x and lastY is equal to my movieclip's last _y. So , i press the button for removing it, and when pressing the other button to re-attach it, TADA! My movieclip appears exactly where I left it!
-
Thanks dude! you are a boss.
-
For some reason its only outputting the books location but not really creating or destroying the book. Idk hmm
-
the function remove(){ bookMC.removeMovieClip();} MUST destroy the movieclip.
-
They aren't destroying it or creating it im positive I did it correctly, did you try using it?
-
:smoov: I got it working, thanks angel you the man