Sprite following mouse

325 views
Skip to first unread message

Armel J. Gibson

unread,
Jun 9, 2014, 11:41:26 AM6/9/14
to haxef...@googlegroups.com
Sup people 

I'm trying to make a FlxSprite follow the mouse pointer in flash. Not to be used as a cursor (I know HaxeFlixel allows us to set our own cursor), but simply as a collider. I'm doing on the update function :

collider.x = FlxG.mouse.x - cursor.width / 2;
collider.y = FlxG.mouse.y - cursor.height / 2;


However, the collider is lagging behind the mouse pointer, and is exactly at the right place only when the mouse stops. 


From what I understand, the actual cursor image used to do that before native cursor were supported. Since I don't just want to display an image under the cursor, but also doing collision etc on it, is there anything that I can do to make the collider sprite act the same as the native cursor image? I've tried looking into FlxMouse, but I can't seem to get the exact x/y of the native cursor from there, only the old cursor system (hence the "lag").

(it's working just fine on windows btw)

Thanks :) 


Gama11

unread,
Jun 9, 2014, 2:29:42 PM6/9/14
to haxef...@googlegroups.com
This is not an issue with "old cursor system x y values". There's no way to avoid the lag - that's why the native mouse cursor API was added in the first place. I guess a high framerate can help though.

From the Adobe docs:

  • In general, the responsiveness of display object cursors are sluggish. In comparison, native mouse cursors look and perform better when the user interacts with an application.
What you can do is make the mouse lag again by defining FLX_NO_NATIVE_CURSOR. ;)

Armel J. Gibson

unread,
Jun 9, 2014, 2:42:36 PM6/9/14
to haxef...@googlegroups.com
Hm ok :(

It's doing the trick with FLX_NO_NATIVE_CURSOR for now. Might switch to windows only though. Thanks for your help :)
Reply all
Reply to author
Forward
0 new messages