I'm trying to edit the actionscript of catching game in which a object fall from top to bottom and if the catcher fail to catch the object and the object hit the bottom, the score is subtracted.
I got my code from http://flashgameu.com/Catching_Game_...12-131621.html
Here's the code
Help! It's for my final project.Code:package { import com.greensock.*; import flash.display.*; import flash.events.*; import flash.text.*; import flash.utils.Timer; import flash.utils.getDefinitionByName; public class CatchingSkittles extends MovieClip { var girlmouth:GirlMouth; var girlmouthfront:GirlMouthFront; var nextObject:Timer; var objects:Array = new Array(); var score:int = 0; const speed:Number = 7.0; public function CatchingSkittles() { girlmouthfront = new GirlMouthFront(); girlmouthfront.y = -49.00; girlmouth = new GirlMouth(); girlmouth.y = 308.55; addChild(girlmouth); girlmouth.addChild(girlmouthfront); setNextObject(); addEventListener(Event.ENTER_FRAME, moveObjects); } public function setNextObject() { nextObject = new Timer(1000+Math.random()*1000,1); nextObject.addEventListener(TimerEvent.TIMER_COMPLETE,newObject); nextObject.start(); } public function newObject(e:Event) { var goodObjects:Array = ["Red","Purple","Yellow","Orange","Green"]; if (Math.random() < .5) { var r:int = Math.floor(Math.random()*goodObjects.length); var classRef:Class = getDefinitionByName(goodObjects[r]) as Class; var newObject:MovieClip = new classRef(); newObject.typestr = "good"; } else { r = Math.floor(Math.random()*goodObjects.length); classRef = getDefinitionByName(goodObjects[r]) as Class; newObject = new classRef(); newObject.typestr = "good"; } newObject.x = Math.random()*500; addChild(newObject); objects.push(newObject); setNextObject(); } public function moveObjects(e:Event) { for(var i:int=objects.length-1;i>=0;i--) { objects[i].y += speed; if (objects[i].y > 425) { removeChild(objects[i]); objects.splice(i,1); } if (objects[i].hitTestObject(girlmouthfront)) { if (objects[i].typestr == "good") { score += 5; } else { score += 5; } if (score < 0) score = 0; scoreDisplay.text = "Score: "+score; removeChild(objects[i]); objects.splice(i,1); } } girlmouth.x = mouseX; } } }
In addition, how do I end the game after the catcher fail to catch at least 5 objects to go to "game over" screen with final score displayed?




Reply With Quote
