Report a Bug

SIGN IN!

Make your entities mouse sensitive to the nearest pixel


With this plugin you can make your entites mouse sensitive to the nearest pixel. The plugin doesn't trigger if the mouse is over the entity sprite like normally. But it looks if the mouse is over an transparent or visible pixel also. With this you can listen to all common mouse events to interact with your entities.
Plugin URL:  http://bit.ly/MWzgYD
  Source/Support Files:  oldVersion.zip
More Information:  http://impactjs.com/forums/code/plugin-make-your-entities-mouse-sensetive-to-the-nearest-pixel/page/1

current Download: download version 1.1
(changed to a dropbox source, because it's easier to update)

Description

With this plugin you can make your entites mouse sensitive to the nearest pixel. The plugin doesn't trigger if the mouse is over the entity sprite like normally. But it looks if the mouse is over an transparent or visible pixel also. With this you can listen to all common mouse events to interact with your entities.

Changelog

# Version 1.1
There were many naming as well as structural changes of the code. Because the hover effect is applied to every entity of the same type without a hack of the impact core, this part was removed and the plugin now manage all mouse events around entities only. Maybe there will be a tutorial to implement those effects functioning if requested.
[FIX] onMouseOut was not been triggered while dragging
[FIX] the external plugin 'ImpactEvents' caused errors in weltmeister
[CHANGE] the event onReleaseRight is now called onRightRelease
[ADD] with ig.Game.pluginMouseSensitive.enabledInWeltmeister you can enable this plugin in weltmeister also
[ADD] with ig.Game.pluginMouseSensitive.dblClickTime you can set the delay to distinguish between click and double click
[REMOVE] the ability to create simple hover effects doesn't work as easily as I thought at first

Events

If an entity is defined with this plugin you have access to all common mouse events to interact with the entity. To manage those events a second plugin in this package is needed 'plugins.events'. This plugin is inspired by the ImpactEvents plugin of omatase, but causes no errors in the weltmeister editor. If you want to use omatase's version instead, maybe there will be some updates by omatase, you have to embed it only, because the naming of the functions are equal.

So here are the supported events:
onMouseOver, onMouseOut, onClick, onRelease, onRightClick, onRightRelease, onDoubleClick, onClickPerformed, onDrag, onDrop

New Entity Settings

  1. ig.module(
  2. 'game.entities.Example'
  3. )
  4. .requires(
  5. 'impact.entity',
  6. 'plugins.entityMouseSensitive',
  7. 'plugins.events'
  8. )
  9. .defines(function(){
  10.  
  11. EntityMale = ig.Entity.extend({
  12.  
  13. animSheet: new ig.AnimationSheet('media/char.png', 24, 32),
  14. size: { x:24, y:32 },
  15.  
  16. isMouseSensitive: true, // makes the entity sensitive to all mouse actions
  17.  
  18. init: function( x, y, settings ) {
  19. this.parent( x, y, settings );
  20.  
  21. // your code ... for example
  22. this.addListener("onClick", myOwnClickFunction);
  23. }
  24. });
  25. });


bigJim
A great plugin. I was having some difficulty with the left click until I commented out some code that was timing the clicks for a double-click action. Example:

// onDoubleClick
/*if( this.isClickable && this.clickPerformed && ig.input.pressed('checkLeftClick') ...more
   PLUGIN 
Contributed by:
Skar
View Profile
Category:Entities
Updated:August 6, 2012
Version:1.1
Rating:
Your Rating (0)
Average Rating (5)
Ready to get to the point?

Your Email will remain private and is only used for good. We promise!


Please use only letters, numbers or underscores.

SIGN UP!