I was making some code for the game I asked you about before, and I opted to make it a bit differently. The code makes 5 platforms once. Problem is, "thyPlatform"'s properties and methods seem to go away when the variable is assigned to a different platform; this means only one works, and causes the jumper to bounce. I also have some code for the class "Platform", but the hitTest seems not to work as simply as it does in the frame code.
_root.makePlatform = function(){
if (_root.make != true){
for (x = 0; x < 5; x += 1){
newPlatformNumber += 1;
_root.attachMovie("platform", "platform" + newPlatformNumber, 50+newPlatformNumber);
thyPlatform = eval("platform" + newPlatformNumber);
thyPlatform.onEnterFrame = function(){
thyPlatform.checkJumper();
}
thyPlatform.checkJumper = function(){
if (thyPlatform.hitTest(jumper._x, jumper._y, true) && (jumper.dy > 0)){
_root.boing = true;
trace(_root.boing);
}
}
_root.make = true;
}
}
}
Class:
class Platform extends MovieClip {
function Platform(){
_x = Math.random()*Stage.width;
_y = 400;
}
function checkJumper(){
if (
}
}