Hi,

I'm trying to make an Arkanoid type of game in flash, and I'm having a problem.

When I make the instance of the bar (that you are controlling) and the instance of the ball, I put them both at x: 400, y: 400.

But they are not at the same point.

The ball is 50 pixels below the bar, but the y axie is correct.

I tried to make a trace of that, and flash tells me that both objects are at x:400, y:400.

I also attached a screenshot of what my code does, in this post (below).

Anyone knows what my problem could be?

Thanks a lot for your help guys

Here is my Ball class:Code:var initPalX:Number = 400; var initPalY:Number = 400; var initBallX:Number = 400; var initBallY:Number = 400; var ballSpeed:Number = 20; var paletteSpeed:Number = 10; var theball:Ball = new Ball(mc_passball, initBallX, initBallY, ballSpeed, initX, initY); var thepalette:Palette = new Palette(mc_pal, initPalX, initPalY, paletteSpeed); this.onEnterFrame = function() { if (Key.isDown(39)) { thepalette.moveRight(); theball.followPalette(thepalette.getx(), thepalette.gety()); } if (Key.isDown(37)) { thepalette.moveLeft(); theball.followPalette(thepalette.getx(), thepalette.gety()); } if (Key.getCode() == 32) { theball.rebound(90); } }

Here is my bar class:Code:class Ball extends MovieClip { var ball_mc:MovieClip; var x:Number; var y:Number; var speed:Number; var lx:Number; var ly:Number; public function Ball(pass_mc:MovieClip, pass_x:Number, pass_y:Number, pass_speed:Number, pass_lx:Number, pass_ly:Number) { ball_mc = pass_mc; ball_mc._x = pass_x; ball_mc._y = pass_y; speed = pass_speed; lx = pass_lx; ly = pass_ly; } public function getHitAngle() { var a:Number = Math.abs(lx - ball_mc._x); var b:Number = Math.abs(ly - ball_mc._y); var c:Number = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); var angle:Number= Math.asin(a / c); return angle; } public function rebound(angle:Number) { var scale_x:Number = Math.cos(angle); var scale_y:Number = Math.sin(angle); var velocity_x:Number = (speed * scale_x); var velocity_y:Number = (speed * scale_y); ball_mc._x -= velocity_x; ball_mc._y -= velocity_y; } public function followPalette(pass_x:Number, pass_y:Number) { ball_mc._x = pass_x; ball_mc._y = pass_y; //trace(pass_obj._x); } public function setlx(pass_lx:Number) { lx = pass_lx; } public function setly(pass_ly:Number) { ly = pass_ly; } public function getx() { return ball_mc._x; } public function gety() { return ball_mc._y; } }

Code:class Palette extends MovieClip { var mc_palette:MovieClip; var speed:Number; public function Palette(pass_mc:MovieClip, pass_x:Number, pass_y:Number, pass_speed:Number) { mc_palette = pass_mc; mc_palette._x = pass_x; mc_palette._y = pass_y; speed = pass_speed; } public function moveLeft() { mc_palette._x -= speed; } public function moveRight() { mc_palette._x += speed; } public function getx() { return mc_palette._x; } public function gety() { return mc_palette._y; } }