Hi
I’m actually programming a little flash game. The principle : some clothes come from the upper left on a rod, and fall when their x position match with a random x. The player must catch them by moving a basket on the x axis.
My problem : clothes fall with various speeds, sometimes all at the same time. Some even stop in their fall and then move again on the x axis. Furthermore, it seems that only one object on two can be catched up, the other goes through the basket.
The code :
first image
var i:Number = 0;
var acc:Number = 0.01;
var score:Number = 0;
var malus:Number = 0;
var num:Array = new Array();
var xDrop:Array = new Array();
var speed:Array = new Array();
var points:Array = new Array();
points[0] = 10; // tshirt
points[1] = 25; // short
points[2] = 50; // jeans
points[3] = 5; // underwear
basket.onEnterFrame = function() {
basket._x = _xmouse - (basket._width /2);
}
2nd image
i++;
speed* = 0;
num = Math.round(Math.random()*1);
xDrop* = Math.round(Math.random()*750);
if (xDrop* <= 50) xDrop*=50;
attachMovie("dress"+num, "dress"+i, i);
var currentDress:MovieClip = _root["dress"+i];
currentDress._y = (currentDress._height/2) + 10;
currentDress.onEnterFrame = function() {
if(this._x < xDrop*) this._x += 4;
else {
this.gotoAndStop(this._currentframe);
speed* += acc*this._y;
this._y += speed*;
if(this._y >= 700) {
removeMovieClip(this);
malus += points[num*];
}
if(this._y >= (basket._y - (basket._height/2)) && this._x > (basket._x - (basket._width/2)) && this._x < (basket._x + (basket._width/2))) {
removeMovieClip(this);
score += points[num*];
}
}
}
On the third image, there’s a short temporization (for the moment I use the timeline), then I go back to the 2nd image.
That’s all, hope I’ve been clear enough, it’s not easy to explain, especially as I’m french. If anyone can see where the problem is, because I’m completely stuck in !
Thanx in advance !