mercredi 16 novembre 2016

actionscript 3 - scrub movie clip frame by the mouse x axis

just looking for a little insight into a problem I'm having.

Making a simple 'catch the falling objects' game to teach myself a little AS3. The idea would obviously be to move your mouse cursor (a hand) underneath a falling...I dunno, kitty/icecream/whatever to catch it, while avoiding objects like a spider - that's fine, getting an object to follow the mouse is relatively simple.

But what I'd really like is to rather than just having a static object follow the mouse directly, is have the character anchored on one side of the screen, catching the falling objects by 'reaching out' to grab them.

My plan was to have the 'character' be a movie clip, within which the 'hand' is the object that must collide with the falling object to receive a point (and avoid colliding with incorrect objects which will lose points), the rest of the character being a non-event so objects pass by the arm, shoulder, etc with no effect. In the movie clip first frame, the character has their hand close to their chest, and in the final frame the character is leaning over to the right with their arm fully extended (with the in between frames either tweened or frame-by-framed).

Is there a way to link the scrubbing of this clip to the mouse x location (without a click event), so that as you move the mouse to the right, the frames of the movie clip are advanced/played (thus the arm is extended reaching out into the path of the falling objects), while moving the mouse to the left causes the movie clip to go back frames (thus making the character retract their arm)? I've definitely seen a similar mechanic in old flash games years ago, but am unsure if this is how they achieved it.

Thanks in advance for any help!

Aucun commentaire:

Enregistrer un commentaire