Can anyone please tel me how to make a Analog onscreencontroller follow the screen? I used the code to make it a HUD but the knob doesn't respond to my touch,please help!
You might be attaching the controller to the scene. That is the reason the knob is not working.
what you should do is set the controller as child scene to your scene
setChildScene(AnalogOnScreenControl);
Now it will work.
Related
I'm looking for help. I'm trying to make some puzzle game and I have thin scrollable layer at the bottom of my main layer which contains some puzzle shapes. I can scroll the layer and see every shape but shapes were positioned manually in code on the scrollable layer and the problem is, if I try to detect if I touched on sprite, which position is greater than 1024(in first iPad) it doesn't work. it doesn't work because touch can have position inside 1024X768 and the position of shape is for example 1500x100. to make it clearer, shapes are sprites and i try to detect them using CGRectContainsPoints method. Is there any other way to make it or have you any ideas? thanks in advance :]
What you could do is subclass your sprite, create a delegate for it and assign your main view/class as the delegate.
Implement the appropriate touch method, and send the message of what sprite was selected to your delegate (Main view or desired controller class).
With this every sprite has the same delegate, and sends a message to your controlling class as to what sprite has been selected and continue with desired functionality. No need for CGRectContainsPoint method.
This is cleaner, and more efficient.
Hope this helps!
I am developing a cocos2d based IPhone game where a scene replace another with a Left to Right Transition. The new scene has a background a bit bigger than the scene. That is just because I move it according to the device tilt to create a sort of 3D effect.
Unfortunately during the transition of the scene I can see the background outside the scene overlapping the previous one :(
I have then tried to use the z-order in such a way the previous scene should go on top of the new one bug it does not work the way it should.
do you have any suggestion?
Thank you in advance
I think you need do crop your scenes layer by overriding it's -(void)visit method.
That's how I did it:
- (void) visit {
glPushMatrix();
glEnable(GL_SCISSOR_TEST);
glScissor(cropRect.origin.x,
cropRect.origin.y,
cropRect.size.width,
cropRect.size.height);
[super visit];
glDisable(GL_SCISSOR_TEST);
glPopMatrix();
}
May be you'll need to play a bit with cropRect origin and size values.
Also you may need to add some device orientation changing support
My application has some screens support landscape mode which load some more data and have to re-render GUI, and one of them will load another view in landscape mode. But its seem the screen would be rotated before re-rendered or load another view, it is not nice looking.
So it would be better if there is an animation or a view to be shown when rotating.
Does anyone know how to do this please help me! Thanks so much!
You can do either one (or both); display additional animations or display a different view while rotating. I'm assuming you're working with a UIViewController, check out the documentation (specifically, 'Handling View Rotations').
Override both willRotateToInterfaceOrientation:duration: and didRotateFromInterfaceOrientation: to add and then remove your placeholder view.
You will need to override willAnimateRotationToInterfaceOrientation:duration: to perform any animations.
I haven't been able to figure this out. Could someone please help me? I am trying to stop one UIView in my app from rotating when the device is turned.
I am working on a drawing app. Right now, when the device is turned, all UI elements turn with it. What I am trying to do is have all the buttons, menus, etc. turn, but have my canvas UIView be static and ignore the rotation of the phone.
If the canvas view is a subview of a view that rotates, then it will rotate as well. It's inescapable.
If you have one element of a view that you do not want to appear to rotate, you have use a rotation transform to programmatically rotate that one view back to the orientation and frame you want it have.
You could use the following to prevent the view itself from rotating:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
return false;
}
Then manually rotate the individual elements you want rotated.
OP here. Rotating the view using CGAffineTransformMakeRotate() worked like a charm. Thanks, TechZen!
I need to have a preview of the camera but not in fullscreen. Actually I need to resize the camera view to manage place for my overlay view.
I need a resize camera view and not a truncated one.
Do you have any ideas/pointers to achieve this?
Thanks for your help :)
Regards,
Try the cameraViewTransform property of the UIImagePickerController.