objective c - How to control CAKeyframeAnimation with touch gesture? -
i have caemitterlayer
animated along bezier path (closed form, '8', out of 4 control points) cakeyframeanimation
. want control animation slide of touch-finger along (but not on) path. how possible , possible?
make cgpoint click;
variable remember initial "drag" point, create local nsevent
handler...
[nsevent addlocalmonitorforeventsmatchingmask: nsmousemovedmask | nsleftmousedownmask handler:^(nsevent *e) { if ( e.type == nsleftmousedown ) click = e.locationinwindow; else "yourdelta" = click - e.locationinwindow; // pseudocode return e; }];
"yourdelta" offset of initial point current location... achieve similar results scroll events, monitoring nseventscrollwheelmask
... , looking @ e.deltax
, e.deltay
values.
edit: i'm not familiar event handling on ios.. same technique applied normal event handlers... ie.
- (void)touchesbegan:(nsset *)touches withevent:(uievent*)e { click = [e locationinview:_yourview]; } - (void)touchesmoved:(nsset *)touches withevent:(uievent*)e { "yourdelta" = click - [e locationinview:_yourview]; // pseudocode }
as "seeking" animation.. 1 possible way [layer addanimation:thenewanimation]
, using previous tovalue
's, instead of basing fromvalue
's of 0, or model layer
... use layer.presentationlayer
values instead? hard without seeing full content of cakeyframeanimation
.
Comments
Post a Comment