Touch and mouse issues

I am using EventListeners and on my Windows machine when using window screen (non-full mode) I am getting the Y coordinate of a mouse click or a touch click with a different resolution. meaning when I kill at the bottom of the screen I see it directly where I clicked. but if I go up to the end of the screen I’ll see around 50 pixels off.

This is not a scale issue which I suspected at first. I am using Resource + design resolution which are extactly the same and scale factor of 1.0.

When I go to full screen the problem goes away.

I am using cocos2d-x 3.16

Just to add to what I said. the way that I am testing it is by doing this code :

void LevelScene::onTouchEnded(Touch* touch, Event *event)
{
Point endLocation = touch->getLocation();
DrawNode *drawnode = DrawNode::create();
drawnode->drawDot(Vec2(endLocation.x,endLocation.y), 10, Color4F::GREEN);
this->addChild(drawnode, 100);
}

So I have a green dot on the screen whereever I click inside the scene. the pixel is not where I touch it is slightly higher when touching the upper part of the screen.

Can you show a screenshot too? I am having trouble visualizing this.

Here is a vide I uploaded :

It is using the basic HelloWorldScene and the code on Mousedown is :

void HelloWorld::onMouseDown(EventMouse *event) {
	DrawNode *drawnode = DrawNode::create();
	drawnode->drawDot(event->getLocationInView(),10, Color4F::GREEN);
	this->addChild(drawnode, 100);

}

As you can see as I go up and click the sprite is placed with an offest on the screen.

Nobody ? this really seems like a nasty cocos2d-x bug…

I do have some more understanding of the problem now.

I have used the following code to generate the image that you can see -
auto visibleSize = Director::getInstance()->getVisibleSize();

DrawNode *drawnode1 = DrawNode::create();
DrawNode *drawnode2 = DrawNode::create();
DrawNode *drawnode3 = DrawNode::create();
DrawNode *drawnode4 = DrawNode::create();

drawnode1->drawDot(Vec2(0,0), 100, Color4F::BLUE);
drawnode2->drawDot(Vec2(visibleSize.width, 0), 100, Color4F::YELLOW);
drawnode3->drawDot(Vec2(visibleSize.width, visibleSize.height), 100, Color4F::WHITE);
drawnode4->drawDot(Vec2(0, visibleSize.height), 100, Color4F::GREEN);

this->addChild(drawnode1, 100);
this->addChild(drawnode2, 100);
this->addChild(drawnode3, 100);
this->addChild(drawnode4, 100);

AnchorPoint by default is 0.5 so I planned to see a perfect 1/4 circle on each corner of the screen. what you can see is that on the bottom the 1/4 is perfect but on the top it is showing only a portion of it. I think that the visible origin containing the window title.

the blue circle portion is: 47x49 pixels.
the green cicle + title is : 41 x 52 (the width may be different because the title hide part of it)

As I said at the beginning of my original post this is no issue on full-screen mode.

However, all Touch/ Mouse events base on visible size which does not include the title. therefor the glich you can see easily on the video I posted previously…

This seems like a bug in cocos2d-x I am able to reproduce it on standard Helloworld application. I wonder how come nobody notice that ?

http://cocos2d-x.org/docs/en/basic_concepts/sprites.html

and

http://cocos2d-x.org/docs/en/sprites/manipulation.html

slackmoehrle , I dont see how this is helping me out. maybe you answer someone else ?

What does your console say for screen size ?

When you click mouse what are the coordinates?
I feel like something is wrong with resolution or its policy

it is reproduced in the standard project settings. I didn’t change anything. just add a touch listenner or mouse and add the lines of code I provided.

I am on a windows system. it does not reproduce on full screen but it is a pain to debug on full screen.

I tested it on the Hello Word project + similar code, and it works just fine.
I used the engine version from the github master + VS2017 and I retargeted the win 32 project to the new version of the win sdk (10.0.x).

So try a new version of the engine, try to create a new project.
If this did not help, then create an issue on the github.

My testing on other platforms works as well. Thanks @Priority10 I was trying to get a VM going to test this on Windows specifically.

I did change the basic resolution of the viewed rect which seems to cause it. when the screen has right/left black portion the visible screen keep going up and pass the real visible screen. When I understand that I just changed my window resolution to something else and it solves the issue. however this is definitely a bug in cocos-2dx. if you wish that I will send you the exact parameters I have to send to the create windows function I can help you reproduce it.

Please show me what you changed in the default project and why.

Yes, let us try and help in more detail. I don’t want you doing something unconventional if we can help.

I don’t know what to tell you guys. this problem comes on and off. I am unable to understand when and why. now it reproduced with whatever resolution I am using.
I will investigate it more and understand it better. but something is fishy in the library. I just need to figure it out. I suspect it relates to me using 3 displays.

3 displays while developing/testing games could be part of the issue. When I play and debug my games I just use a single display. If I am on my laptop, I just use the laptop display.

@slackmoehrle Must say that I tried with one screen as well. this problem keeps coming.

The main problems seem to be related to the title of the windows. somehow cocos2dx treat this part as a visible region while it is definitely not.

I manage to reproduce it easily on my windows 10 with untouched cocos2dx sample created using 3.16

Thanks for mentioning steps to reproduce.