now I'm trying to make a simple drag and drop game.
The first time I drag and drop a clone works fine, but it doesn't allow me to drag a clone anymore.
So I want to create as many clones as I drag.... and I have no idea how to do it.
Please take a look at my code first.
function init(){
var xCoordinate;
var yCoordinate;
var itemName;
$('#burger, #chicken, #fries, #hotdog, #soda').draggable({
containment: '#screen',
start: getPosition,
helper: 'clone',
stop: dragStop,
revert: 'invalid'
});
$('#A, #B, #C').droppable({
drop: itemDrop
});
}
function getPosition(event, ui){
xCoordinate = ui.offset.left;
yCoordinate = ui.offset.top;
};
"function getPosition" is simply to get x and y coordinates of the original draggable item so that the clone can be placed at the same position.
I understand I have to comand 'duplicate clones!!' under the droppable function, but don't know how to do it.
The code should provide a function for the
drop
property. This function should clone the helper and append it to thedroppable
. I have provided a basic example which you can apply to your implementation.HTML
Javascript
Working Example http://jsfiddle.net/2W4jA/