I’m constantly bumping into a problem/bug in openfl when using the position of my sprite objects on screen. For example, if I want them to follow my mouse, using stage.mouseX and stage.mouseY, the objects will move to twice this location. So I always have to implement a fix like this:
x = stage.mouseX * 0.5;
The ** 0.5* fixes my problem, but there shouldn’t be a problem in the first place, right? I can’t really find anything concerning this issue using Google, it appears I’m the only one who has it.
When tracing the stage.mouseX and the instance’s x position, the mouse position actually corresponds with the pixels on my screen, whilst the instance’s position is half this number when it’s on exactly the same position as my mouse.
Besides that, adding a value of 1 to my instance’s x or y will make it move two pixels instead of one. The instance’s sprite (that is, the image) is drawn at a 1:1 scale (one pixel is one pixel), so this issue doesn’t have anything to do with a zooming or scale problem.
This issue persisted after upgrading all my haxe libs (haxelib upgrade).
I was wondering if it might have something to do with my system’s flash install?
Anyways, I hope this is all the information you need, and I really hope someone here who can help me solve this issue…
What platform is this? Does it work this way on the desktop?
This is on my Windows laptop (windows 8.1)
Could you try the “HandlingMouseEvents” sample?
openfl create HandlingMouseEvents
openfl test HandlingMouseEvents neko
It should include dragging for the image, it would be interesting to know if this works properly for you or not
That sample should be using the mouseX values, as well, without requiring special multiplication, so I’m guessing there’s something different in what your project is doing than this one?
I found some more details on my issue:
Everything concerning a Sprite instance’s coordinates goes wrong, so it doesn’t have anything to do with the mouse.
I compiled one of my test projects on someone else’s computer (he doesn’t have this issue with his own projects), and it worked exactly the same, it still needed the fix to work properly, so the problem should be somewhere in my standard template when I create an openfl project in FlashDevelop…
So I have tried to see if I could find something wrong in the standard settings/variables of the template, but I can’t really find anything that influences this problem. Any thoughts on what this could be?
Maybe we could start with a “known good” sample like HandlingMouseEvents, and try modifying it until we can get it to recreate the same behavior, helping us know the trigger?