I am building this simple HTML5 drag and drop game using Craftyjs.
- I created an entity let's call it E1 with some components, one of the components is "
Draggable
". - I created a new entity E2 and made it as a clone of E1 (now E2 should have a copy of all E1's properties and components)
on run, E2 is cloned with the same properties and attribute but it is not draggable!
var E1 = Crafty.e("2D, Canvas, apple, Draggable, Gravity, Collision");
var E2 = E1.clone();
E2.attr({x:100, y:100});
E2.addComponent("Draggable");
E2.enableDrag(); E2.bind("Dragging", function(){ console.log("E2 is being dragged"); });
I tried to:
- force add the Draggable component with
E2.addComponent("Draggable")
but it won't work! - bind the Draggable events like "
Dragging
" and "StartDrag
" but it won't work either! - force enable drag by using "
enableDrag
"method but that did not have any effect either :( consloe.log
whether or not E2 has Draggable component by usingE2.has("Draggable")
and it returned yes!
FYI: all other functions like MouseUp and MouseOver are not working for E2 as well even if I add them later any ideas of what is making the Draggable component not working in the cloned entity?