I am developing a magnet effect in my Qt project.There two widgets(Master and Slave).Slave's left border will be moved to Master's right border(that's I called magnet effect) when they are 30 pixels away from each other when Slave is moving,then they enter TOGETHER_STATE.Once they enter TOGETHER_STATE,Slave will be moved when Master is moving,not vice versa.**They enter SEPARATE_STATE when **Slave's left border is more than 30 pixels away from Master's right border when it is moving.As far as I know Teamviewer has similar effect.
One way to implement magnet effect is that move Slave to Master's right border using move function in Slave's moveEvent when condition described above is satisfied. But it will contribute to flicking because move widget in moveEvent will lead to infinite recursion.
Do anyone have any good ideas?Did I make myself understood?
Related
I’m building a small web-based game that uses the computer’s built-in or attached camera. I’m using Machine Learning to recognize the user’s face and then have an avatar on the screen mimic the user’s movement (i.e. when the user’s face gets closer to the camera, the avatar gets bigger since the user’s face is closer to the camera; when the user moves right, the avatar moves right too).
One of my friends has a large monitor in front of him and then the laptop sits to his right. Hence, when he moves closer to the bigger monitor, the avatar shows him moving left, since the camera is to his right. This makes sense but I was wondering, from a mathematical point of view, given a set of (x, y) coordinates for the user’s nose, eyes and ears, how could I possibly rotate this set of coordinates around the y axis. We can assume that the camera sits 45 degrees to the right of my friend.
I’m hoping that with this rotation, when he moves closer to the screen he’s facing, the avatar will become bigger, mimicking his exact movements, despite the fact that the camera is to his right. One particular problem I’m struggling with is the size of the avatar - when the camera is to the right and the user moves left, the avatar becomes smaller since the face is moving away from the camera, but this shouldn’t be the case.
I’ve added the option to ask the user where the camera is positioned, but I need help with finding a plane rotation that will solve the issue above.
Thanks in advance.
first of all I am not the big front end developer, but I know at least normal CSS design methods. My problem is, I want one image, lets say a worldmap.
On the map I want pins and when someone hovers over that pin a info box will be shown. Thats no problem, when I use CSS circles with a hover effect and a little bit of Javascript. The problem is that the trick with the position of the circles only works, if the size of the image stays the same. When I have a responsive image, the pins are somewhere else.
Thanks!
I am super new at this, so please be patient with me. I am attempting to design a user interface on a VGA display using an Arduino UNO and a Gamduino 1.0, and need help with drawing two axes (x and y). Essentially, I need to draw two static lines on a monitor where the x-axis pans from left to right on the display, and the y-axis is 1/8 from the left of the display, panning 1/2 from the top of the display until the bottom.
Hopefully that makes sense.
If it's static you'll want it as a background (as opposed to sprite).
There's a tutorial here on setting backgrounds:
http://excamera.com/sphinx/gameduino/tutorials/frogger1.html
I'm in the process of something similar so I'll post up my code soon (gameduino just arrived in the mail today).
I'm working on a simple board game in qt, and i have some problem with the layout. I have two players, their health is represented with pixmaps, at the bottom of the screen. It looks now something like this:
Notice, that i would like to keep the health indicators on the opposite sides of the screen, and the button in the middle centered, relative to the screen.
BUT when some of the players loose health, this happens:
If the drawing were not understandable, here, i took some screens:
So the problem is, that the button in the middle starts shifting to one of the edges of the sreen because of the spacers. I understand why it does it, but i simply can't find a solution.
Please if you have any ideas, how i could make this layout work, help me!
Thanks in advance!
Make an empty (fully transparent) health indicator pixmap which has the same size as the heart pixmap. Then you can always place three same size health indicator pixmaps for both players.
You can put a Widget where your health indicator should be, set its sizePolicy to a fixed size, and put your health indicator pixmap inside that widget.
I'm developing a Flex 2 application, and I noticed that part of the library which is responsible for moving GUI windows (TitleWindows) around when you drag them with the mouse gets confused if there is a clickable (buttonMode = true) sprite beneath them. When I say confused, I mean that the window is moved around normally for a while, but then at some point "jumps" into the upper left corner of the flash app, and makes very minor movement there. Then at some other point it jumps back. It is more difficult to explain than to experience, so please go and see for yourself. Here's how to reproduce the problem:
Go to http://www.panocast.com
In the left sidebar, choose "Real Estate"
Just below the bottom right corner of the flash window, choose "high res" by clicking on the rightmost icon.
When (part of) the video loads, click on the staircase. A TitleWindow will pop up.
Try dragging it around the screen. When the mouse cursor is moved above one of the clickable areas (like the staircase), the window is misplaced.
(Sorry, but can't give you a direct link, part of the page is generated dynamically.)
(What's makes the problem even more interesting is that for me, in "low res" mode, the problem does not occur! There is very little difference between the various modes.) I would really appreciate if someone told me what was going on here and how it can be fixed.
I'm not sure if it matters, but the underlying sprite is actually not just plain sprite, rather it is a Papervision3D renderer object with some 3D elements in it. I'm telling this because it is possible that the incorrect mouse coordinates somehow come from the texture UV mapped on the clickable objects.
I've managed to replicate this on the low res mode as well, so I don't think it's related to the resolution.
This looks to be because the MouseEvent is being handled by the TitleWindow AND the Papervision3D window. Perhaps you need to force stopImmediatePropagation() on one or the other? Or maybe switch off the MouseEvent handling for the Pv3D window when the TitleWindow pops up?
That's a tough one to debug without some source; something's apparently calling either move() or setting x and y properties on that TitleWindow and scheduling it be moved.
When I first read the post, it "smelled" like maybe a rotation miscalculation somewhere (using Math.atan vs. Math.atan2 can sometimes have that kind of effect), so you're right, it could have something to do with PaperVision, assuming you're not using Math.atan or setting rotation properties yourself anywhere. Just thought I'd mention it, though it's probably not happening in your case. You never know, though. ;)
More likely the LayoutManager is moving the component in response to a property change on the component. The Flex docs explain that in addition to setting its x and y properties, and explicit calls to move(), a UIComponent's move event can also be triggered when any of the following other properties change:
minWidth
minHeight
maxWidth
maxHeight
explicitWidth
explicitHeight
PaperVision or no, maybe that info might help you isolate the source of the move. Good luck.
I got this figured out. Apparently, this is a Papervision3D problem. There is a class deep inside Papervision3D called VirtualMouse, which is supposed to generate MouseEvents programmatically. This happens, for example, when the user interacts with any of the interactive objects on stage, e.g., a Plane with an interactive material on it (as in my case).
The problem is that the x and y coordinates of the generated event represent texture UV coordinates (just as I suspected) and not real world screen coordinates. When a TitleWindow (or any Panel object) is dragged, a "mouseMove" handler (among others) is added to the SystemManager, which then uses the stageX and stageY properties of the event object to determine the new position of the window. Unfortunately for VirtualMouse's mouse events, these are invalid, since the original x,y coordinates, which are probably used to determine the global stage coordinates are, as I said, not screen coordinates.
Honestly, I'm still unsure whether the events dispatched by VirtualMouse are used anywhere within Papervision3D itself, or they are just offered for convenience, but they sure make it difficult to integrate a viewport into a Flex program. Assuming that such events aren't necessary for PV3D itself, there is a one-liner fix for my problem, which must be added right after the creation of the viewport:
viewport.interactiveSceneManager.virtualMouse.
disableEvent(MouseEvent.MOUSE_MOVE);
BTW., there was a very similar (or rather, as it turns out, the same) bug with dragging sliders, also fixed by this line.