PDA

View Full Version : problem with instances of movie clips



wellingtom
August 16th, 2008, 09:13 PM
Hello there**!!

I am making a side scrolling game, and I am having issues with the "recollection of coins" part.
I created a movie clip called "coin", and dragged and dropped 10 instances of that symbol to the scenario, I called all of them: "coin" (their instance names).

when the player jumps to get the coins, he just can get the first coin I called "coin"... If I try to get another coin, nothing happens... What am I doing wrong?

thanks a lot.

PLIP PLOP!!

TCAtect
August 17th, 2008, 03:14 PM
Naming multiple instances the same name is conflicting. Perhaps you can try defining a variable 'itemType="coin"' inside each instance, so the collision detection checks for that variable rather than the name. This would be one approach to the problem, but we can't know if it will work in your specific instance as you have not given the us the code to examine.

SparK_BR
August 17th, 2008, 06:19 PM
test collision with player by using

this.onEnterFrame = function(){
//collision with player test
}

in the first frame of the coin object
(all the instances will be updated automatically)

wellingtom
August 21st, 2008, 01:57 PM
SparK_BR!! I can't believe!!, it worked out!
I put this on the first frame of my movieClip:

this.onEnterFrame = function() {
if(_root.pelota.hitTest(this)){
this._visible=false;
}
}

and it worked out for all of the instances :hugegrin:
thanks a lot!

TCAtect: sorry for do not posting all the code, this was my first thread, so I go learning...

PLIP PLOP!!

bluemagica
August 21st, 2008, 10:22 PM
well though this seems solved, i thought i will pitch in a bit:-
1)When you have one object on one hand, and multiple on the other for collision, its best to use the multiple object to check for collision against the single object.

2)there's a beautiful tutorial about multiple collision on the main kirupa site, just go readup a bit, and you will learn lots of things!

SparK_BR
August 24th, 2008, 10:02 PM
if you had a lot to hit a lot you would need a for loop