hyperandroid / CAAT

Canvas Advanced Animation Toolkit
hyperandroid.github.com/CAAT
MIT License
727 stars 117 forks source link

Dock with touch events #78

Closed ghost closed 11 years ago

ghost commented 11 years ago

Is the Dock() capable of responding to touch events as well as mouse events?

I added the following to the top of my CAAT script:

CAAT.TOUCH_BEHAVIOR = CAAT.TOUCH_AS_MOUSE;

But The dock does not respond to a finger dragging over it, the same page loaded into a browser works correctly with mouse input.

If I need to manually convert touch events into mouse events, is there any sample code to show how to do this.

TIA

Andy

hyperandroid commented 11 years ago

Hi Andy,

Dock is not supposed to work with touch events. Will give it a try and see if i can make it work. Thanks.

ghost commented 11 years ago

Hi, thanks, that sounds great.

I thought I would share my use case, in case it's a no-go.

What I want to do in my app is drag-n-drop an actor in the scene to one of the dock items.

so:

Touch actor to select it Drag over to the dock Scroll over the dock items until the actor is over the right dock item Release the actor Be able to invoke some code at that point to execute some animation to indicate the actor has been added to the dock item and invoke a backend action.

I am just trying to see if the pieces are in place, but if the end-game is not achievable (e.g. I won't be able to use the touch events to both drag an actor and trigger the dock at the same time) then I'll drop the idea and try another approach.

TIA

Andy

alexac1970 commented 11 years ago

Hi,

It should be nice than Actors with "setAsButton" react to touch events too.

Alex.

hyperandroid commented 11 years ago

They do. is there any issue ? Sumon game works ok on mobile with actors as buttons.

alexac1970 commented 11 years ago

I tried this code with template-with-splash.js and the button image that comes with the demos and i can click the button but i can't touch it:

CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH; var escena, contenedor, botonPista; var botones = new CAAT.SpriteImage().initialize(director.getImage("botones"),7,3); escena = director.createScene(); contenedor = new CAAT.ActorContainer().setBounds(10,10,600,300).setFillStyle('#0000ff').setAlpha(0.5); botonPista = new CAAT.Actor().setLocation(60,60).setAsButton(botones.getRef(),0,1,2,0,function(){alert('clic');}) contenedor.addChild(botonPista) escena.addChild(contenedor);

I tried in a windows 7 tactile notebook and in an ipod with cocoonjs. Is there anything wrong in the code?

I've just discovered that if i comment the first line, then i can touch the button.

hyperandroid commented 11 years ago

Remove CAAT.TOUCH_BEHAVIOR=... block. With multitouch you must check behavior yourself.

-ibon

takhimi commented 11 years ago

I`m sorry. Base on this code, mine still not working. Even when remove the CAAT.TOUCH.BEHAVIOUR line. With cocoonjs it will return error

Line 23179 File 1576987976 Tag TouchStart. TypeError Result of expression "node.ownerDocument" undefined is not an object..

Im stuck...

HextoryWorld commented 10 years ago

takhimi, try to update your cocoonjs launcher