ios - Scroll a node in constant distances-SWIFT -
i want know how scroll node in given distance, example 100 px . have done this:
override func touchesended(touches: set<nsobject>, withevent event: uievent) { fingerisonscroll = false } func roundto(value: int) -> int{ var fractionnum = double(value) / 100.0 let roundednum = int(ceil(fractionnum)) return roundednum * 100 } override func touchesmoved(touches: set<nsobject>, withevent event: uievent) { if fingerisonscroll{ touch: anyobject in touches { let touchloc = touch.locationinnode(self) let prevtouchloc = touch.previouslocationinnode(self) var jump = touchloc.x - prevtouchloc.x var myintvalue:int = int(jump) myintvalue = roundto(myintvalue) var jumpcgfloat = cgfloat(myintvalue) simple.position=cgpointmake(simple.position.x + (jumpcgfloat), simple.position.y) } } }
the problem when scroll left moves right , if scroll right doesn't move. thanks.
Comments
Post a Comment