Hiya, how about logging the _root._xmouse properties (AS2) or log the localX/ stageX properties of the MouseEvent class in AS3. The timer can be triggered by moving over a movieclip or by whatever then set the parameters of where your 'moving area' is to be on the stage or let the user use the whole stage once the timer starts, using this method you can log their movements outside of the box!
Hope this helps,
Ali



On 13 Feb 2008, at 07:04, Paul Steven wrote:

Thanks Cory

Good point about the setInterval introducing redundant processing.Problem with placing an invisible movie clip is, the users mouse may not pass over this movie clip. For example, the movie is 600 pixels wide and 400 pixels high. If I place a 400 high and say 10 pixels wide movie clip in the center of the movie, it is still possible for the player to move their mouse left and right in the area to the left or the area to the right of the hidden movie clip - hence no speed would be detected. I am therefore not sure how to overcome this apart from insisting they move the mouse in a specified
area.

Any ideas anyone?



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cory Petosky
Sent: 12 February 2008 21:52
To: Flash Coders List
Cc: [EMAIL PROTECTED]
Subject: Re: [Flashcoders] Control speed by how fast mouse moving

You'd be better off doing it in an onEnterFrame or a onMouseMove than
in a setInterval call -- code is only executed between frames anyway,
so your way just adds extra processing burden.

Since all these events are only working once per frame, just comparing
x's isn't likely to give you meaningful data -- if a player moves his
mouse rapidly left to right at a rate that's some factor of your
framerate, you could easily get the same (or similar) x value at every
read. Increasing the framerate could help this, but brings other
problems.

Consider placing a small, invisible movieclip on the path you intend
the user to move his mouse, and listen for onRollOver. You can use the
number of RollOver events per second to adjust speed. Just keep in
mind that you won't get any more events than your framerate.

Finally, instead of adjusting speed directly, adjust max speed and
provide a constant acceleration toward the current max speed. For
example, if the user starts out at a rate that correlates to 50 mph,
his current speed should slowly increase at a constant rate over many
seconds until it reaches 50. Similarly, once the user begins to slow
down, the speed should decrease linearly to the maximum speed allowed
by the mouse move rate. This provides a slow acceleration at the
beginning -- which is probably what you want if you're emulating the
old button mashers -- and provides smooth speed changes as the game
progresses, which is definitely good.

On 2/12/08, Paul Steven <[EMAIL PROTECTED]> wrote:
I am trying to program a game where a character moves faster, the faster
the
player moved the mouse left and right. A bit like the old Dailey Decathlon Game where you had to hit 2 keys on the keyboard on after the other as
fast
as you can to control the speed of say a character running.

I could do with some advice on how to achieve this.

I have a frame rate of 31 FPS, with a movie width of 600 pixels.

Currently I am calling a function every 10ms to calculate the speed

objShowerGame.updateSpeedInterval = setInterval(updateSpeed, 10);


I compare the previous mouse X position with the current one and use this
difference as the speed.

This isn't really working so I could do with some suggestions.

Thanks

Paul

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



--
Cory Petosky : Lead Developer : PUNY
1618 Central Ave NE Suite 130
Minneapolis, MN 55413
Office: 612.216.3924
Mobile: 240.422.9652
Fax: 612.605.9216
http://www.punyentertainment.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to