当前位置: 动力学知识库 > 问答 > 编程问答 >

HTML5 isogenic engine mouse cursor

问题描述:

I'm a newbie to HTML5 game, and I'd like to know how to change the mouse cursor when I point out an building on a tile?

I created tilemap, created a Shop class extending IgeEntity class.

Then I have created an object "MyShop" which is an instance of Shop class.

And finally,

MyShop.occupyTiles(3,3, 2,2);

I'd like to change my mouse cursor to my custom cursor (from file) when I point out the shop.

And is it possible to get the object under the cursor when I click the mouse?

I mean, when I click my shop, I'd like to show something.

网友答案:

Use the mouseUp, mouseOver and mouseOut functions:

MyShop.mouseUp(function() {
    alert('you clicked the shop'); 
    // show the stuff you want here
});

MyShop.mouseOver(function() {
    console.log('hovering the shop', MyShop);
    $('body').css('cursor', 'pointer'); // jQuery cursor CSS change on the body, 
                                       //  see how you handle custom images
});

MyShop.mouseOut(function() {
    console.log('no longer hovering the shop', MyShop);
    $('body').css('cursor', 'default'); 
});

You can also chain them.

etc... Can't help you more until you make your question clearer.

分享给朋友:
您可能感兴趣的文章:
随机阅读: