Cocos2d-x SetFrameSize make screen touch event wrong position - c++

I use visual studio to implement my Win32 game project, but because I will port it to android platform later, so in AppDelegate class, I use setFrameSize to make window screen be like a mobile screen as below:
glview->setFrameSize(600, 900);
glview->setDesignResolutionSize(320, 480, ResolutionPolicy::FIXED_WIDTH);
But I got problem when implementing menu items, if I use setFrameSize function, when I touch to menu item, they does not work because their visual position is diffent from thier real position. If I comment out the set frame size command, menu items work correctly, but my screen too big and is very difficult for me to develope mobile game. Does anyone know why this problem come to me and how to resolve it? Thank alot.
Edit: I use visibleSize to set position for my menu items. It seem to not the same as what I want because when I set position of sprite is 3/8 of screen height ( bottom up), it become 1/2 of screen height ( bottom up).

Related

How do you handle a mouse cursor in the FPS game?

I'm making an FPS game. In the FPS game, the mouse cursor is in the middle of the screen. So I put the mouse cursor in the center with the next code. But how can I solve this problem when the camera stutters very much every time I move the mouse?
SetCursorPos(CRenderMgr::GetInst()->GetResolution().fWidth / 2, CRenderMgr::GetInst()->GetResolution().fHeight / 2);
CRenderMgr::GetInst()->GetResolution() is Screen Width and height
What you are doing is referred to as 'relative mode' mouse movement.
For classic Win32, this is typically done using "raw input". See this article.
If you want "raw input" to also to work in a Remote Desktop, see this code. In Remote Desktop, you don't get MOUSE_MOVE_RELATIVE data, and in normal desktop scenarios you never get MOUSE_MOVE_ABSOLUTE data.
For UWP, this is implemented as mentioned in this article.
You can see the Mouse class in the DirectX Tool Kit.

How to zoom in/out a selected part of an image in Qt?

I'm working on a Qt class project. We're supposed to develop an application like Microsoft Paint. Now I don't know how to enlarge a selected part of an image. Actually I don't even know how to "select" an area. You know, just like that on the desktop of Windows, you press the left button of the mouse and than move it, a dashed-line rectangle will show up. I hope to move or zoom in/out this particular area.
Any help will be appreciated, thanks!
It could be done by using mouse events. Here's example that might be useful to you:https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

Overlay images on the desktop with C++

I am trying to make an interesting tutorial for a program I have developed, and I want arrows to appear and disappear on the screen at certain times of the tutorial. These arrows I have already drawn on paint (I can have them in png, jpg... practically any image format), but I have on idea on how to make them appear on the screen and disappear when I want them to.
Basically if they could appear on the screen, like on top of any other window, on the highest layer (with only the mouse itself capable of going over it), that would be my ideal code. It would not matter if print screen would include the image or not, all that matters is that it can appear and disappear when the right code is given.
Any help at all would leave me in your eternal debt xD!
Probably the easiest way to do this is to create a see-through and click-through fullscreen window that is always on top. Then you can draw the arrows in this window with GDI (assuming you're targeting Windows) at any position on-screen you like.
The window can be made see-through and click-through by using
WS_EX_LAYERED | WS_EX_TRANSPARENT
as extended window style.

Two finger moving smooth and kinetic scrolling with trackpad or touchpad?

I am working on a Qt application which resembles hex editor for Mac.
(picture from Google)
It has a very large portion of data to scroll vertically(upward and downward) because it shows all large files data in hex format.
In my application, I'd like to add two finger smooth scrolling in both direction: up and down like that in Macbook Air two finger scrolling.
It work properly with mouse wheel but not with trackpad two finger move scrolling.
If someone has a solution, please help me out. Thanks in advance.
The scroller allows for gestures like click and drag to do kinetic scrolling.
http://qt-project.org/doc/qt-5/qscroller.html#details
Note on this page:
QScroller::TouchGesture 0
The gesture recognizer will only trigger on touch events. Specifically it will react on single touch points when using a touch screen and dual touch points when using a touchpad.
So then the example they give would turn into this for you:
QWidget *w = ...;
QScroller::grabGesture(w, QScroller::TouchGesture);
There is more on doing new things with touch screens and touch pads by handling the QTouchEvent:
http://qt-project.org/doc/qt-5/qtouchevent.html#details
Hope that helps.

OpenGL Detect clicking on object inside another object

I am pretty new to openGL programming and I encountered a problem I just need some advice on. Basically I have a button which has a simple function to just print something out on the console when it is clicked and that works fine on its own. However I also have a rectangle which I use as mini window or a container to hold buttons.
The problem I have is when the button is on top of the rectangle, the clicking functions for that button isn't detected, instead the clicking functions for the rectangle which is printing a message on the console saying the rectangle was clicked, is detected. On the other hand, if I drag the rectangle away and just leave the button on its own on the window, the clicking functions will work for the button.
Is there any advice you guys can give me or tell me what to research to aid me with detecting the button click while my button is inside of the rectangle? by the way I am not using Glut on my project.
A good start would be, if you told us, how you're actually getting the user input and how you're processing it. Whatever you do, it got nothing to do with OpenGL though, because OpenGL doesn't deal with user input and OpenGL doesn't deal with scene management.
OpenGL draws things. One point, line or triangle at a time. After it pushed some pixels to the framebuffer canvas it forgets about what it just did. There's no scene in OpenGL. There are no models in OpenGL. So whatever you do, it's using something else.