Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi Niko At first thanks for the update.I was hoping for some Lights but i guess i'll have to wait. I have tried to develop some events but they are not working right. What i am doing is this.(I don't know if the syntax is right) engine.handleMouseDown = function (event) { mousedown (event) }; What i want to do is to create a function with prototype the handleMouseDown. So the mousedown (event) is like this function mousedown (event){ if (currentTool != null) { currentTool.handleMouseDown(event); } } The currentTool is selecred from a function that is selecting a tool depends on what button is pressed in the html. function selectTool(opt_toolNumber) { var toolNumber = opt_toolNumber; if (toolNumber == undefined) { currentTool = tools[0]; } else { currentTool = tools[toolNumber]; } } The tools table is like this tools = [ new SelectTool(), new MoveTool () ........... ] And in seperate javascript files i have the function for each tool. For the select tool is like this function SelectTool() { SelectTool.prototype.handleMouseDown= function(event){ var XPos = engine.getMouseX(); var YPos = engine.getMouseY(); alert (XPos+" "+YPos ); }; } engine is a global value. It gives always 0,0 no matter where i press the mouse. Can you please help me on this?What am i doing wrong? |
||||
|
What you are doing is not how it is supposed to be done. You need to o it like in tutorial 2: http://www.ambiera.com/copperlic... The part in there is about keyboard input, but it works in the same way with mouse input. The function handleMouseDown is only supposed to be called by you if you do your own mouse input. If you overwrite it, the engine doesn't get the events anymore, that's your problem. See the tutorial, it gets explained in there. |
|