-
cursor help
Hey! I'm making a game and need help.
Can you make me a code that would change to frame 20 in the timeline when a movieclip called "knife" touches my cursor?
If you could, GREAT! I'm a n00bie!
---------------- MRD Media---------------
---------------- ----------------
-
I'm not going to spoon-feed you the code because you'll learn better if you do it yourself, also, I can't remember it.
But, do a hit test inside an IF control structure. If it's true, use gotoAndPlay() ot gotoAndStop(). Check the ActionScript dictionary for more info.
-
I disagree. I know I'd never have been able to learn proper AS if all people would do is give me 'hints'..
Code:
onClipEvent(enterFrame)
if(this.hitTest(_xmouse, _xmouse) {
_root.gotoAndStop(20);
}
If you put that inside the knife MC, it should work.
***
Another method is to make another small, invisible (set it's alpha to 0) MC, and set it to follow the mouse with the code:
Code:
onClipEvent(enterFrame) {
this._x = _xmouse;
this._y = _ymouse;
}
(put that inside the small, invisible MC)
Then give that small, invisible MC an instance name, I'll use 'mouseHit' for this example. Then place the following code inside the knife:
Code:
onClipEvent(enterFrame) {
if(this.hitTest(_root.mouseHit)) {
_root.gotoAndStop(20);
}
}
A bit of explanation: The code used for determining wether one thing hits another is
'if(OBJECT1.hitTest(OBJECT2)) {
WHAT YOU WANT TO HAPPEN
}'
Mmkay?
Good luck with your project.
-
Originally posted by BodadeM
I disagree. I know I'd never have been able to learn proper AS if all people would do is give me 'hints'..
Code:
onClipEvent(enterFrame)
if(this.hitTest(_xmouse, _xmouse) {
_root.gotoAndStop(20);
}
If you put that inside the knife MC, it should work.
***
Another method is to make another small, invisible (set it's alpha to 0) MC, and set it to follow the mouse with the code:
Code:
onClipEvent(enterFrame) {
this._x = _xmouse;
this._y = _ymouse;
}
(put that inside the small, invisible MC)
Then give that small, invisible MC an instance name, I'll use 'mouseHit' for this example. Then place the following code inside the knife:
Code:
onClipEvent(enterFrame) {
if(this.hitTest(_root.mouseHit)) {
_root.gotoAndStop(20);
}
}
A bit of explanation: The code used for determining wether one thing hits another is
'if(OBJECT1.hitTest(OBJECT2)) {
WHAT YOU WANT TO HAPPEN
}'
Mmkay?
Good luck with your project.
THANKS very much! If not for you, I would still be back at step 1...
---------------- MRD Media---------------
---------------- ----------------
-
No problem! I'm glad I could help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|