PDA

View Full Version : [AS2] Collisions with lines drawn on multiple movie clips


patawic
06-03-2010, 06:25 AM
I have a drawing code of

var linenumber = createEmptyMovieClip("line"+getNextHighestDepth(), getNextHighestDepth());
linenumber.lineStyle(2, 0x000000, 100);
linenumber.moveTo(oldx, oldy);
linenumber.lineTo(_xmouse, _ymouse);
trackcode += "l|" + _xmouse + "|" + _ymouse + "|";
trace(linenumber);
oldx = _xmouse
oldy = _ymouse

Which puts each line segment onto its own movieclip

I have the players character (which is a bouncing ball), How is it possible for the ball to collide with every movieclip. "Line1","Line2","Line3" etc etc.

dzy2566
06-03-2010, 06:53 PM
Chapter 10 of Keith Peters' book covers exactly that. I highly recommend checking it out:
Foundation Actionscript 3.0 Making Things Move (http://www.amazon.com/gp/product/1590597915?ie=UTF8&tag=bacandgam-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=1590597915)
This book saves my ass on a weekly basis.

patawic
06-03-2010, 08:23 PM
Thanks, i will look into it.

patawic
06-04-2010, 08:02 AM
Im still unable to get the collision to function properly :(

Would it help if i uploaded what i have currently???

patawic
06-04-2010, 11:55 PM
I have read the chapter in that book, and i am still unable to get it to function. The ball passes straight through the line.

patawic
06-06-2010, 06:31 AM
If i use the code

for (x=1; x<=terrain.length; x++) {
if (this.hitTest(_root[terrain[x]])) {
collisions++;
sum_x += spot_x;
sum_y += spot_y;
}
}

It laggs the game until it crashes. What am i doing wrong :/