Last visited

Community Reputation

About riens

You move scale - it works
you move a second time and the image jumps correct ?[/quote]
I don`t move scale - it works
I move scale - it jumps back before zoom
could you write down a sequence of actions you want to do ?[/quote]
swipe, pinch zoom
this corresponds to: moveby(1, 0), scaleby(delta, delta)
btw if you have icq message me and i'll add you[/quote]
I can create a new ICQ account if you have no jabber or skype

I'm wondering how your swiping works even with scale equals 1.[/quote]
I don`t need to swipe when scale equals 1 Only when we are zoomed.
in case that scale is 1 and aspectRatio is 1. These lines will not translate at all.
[/quote]
Yes, this is a feature. When aspectRatio == 1 we are on iPAD and don`t need to swipe the initial picture. On iPhone aspectRatio is 1.25 and the picture is partially invisible so we can swipe it.
Maybe you could try to explain how you want to handle swipe and pinch.
(code)
This code has one fallback. swipe, scale swipe, scale would not work since you have to accumulate this actions.[/quote]
I want to handle both swipe and scale in one place.
I also have moveTo(point) method, zoomIn() and zoomOut() and all of them are avaible for scripters. I used the approach you suggested, but it was a big pain to handle all scale-swipe-change scale target events

Render loop updates screen frequently.
I have in mind that you render your scene without translating it when handling pinch gesture.[/quote]
Here is the rendering code:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glLoadIdentity();
float scale = view->getScale();
CGPoint target = view->getTarget();
glTranslatef(target.x, target.y, 0);
glScalef(scale, scale * aspectRatio, 0);
glTranslatef(-target.x, -target.y, 0);
renderScene();
glPopMatrix();
renderUI();
As you can see, i translate to the target position, scale and translate back. No explicit translation handled.
Could it be that getScale() returns 1 and you get a division by zero in your touchesMoved routine ?[/quote]
Whoops, it is possible. Thank you, i`ll fix it right now.
Did you console log all your scale and translation values to see if they behave in correct way?[/quote]
Yes, they behave correct. In fact, my puzzle is already released on iPAD, but I cannot pass QA to release it on iPhone because they demand swiping up and down with initial scale

Hello!
I am making a 2D puzzle for iOS and currently I`m trying to implement zooming and scrolling with UIPinchGestureRecognizer.
Zooming is done this way: I have a target 2D vector which is a "zooming point". The code is:
glTranslatef(target.x, target.y, 0);
glScalef(scale, scale, 0);
glTranslatef(-target.x, -target.y, 0);
Target is being selected with gesture recognizer this way:
-(void)handlePinchGesture:(UIPinchGestureRecognizer*)recognizer
{
if (UIGestureRecognizerStateBegan == [recognizer state])
{
view->setTarget([recognizer locationInView:self]);
}
// Rest of the code omitted
}
Everything works just fine.
Initially the game was designed for iPAD, but I want it to work on iPhone and iPOD too. But iPhone and iPOD have different aspect ratio. To keep initial picture proportions I decided to make initial Y scale a bit bigger. Also this made possible to swipe the game field up and down with initial zoom factor. The code is:
glTranslatef(target.x, target.y, 0);
glScalef(scale, scale * aspectRatio, 0);
glTranslatef(-target.x, -target.y, 0);
This works just fine IF the game field is "centered" at the screen(e.g. when there are equal space in bot swipe directions(up and down)). But if we swipe the field up or down and begin pinch gesture, the game field jumps to the centre again.
I understand that I need to translate the gesture position by some offset, but I cannot figure how exactly for 3 days.