Jump to content

[EnchantJS] Finding the Mouse Coords without touch event


theweirdn8
 Share

Recommended Posts

Hello guys,

 

I've been tickering around with EnchantJS and I have been unsuccessful on finding a way to find the mouse coordinates without touching/clicking on the screen.

 

I plan on making a RTS project and I will need to have the mouse coordinates available for the commander to move around the map freely without having to click to do so.

 

 

Does anyone know how to do this?

Link to comment
Share on other sites

No mention of it in the API.

Hmmm, enchant js dev mentions it on his blog.

http://blog.enchantjs.com/en/2011/11/22/shi3z-game-programming-2-how-to-become-a-game-programmer-in-48-hours/

 

You may have to write your own mouse motion listener.

This incomplete example uses jQuery to get the canvas offset. Getting the mouse coordinates on a canvas requires some browser kludges and jQuery makes it a little easier.

yourcanvas.addEventListener("mousemove", function(event) {var canvas = document.getElementById('yourcanvas'),var x = event.pageX - canvas.offsetLeft,var y = event.pageY - canvas.offsetTop;...});
Link to comment
Share on other sites

I too tinkered around with EnchantJS at one point.  I found it very good and very easy - up to a point.  After I hit that point, which involved getting support for features and bug fixes, I hit a wall.  Part of the problem is that the developers are Japanese and there was less English support and usage than Japanese.   Part of the problem is that the engine is simple to use but not especially feature-rich.

 

In the end, I gave up on Enchant, though I don't think it is useless.  I turned to Pixi first and then to Phaser.

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...