Closed bluelemonade closed 6 years ago
@bluelemonade I don't understand your problem :/ if you still need help, I could try to assist in voice via Telegram or Skype or Google Hangouts.
hello,
you can find a capture of the issue: http://intern.bluelemon.de:8080/share.cgi?ssid=0lYDjOt ( NAS active between 8.00 and 21.00 MET)
you can see the comibation of scaling an rotating. when I change the rotation an change at the same time the scaling smaller then my minimal scaling, the sprite wanders out of the touch points. how can I avoid this.
regards
@bluelemonade well do not transform your object via those scaleX
scaleY
x
and y
convenience setters! If you do it this it transforms object relative to it's origin.
I think you should drop all code after // nicht zu klein machen
and instead limit the scaling at matrix.scale()
call. You don't want to apply too much up/down scale here.
Perhaps something like
const pic = event.target.target as DisplayObject;
...
matrix.translate(-transformPoint.x, -transformPoint.y);
matrix.rotate(gesture.rotation);
if (doScaling) {
const currPicScale = pic.scaleX;
const minScaleToApply = 0.7 / currPicScale;
const maxScaleToApply = 1.1 / currPicScale;
const scaleToApply = Math.max(minScaleToApply, Math.min(gesture.scale, maxScaleToApply));
matrix.scale(scaleToApply, scaleToApply);
}
matrix.translate(transformPoint.x, transformPoint.y);
pic.transform.matrix = matrix;
oh, thank you, indeed its stupid to scale the object. thanks
hi pavel,
I have used your lib a few time, works great. in the past I used the gesture seperated, panning rotation, zoom. Now I have to freerotate elements.
when the user rotates an sprite and chages the distance between the fingers the scaling works while rotating. when the user rotates a bigger angle the sprite moves away from the touchpoints.
is there a simple trick to prevent this? or should I only scale when the rotation is smaller then a defined value?
regards.