PDA

View Full Version : attaching object help


shrijani
01-29-2009, 10:09 AM
Hello,

I'm using the code in http://board.flashkit.com/board/show...hlight=falling for my catch game. At the moment the objects are falling from the sky and disappearing when they hit to my object (which is a stick) What I want to do is to catch the objects and stack them on top of each other on the stick, and make them move together with the stick to catch new objects.

Can someone help me please?

Thank you.

pradvan
01-29-2009, 03:07 PM
Post your fla/code

shrijani
01-29-2009, 03:34 PM
I'm sorry, the correct link is: http://board.flashkit.com/board/showthread.php?t=786723

The code looks like this:

Actionscript on Fr 1 On main _root timeline:



//this produces random balls that fall from the sky
depth = 0;
allBalls = new Array();
function makeNewClip() {
clearInterval(ranID);
ran = (Math.random()*250)+500;
ranID = setInterval(makeNewClip, ran);
newClip = _root.attachMovie('good', 'good'+depth, depth++);
allBalls.push(newClip);
//trace(allBalls);
newClip._x = 140 + Math.random()* 430;
newClip._y = -50;
newClip.speed = (Math.random()*5)+5;
newClip.onEnterFrame = function() {
this._y += this.speed;
if (this._y>Stage.height) {
updateScore(-2);
for (i=0; i<allBalls.length; i++) {
if (this == allBalls[i]) {
allBalls.splice(i, 1);
//trace(allBalls)
}
}
this.removeMovieClip();
}
};
}

//

makeNewClip();
//


//
_root.createEmptyMovieClip('watchCollision', -2);
watchCollision.onEnterFrame = function() {
for (i=0; i<allBalls.length; i++) {
if (allBalls[i].hitTest(cocktail_mc._x, cocktail_mc._y, true)) {
//trace('we hit the cocktail');
allBalls[i].removeMovieClip();
allBalls.splice(i, 1);
updateScore(5);
}
}
};
score = 0;
function updateScore(amount) {
score += amount;
score_txt.text = 'Score is '+score;
}
updateScore(0);



//Actionscript on slider MC, my slider MC is called 'cocktail':


onClipEvent (load) {
power = 0.5;
yspeed = 0;
xspeed = 10;
friction = 0.95;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
xspeed *= friction;
yspeed *= friction;
_y += yspeed;
_x += xspeed;
}

My question is, how to stick the objects on top of each other, and move them together with the slider..

shrijani
01-30-2009, 08:58 AM
anyone??