Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by empika

Hallo

Another plugin from me! ...well, two. One injects into the entity class and one into the game class.

The entity_utilities contains the isMouseInside function to check if the mouse is withing the entity aswell as the actual dragAndDrop function. Just pop the dragAndDrop function into your entities update function.

dragAndDrop takes a few arguments:
snap - bool: snap to the grid. No need to use snap_after_drop with this, just set that to false.
snap_after_drop - bool: snap to the grid when the mouse is let go
snap_grid_size_x - int: the grid size to snap to, defaults to the entities width
snap_grid_size_y - int: the grid size to snap to, defaults to the entities width


The game_utilities contains a function called entitiesUnderMouse which returns all the entities that are under the mouse when called. This means we can drag and drop only the entity under the mouse with the highest zindex.


Code is up on github: https://github.com/empika/ImpactJS-Plugins
And working demo files can be found here: https://github.com/empika/ImpactJS-Demo-Code

I will also keep the live demo (although compressed) so you can see how this stuff should be behaving here: http://labs.nixmc.com/~eddy/game/

Cheers and enjoy!

1 decade ago by Clive

Empika,

I would like to get in touch with you to discuss a private (game) project that I need help with. I live and work in London as an Enterprise Architect for a technology consulting company. If you have the time and would like to heard more please drop me a line to drclive@gmail.com.

Best,
Clive

1 decade ago by Jerczu

I don't know if it is a bug but in your demo once you drag the level map you cant drag the green face anymore.

1 decade ago by kaleong

Empika,

Thanks for your sharing, it is perfectly work on the browser, but in iphone... the dragging direction is totally opposite to my movement, any clue to modify the plugin??

Thanks again :)

1 decade ago by kaleong

For those who face the same question on native side

in entity_utilities.js

var mouse_x = ig.input.mouse.x - ig.game.screen.x;
var mouse_y = ig.input.mouse.y - ig.game.screen.y;

Cheers!

1 decade ago by trigoletto

I'm trying to run your demo but with no success :(

Uncaught TypeError: Cannot use 'in' operator to search for 'ontouchstart' in null html_button.js:34
ig.Input.inject.bindTouch html_button.js:34
ig.Game.extend.init main.js:30
Class impact.js:477
ig.System.ig.Class.extend.setGameNow system.js:63
ig.System.ig.Class.extend.setGame system.js:57
ig.Loader.ig.Class.extend.end loader.js:6

1 decade ago by paala

Same problem here.

9 years ago by dapinguo

Cannot use 'in' operator to search for 'ontouchstart' in null ~~~ AnyOne here?
Page 1 of 1
« first « previous next › last »