RobyDX / SharpDX_D3D12HelloWorld

DirectX12 Hello World samples created with SharpDx and C#
http://www.notjustcode.it
MIT License
15 stars 3 forks source link

[Question] SharpDX Mouse Input #2

Open JakubK opened 9 years ago

JakubK commented 9 years ago

Hi @RobyDX ! I just wanted to ask you for something,I'm quite new to SharpDX,I've been learning XNA,but I want to learn SharpDX.I've noticed that it's pretty similar, but I want to know how to detect mouse click or mouse over on the Texture2D,but I can't find anything in the Internet (I'm using the SharpDX Toolkit and Game class),can you help me? Regards!

RobyDX commented 9 years ago

Hi, collision detection (2D or 3D) can be detected in many ways. One example for 2D items is to get mouse position from form, get pixels from the texture and check if alpha is 0 (transparent) or 1 (opaque). Of course you must compute the position of the pixel based on texture position. Collision detection are part of a game engine and depend on your needs

JakubK commented 9 years ago

@RobyDX Now I'm using for 2D mouse detection this Idea: I'm getting the currentMouseStateX and Y and I'm Multiplyin that by Window's Width and Height and It's working for me perfectly,but I'm wondering now what to do If my Camera will change It's position