Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-03-2010, 06:25 AM   #1
patawic
Registered User
 
Join Date: May 2010
Posts: 36
Default [AS2] Collisions with lines drawn on multiple movie clips

I have a drawing code of
ActionScript Code:
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.
patawic is offline   Reply With Quote
Old 06-03-2010, 06:53 PM   #2
dzy2566
I'm back, baby!
 
dzy2566's Avatar
 
Join Date: Jul 2003
Location: Palm Desert, Ca
Posts: 1,148
Default

Chapter 10 of Keith Peters' book covers exactly that. I highly recommend checking it out:
Foundation Actionscript 3.0 Making Things Move
This book saves my ass on a weekly basis.
__________________
Bacon and Games
A site dedicated to game design and programming (and bacon!!!)
http://www.baconandgames.com
dzy2566 is offline   Reply With Quote
Old 06-03-2010, 08:23 PM   #3
patawic
Registered User
 
Join Date: May 2010
Posts: 36
Default

Thanks, i will look into it.
patawic is offline   Reply With Quote
Old 06-04-2010, 08:02 AM   #4
patawic
Registered User
 
Join Date: May 2010
Posts: 36
Default

Im still unable to get the collision to function properly

Would it help if i uploaded what i have currently???
patawic is offline   Reply With Quote
Old 06-04-2010, 11:55 PM   #5
patawic
Registered User
 
Join Date: May 2010
Posts: 36
Default

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 is offline   Reply With Quote
Old 06-06-2010, 06:31 AM   #6
patawic
Registered User
 
Join Date: May 2010
Posts: 36
Default

If i use the code
ActionScript 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 :/
patawic is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:17 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.