Sign in to follow this  

[web] crossbrowser music switch + mousedown check?

This topic is 3741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a js snake game and I want to include a music switch. Problem is how to stop an embedded midi file? "href="javascript:document.embeds['musicfile'].stop()" doesn't seem to work in most browsers. I also included a simple level editor to let people from the forums help me build levels, I already got a whole bunch of excellent designs. However clicking every individual cell becomes cumbersome very quickly, especially now I increased grid resolution. Currently an onclick (for every cell) will execute a function that either adds or removes the cell from the Walls array. But instead of checking onclicks, I want to put an onmouseover in every cell and check if the mouse button is down from within the function (so it becomes more like drawing). But I'm not sure how to check for this, as far as I know the mousedown event only fires once when the LMB is clicked so 'if(mouseDown)' doesn't seem to work. Is there any way to check if the mousebutton is being held down? See a WIP version here.

Share this post


Link to post
Share on other sites
I don't know about the music, but the mouse button thing isn't hard. Just track it yourself. E.g.



mousedown = false;

function onMouseDown(ev) { mousedown = true; }
function onMouseUp(ev) { mousedown = false; }

function onMouseMove(ev)
{
if (mousedown)
{
// do something
}
}



Then hook those functions to their respective triggers in HTML.

Share this post


Link to post
Share on other sites

This topic is 3741 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this