How to convert world position to canvas click
by Andy Hawkins · in iTorque 2D · 11/19/2012 (7:01 am) · 1 replies
I have some code to fire at the cursor and I have set up a canvas like this. Problem is when I click on the screen I need to know where the player is on the canvas as well. However when I run the code touchScreenUI.getCanvasPoint(%obj.getPosition()); it returns numbers like -511, 477 when the mouse coords are coming back as -22, -10. It seems like the function is broken. How do I convert from world position to screen coords so I can get a vector to the mouse point to fire at it?
new t2dSceneWindow(touchScreenUI) {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "0 0";
Extent = "800 600";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
lockMouse = "1";
useWindowMouseEvents = "1";
useObjectMouseEvents = "1";
};
Torque 3D Owner Scott Warren
Edit: I think this is closer to getting your solution:
www.garagegames.com/community/forums/viewthread/132383