Jump to content

mouseup inside init function?


Ninjadoodle
 Share

Recommended Posts

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 :)

Link to comment
Share on other sites

Ah, I see your problem. :D 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).

Link to comment
Share on other sites

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

}

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...