Ninjadoodle Posted October 14, 2014 Share Posted October 14, 2014 Hey guys Is there a way to use a mouseup function inside the init function? Thank you in advance! Quote Link to comment Share on other sites More sharing options...
Stephan Posted October 14, 2014 Share Posted October 14, 2014 What do you want to do exactely? Create a new event handler of trigger an existing mouseUp function? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted October 14, 2014 Author Share Posted October 14, 2014 I would just like to test whether the mouse has been released (inside the init function). I know you can set up a mouseup outside of init, just wondering whether you can do this from inside. I have a bunch of sprites being dragged all setup with as vars, which makes them local to init and I need to test whether they are being dragged/dropped. Thank you Quote Link to comment Share on other sites More sharing options...
Stephan Posted October 14, 2014 Share Posted October 14, 2014 Ah, I see your problem. You can't use mouseup in the init function of the object that is being initiated because the event is triggered on mouse down (which is before the init function). Unfortunately there is no isMouseDown property available. I suppose you mean that you want to check for mouse down during the init function of a new scene? I suppose it would be possible to check for a mousedown just before you are going to load a new scene. If you mean the init function of an object WITHIN the scene, it would be pretty straight forward and you could create an isMouseDown property yourself in main.scene. (In that case it would probably be even better to create some sort of isSomethingDragged property in game.scene instead). Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted October 15, 2014 Author Share Posted October 15, 2014 Hi Stephan Thank you for your help I managed to solve this when I realised how attaching mouse events to objects works, especially when also taking touch into consideration. The mouseupoutside event was giving me trouble, but now I understand it well ... myObject.mouseupoutside = myObject.touchendoutside = function() { // Do something when the player releases the object and the x/y of the pointer or touch, is not on the object itself} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.