A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: paddle game and moving buttons

Threaded View

  1. #1

    Question paddle game and moving buttons

    I have a paddle game where the ball bounces of the paddle and hits blocks. (nothing special) It works but i was wondering is there a way to make it so that the ball bounces at a different angle if it hits the very edge of the paddle.

    Heres the code for the paddle:

    onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
    if (this._x<=485) {
    this._x += 13;
    }
    }
    if (Key.isDown(Key.LEFT)) {
    if (this._x>=25) {
    this._x -= 13;
    }
    }
    }


    and heres the code for the ball :

    onClipEvent (load) {
    dir = Math.round(Math.random()*1);
    speed = 15;
    if (dir == 1) {
    var Ang = 45;
    } else {
    var Ang = 135;
    }
    xspeed = speed*Math.cos((Ang)*Math.PI/180);
    yspeed = speed*Math.sin((Ang)*Math.PI/180);
    }
    onClipEvent (enterFrame) {
    this._x += xspeed;
    this._y += yspeed;
    if ((this._x<=5) || (this._x>=495)) {
    xspeed = -xspeed;
    }
    if ((this._y<=5) || (_root.pad.hitTest(this))) {
    yspeed = -yspeed;
    }
    if (this._y>420) {
    _root.lives -= 1;
    _root.score -= 10;
    if (_root.lives == 0) {
    _root.gotoAndPlay(5);
    }
    _x = 150;
    _y = 100;
    dir = Math.round(Math.random()*1);
    speed = 15;
    if (dir == 1) {
    var Ang = 45;
    } else {
    var Ang = 135;
    }
    xspeed = speed*Math.cos((Ang)*Math.PI/180);
    yspeed = speed*Math.sin((Ang)*Math.PI/180);
    }
    }

    If anyone knows how to help please post
    by the wat does anyone know how to make a moving button
    oh yah, and i am using MX
    Last edited by bob58; 08-20-2008 at 02:52 PM.

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