I use Sprites to draw images in a D3D window. I draw an image on every sprite within a rectangle (0, 0, width, height) and use Matrix.Transformation2D to place the image in the rendered view.
Example:
using (Sprite s = new Sprite(device))
{
s.Begin(SpriteFlags.AlphaBlend);
Matrix tranz = new Matrix();
tranz =
Matrix.Transformation2D(new Vector2(0, 0), 0.0f,
new Vector2(scale, scale),
new Vector2(0, 0), Geometry.DegreeToRadian(angle),
new Vector2(positionX, positionY));
s.Transform = tranz;
Vector3 spriteCenter = new Vector3(0.0f, 0.0f, 0.0f);
Vector3 sprPosition = new Vector3(0.0f, 0.0f, 0.0f);
s.Draw(someTexture, new Rectangle(0, 0, width, height),
spriteCenter, sprPosition,
Color.FromArgb(0xff, 255, 255, 255));
s.End();
}
How can I detect that a certain image was clicked?
Known parameters: 1. Mouse position: mouseX, mouseY 2. All transformation2D parameters 3. Size and position of the image within a sprite.
This should be enough data to get what I want, but I have no clue what to do.
BTW - no world transformation nor other to include in the calculation. I Just transform the sprites.