Jump to content
  • Advertisement
Sign in to follow this  
Kirl

[web] crossbrowser music switch + mousedown check?

This topic is 3988 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!