A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Stuck trying to animate mc's - see code

Threaded View

  1. #4
    Member
    Join Date
    Jul 2009
    Posts
    69
    Ok, I corrected this:

    shape.velX = (Math.random()*20)-10
    shape.velY = (Math.random()*20)-10
    instead of "10" I had a smaller number there before, which resulted in a bias in the random numbers created, thus shapes going mostly in one direciton.

    Still having trouble with this ... my understanding of Math.random is clearly not good ... off to google:

    if(shape.y >= stage.stageHeight-shape.length/2){
    shape.velY = shape.velY*Math.random()*20+5;}

    if(shape.y <= stage.stageHeight-shape.length/2){
    shape.velY = shape.velY*Math.random()*20+5;}

    if(shape.x >= stage.stageWidth-shape.width/2){
    shape.velX -= shape.velX*Math.random()*20+5;;}

    if(shape.x <= stage.stageWidth-shape.width/2){
    shape.velX -= shape.velX*Math.random()*20+5;;}
    yes, I'm at Actionscript for dummies level : ) ... gotta start somewhere. Thanks for any help.
    Last edited by Leftyplayer; 09-10-2009 at 10:56 AM.

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