A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Shooting

  1. #1
    14 year old W.I.Z!
    Join Date
    Jul 2005
    Location
    USA
    Posts
    227

    Shooting

    Ok, in this topic, I want to know how the pros do shooting in games. I know how the slope intercept and the tans work with getting a projectile to fly, but what I want is a line that flies across the screen and if it hits something, that something dies. I was thinking:
    Code:
    onClipEvent(load){
    createEmptyMovieClip("line",1);
    line.lineStyle(1,0x000000,100);
    line.moveTo(_x,_y);
    }
    onClipEvent(enterFrame){
    var dx:Number = _xmouse-_x;
    var dy:Number = _ymouse-_y;
    var r:Number = Math.atan2(dy,dx);
    var x:Number = Math.cos(r)*999;
    var y:Number = Math.sin(r)*999;
    line.lineTo(x,y);
    }
    But this doesn't entirely work right...can someone help me? Please?
    Excuse my horrible spelling....you can blame my English teacher for that!

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    So, the line is drawn from center of mc (_x, _y) in the direction of mouse? Drawing it is easy, but to make it detect things on the stage is difficult. What kind of shapes do you need to be detected? Lines, points, circles, rectangles, or any kind other of shapes? Basically you need to create collision detection calculation between line and "the thing that can die".

  3. #3
    14 year old W.I.Z!
    Join Date
    Jul 2005
    Location
    USA
    Posts
    227
    Well, what I was thinking was what they have in games like StickMan Sam(the series) and Madness Interactive and such. I know they don't just have a bullet fly to where the mouse was clicked because that would lag the game, so I concluded that they used lines.
    Excuse my horrible spelling....you can blame my English teacher for that!

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center