Vote count:
0
So, I need to remove my frog, from a small flash game, after 3 times moving, I'm trying to do this with 'aantalGezwommen' and a function, sadly it doesn't work with the code now.
I can't figure it out, any of you got an idea?
I have included the whole code, so if something else is wrong, please tell :)
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.geom.Point;
public class KikkerOgen extends MovieClip {
var timer:Timer = new Timer(1000, 4);
var geknipperd:int = 0;
var hoevaakKnipperen:int = 0;
var aantalGezwommen:int = 0;
var score:int = 0;
//boompjes en bosjes
var object_1:Point = new Point(57,84);
var object_2:Point = new Point(500,86);
var object_3:Point = new Point(46,168);
var object_4:Point = new Point(479,126);
var object_5:Point = new Point(69,159);
var object_6:Point = new Point(443,162);
var object_7:Point = new Point(248,316);
var object_8:Point = new Point(209,198);
var object_9:Point = new Point(163,357);
var object_10:Point = new Point(440,283);
//constructor
public function KikkerOgen()
{
addEventListener(Event.ENTER_FRAME, Update);
addEventListener(MouseEvent.CLICK, isClicked);
timer.addEventListener(TimerEvent.TIMER, Knipperen);
timer.start();
gotoAndStop(13);
}
public function Update (event:Event)
{
trace(currentFrame);
}
//Score moet bij deze functie omhoog - document class
public function isClicked (event:MouseEvent):void
{
this.parent.removeChild(this);
}
//Hier telt hij het aantal keren dat de kikker moet knipperen
function Knipperen (event:TimerEvent):void
{
if (event.currentTarget.currentCount >= 2 && geknipperd < 3) {
geknipperd ++;
gotoAndPlay(1);
}
//Wanneer de kikker 3x geknipperd heeft moet hij naar een nieuwe positie
if (geknipperd == 3)
{
//Selecteer een random positie om heen te zwemmen
switch(Math.round(Math.random() * 10))
{
case 1:
x = object_1.x;
y = object_1.y;
break;
case 2:
x = object_2.x;
y = object_2.y;
break;
case 3:
x = object_3.x;
y = object_3.y;
break;
case 4:
x = object_4.x;
y = object_4.y;
break;
case 5:
x = object_5.x;
y = object_5.y;
break;
case 6:
x = object_6.x;
y = object_6.y;
break;
case 7:
x = object_7.x;
y = object_7.y;
break;
case 8:
x = object_8.x;
y = object_8.y;
break;
case 9:
x = object_9.x;
y = object_9.y;
break;
case 10:
x = object_10.x;
y = object_10.y;
break;
}
trace("posX:"+x);
trace("posY:"+y);
//Reset de timmer, het knipperen en laat hem opnieuw tellen om te verplaatsen.
geknipperd = 0;
trace(geknipperd);
//Tel hoevaak het kikkertje verplaatst is om de kikker bij 3x van stage te verwijderen.
if (aantalGezwommen < 3) {
aantalGezwommen++;
}
timer.reset();
timer.start();
}
}
//Wanneer de kikker 3x is verplaats verwijder hem uit het spel
function removeKikker ()
{
if (aantalGezwommen == 3)
{
this.parent.removeChild(this);
}
}
}
}
Apologies for the Dutch notes, things I need to remember :)
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire