PDA

View Full Version : Problem with hittest - object solidity?



Jackal007
January 20th, 2005, 05:44 AM
Hi,

I am quite new to flash, and have started making break out, to learn some game programming aspects and knowledge, i have a ball pinging around the screen, the only problem at the moment is when the ball hits the top or bottom of a block it pings off in the opposite coordinates, but on the side of the object it goes through it awkwardly instead of pinging:-

________
* here goes thru * |_______| *

Anyone come across this before?

rhine
January 20th, 2005, 06:13 AM
Hi,

I am quite new to flash, and have started making break out, to learn some game programming aspects and knowledge, i have a ball pinging around the screen, the only problem at the moment is when the ball hits the top or bottom of a block it pings off in the opposite coordinates, but on the side of the object it goes through it awkwardly instead of pinging:-

________
* here goes thru * |_______| *

Anyone come across this before?
Can you post the code? It may have to do with the _y hittest coordinates you're using.

Jackal007
January 20th, 2005, 06:21 AM
Can you post the code? It may have to do with the _y hittest coordinates you're using.if (_root.mcBlock.hitTest(this)) {
redirectBall();
}


function redirectBall() {
speedX = +speedX;
speedY = -speedY;
}

that code is on the ball movie clip
if it hits a block it calls that function to reverse the balls direction

RyxiaN
January 20th, 2005, 01:00 PM
Shall the ball move? Then you need to have:


if (_root.mcBlock.hitTest(this)) {
redirectBall();
}
function redirectBall() {
speedX = +speedX;
speedY = -speedY;
_x= speedX;
_y= speedY;
}

Right?

lostinbeta
January 20th, 2005, 01:13 PM
Have you seen this?

http://www.kirupa.com/developer/actionscript/pongout.htm

JoMan
January 20th, 2005, 02:45 PM
Ah yes, the great pong tutorial! Well writen I say :thumb:

peace

Jackal007
January 21st, 2005, 08:27 PM
Thanks, i just discovered this site, but its really good, i think ill give that pong tute a go and then ill be more aware of how to actually make arcanoid ;)