Is there a way to get two items to snap together?


(Cris) #1

Hello,

I am trying to design some children’s games for a book I am doing in iBooks Author. I would like to be able to drag two items together. If they match I want them to click together and not if they don’t match. Is this possible? If so can you point me in the right direction to get it to work?

Thanks


(Lucky) #2

See

I modified the code slightly so that they snap together on release

if(event['hypeGesturePhase']=='end'){
	console.log(a.id+' hit '+b.id)
	a.style.left=b.style.left
	a.style.top=b.style.top
}

hittest-1 2.zip (16.1 KB)
But if you want something to happen afterwards like an action you’ll need to keep building on that with code, I’m afraid there’s no other non javscript way to do this.


(Cris) #3

Thank you Lucky. That’s exactly what I need. I hope I can figure out how to apply it to my scene.
Much appreciated.