8 Forum Posts by "jelly-bean-jade"
At 10/30/14 01:56 PM, Sam wrote: Find the distance between the contained circle and the centre of the container circle. Don't allow this value to exceed the container circle's radius.
I have managed to get the distance between the two circles, but I am struggling with the "don't allow value" bit.
Hello flashy people
I am trying to create a pretty simple game, part of which involves a circle that you can drag, so that it doesn't leave it's parent circle. I've tried using hit test, which hasn't work at all. But I know there is a better way of doing it using math, but I just can't work out how to do it with a circle. Please help before I go insane trying to figure it out. And thank you in advance.
xxxxJBJxxxxx
At 3/15/13 09:16 PM, GeoKureli wrote: the Point class has a normalize() function that sets it to a certain length, assuming your eye boundaries is a circle you can do
var dis:Point = new point(distx, disty);
dis.normalize(10); // --- CHANGE 10 TO THE RADIUS OF THE EYE MINUS THE RADIUS OF THE PUPIL
Awesomesauce thank you so much XXXXXX
Ah, sorry, the Eyes follow the mouse pointer, but as they start to get further away from the character the pupils escape the head and move next to the character
Apologize for the multiple posts, very tired.
Evening all
I am having a problem with my head. I am making a game, part of which has moving eyes, it almost works, but the pupils keep moving outside of the head. The head is not center to the stage and is made up of three layers: Skin, pupils, white circles for the eye whites. Here is the code for the eye movingness. Please tell me where I am going wrong so I don't get a bad case of the crazies.
stage.addEventListener (Event.ENTER_FRAME, LookAtMouse);
function LookAtMouse (e:Event): void {
eye1Center = new Point();
eye1Center.x = 400;
eye1Center.y = 30;
eye2Center = new Point();
eye2Center.x = 400;
eye2Center.y = 30;
focalPoint = new Point();
focalPoint.x = ( _eye1Center.x + _eye2Center.x ) / 2;
focalPoint.y = ( _eye1Center.y + _eye2Center.y ) / 2;
var distx:Number = mouseX - focalPoint.x;
var disty:Number = mouseY - focalPoint.y;
charBase.pupil1.x = charBase.eye1.x + (distx / 10);
charBase.pupil1.y = charBase.eye1.y + (disty / 10);
charBase.pupil2.x = charBase.eye2.x + (distx / 10);
charBase.pupil2.y = charBase.eye2.y + (disty / 10);
Thank You
xxJBJxx
Evening all
I am having a problem with my head. I am making a game, part of which has moving eyes, it almost works, but the pupils keep moving outside of the head. The head is not center to the stage and is made up of three layers: Skin, pupils, white circles for the eye whites. Here is the code for the eye movingness. Please tell me where I am going wrong so I don't get a bad case of the crazies.
stage.addEventListener (Event.ENTER_FRAME, LookAtMouse);
function LookAtMouse (e:Event): void {
eye1Center = new Point();
eye1Center.x = 400;
eye1Center.y = 30;
eye2Center = new Point();
eye2Center.x = 400;
eye2Center.y = 30;
focalPoint = new Point();
focalPoint.x = ( _eye1Center.x + _eye2Center.x ) / 2;
focalPoint.y = ( _eye1Center.y + _eye2Center.y ) / 2;
var distx:Number = mouseX - focalPoint.x;
var disty:Number = mouseY - focalPoint.y;
charBase.pupil1.x = charBase.eye1.x + (distx / 10);
charBase.pupil1.y = charBase.eye1.y + (disty / 10);
charBase.pupil2.x = charBase.eye2.x + (distx / 10);
charBase.pupil2.y = charBase.eye2.y + (disty / 10);
Thank You
xxJBJxx
Evening all
I am having a problem with my head. I am making a game, part of which has moving eyes, it almost works, but the pupils keep moving outside of the head. The head is made up of three layers: Skin, pupils, white circles for the eye whites. Here is the code for the eye movingness. Please tell me where I am going wrong so I don't get a bad case of the crazies.
stage.addEventListener (Event.ENTER_FRAME, LookAtMouse);
function LookAtMouse (e:Event): void {
eye1Center = new Point();
eye1Center.x = 400;
eye1Center.y = 30;
eye2Center = new Point();
eye2Center.x = 400;
eye2Center.y = 30;
focalPoint = new Point();
focalPoint.x = ( _eye1Center.x + _eye2Center.x ) / 2;
focalPoint.y = ( _eye1Center.y + _eye2Center.y ) / 2;
var distx:Number = mouseX - focalPoint.x;
var disty:Number = mouseY - focalPoint.y;
charBase.pupil1.x = charBase.eye1.x + (distx / 10);
charBase.pupil1.y = charBase.eye1.y + (disty / 10);
charBase.pupil2.x = charBase.eye2.x + (distx / 10);
charBase.pupil2.y = charBase.eye2.y + (disty / 10);
Thank You
xxJBJxx

