Jephz
January 26th, 2009, 05:27 PM
Hey all, I'm trying to make a replaceable map system for my rpg so that the code could come out cleaner. So far, I'm having no luck with my current code:
function boundPlayer(mapHolder:MovieClip, playerShell:MovieClip) {
if (_root.playerShell.hitTest(_root.boundLeft)) {
_root.mapHolder._x += mapSpeed;
_root.playesce("Hit Left");
}
}
See, I'm going to have different maps on each frame but they are all going to have the same codes (scrolling, hittest etc.) so I don't want to have to type in the same code in each and every frame. So I figured, if I could just make one function and just replace the code's target, it'll be a whole lot cleaner. I'm not exactly sure how to do this other then have tons of variables. Is there any other way?
-Jephz
function boundPlayer(mapHolder:MovieClip, playerShell:MovieClip) {
if (_root.playerShell.hitTest(_root.boundLeft)) {
_root.mapHolder._x += mapSpeed;
_root.playesce("Hit Left");
}
}
See, I'm going to have different maps on each frame but they are all going to have the same codes (scrolling, hittest etc.) so I don't want to have to type in the same code in each and every frame. So I figured, if I could just make one function and just replace the code's target, it'll be a whole lot cleaner. I'm not exactly sure how to do this other then have tons of variables. Is there any other way?
-Jephz