|
Post by dk on Jul 14, 2014 5:59:21 GMT
Hi, I have been struggling with this and cannot find a solution on my own.
I have a circle object off screen that slowly scrolls along the x axis as part of a background. When the circle object reaches approximately the center of the screen I need the visibility of a button to activate, Using Java, How do I detect the x,y position of the circle to say within 20 x 20 pixels of the target area then set the visibility of the GoButton? Is this close?
if Cirle.x = >20.y = >20 GoButton.Visible=true;
I know what I need to do but am having difficulty in writing the actual code. Appreciate any help as I am stuck and cannot post my project progress update on the Hippo forum.
Many thanks dk
|
|
|
Post by runes on Jul 14, 2014 7:17:20 GMT
I'm not completely sure I understand what you're doing here... But I'll try to help. You need to define the center of the screen(which is your target area). Then you must define, that if Circle is within 20 pixels of that point GoButton will be visible: var DestinationX=GetMovieWidth()/2; if(Circle.X>(DestinationX-20) && Circle.X<(DestinationX+20){ GoButton.Visible=true; } You don't necessarily have to make the variable DestinationX. You can just put in a number. If your movie is 600 wide you can just put in 300 instead of DestinationX: if(Circle.X>(300-20) && Circle.X<(300+20){ GoButton.Visible=true; } Just a small note; Java and Javascript are two completely different languages. To avoid confusion you should refer to 'javascript' instead of 'Java' (and also correct that in your excellent turkey moving tutorial ).
|
|
|
Post by dk on Jul 14, 2014 8:40:03 GMT
Hi runes. Thanks so much for the help mate. I used the last version of your code snippett:
if(Circle.X>(300-20) && Circle.X<(300+20){ GoButton.Visible=true; }
I placed it in the On Release of my scroll button and got this error message:
"Error2: Button1_OnRelease : The function " failed. Object reference not set to an instance of an object." Thanks for the comments and the advice on Java vs Javascript. Will make changes asap.
Chers d.k
|
|