In my SpriteKit game, I wish to resize my sprite (named "manta" below) based on user vertical drag. Up drag should make the sprite bigger while drag down should shrink it.
I have implemented a UIPanGestureRecognizer
and in rec.state == .Changed
, I have below code:
let deltaY = startPoint.y - currentPoint.y
newScale = mantaCurrentScale + ((deltaY / dragHeight ) * mantaScaleDiff )
if (newScale <= mantaMaxScale) && (newScale >= mantaMinScale) {
manta.xScale = newScale
manta.yScale = newScale
mantaCurrentScale = newScale
}
It works but is not reliable, the responsiveness of resizing is sluggish and not useable in a live game.
Are there any SprikeKit tricks I am not aware of, to give priority to this process or there are better alternatives to UIPanGestureRecognizer
to create such a control in SpriteKit?