swift - Slow responsiveness of sprite.xScale -


in spritekit game, wish resize sprite (named "manta" below) based on user vertical drag. drag should make sprite bigger while drag down should shrink it.

i have implemented uipangesturerecognizer , in rec.state == .changed, 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 not reliable, responsiveness of resizing sluggish , not useable in live game.

are there sprikekit tricks not aware of, give priority process or there better alternatives uipangesturerecognizer create such control in spritekit?

i wouldn't use gesture recognizers because easier if know touch point.

here example in sudo code might find works. of these functions can overridden inside of skscene, , position can found.

var dragging:boolean = false  touchesbegan() {    if (fingerhasclickedsquare == true)    {dragging=true}    else    {dragging=false} }  touchesended() {     dragging = false }  touchesmoved()  {    if (dragging == true)    {       manta.size.width = (fingerposition.x - squareposition.x) * 2 //this either needs *2 or /2 or *1 dont remember    } } 

if need further translating real swift code this topic shows of lines of code need touch position, , node touching.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -