Hi,
This post is a kind of side post to another I have regarding collision detection.
Helpful advice was to look at using points for collision detection.
However is Flash MX compatiable with points, if so what am I doing wrong in the code below?
I cannot import the class (see below)
Or declare the variable as a Point (also see below)
//import flash.geom.Point;
// Calculates the middle point of CPU man sprite as it moves across the screen
var cpuPoint:Point = new Point(_root.cpu._x + (_root.cpu._width / 2), _root.cpu._y + (_root.cpu. _height / 2));
trace (cpuPoint);
Initially I used hitTest on a ball and spite collision detection but due to the shapes and registration points I had issues.
It would detect a collision and move the ball symbol away by reverting a variable used to store direction and speed and multiplying it by *-1 to revert direction.
this.yspeed = this.yspeed*-1;
i.e. yspeed = 3 (3 pixels per frame moving up screen) post calculation yspeed = -3
yspeed = -3 (3 pixels per frame moving down screen) post calculation yspeed = 3
However this would not clear the boundarys of the symbol and simply revert the ball symbol into forever ending loop going back n forth by 3 pixels.
I tried adding do…until loop to increase y co-ordinate until boundary cleared but ending up looping and using too much memory.
Is there a easy method to help with this collision detection.
Previous post (hope its ok to link to previous post):-
Thanks
Rob