How can I change the position of an object through the ccp function in cocos2d? - iphone

I am new to the cocos2d framework, so I took the sample application from this location and tried to modify it. By using the line
target.position = ccp(winSize.width , (target.contentSize.width/2)+actualY);
the object is shown in landscape. When the app runs it will show me the output in landscape mode, and the targets are shown from the starting the landscape mode of one side to another side. I want to show it from the the end of the landscape mode to the start. How can I do this?
Also, I want to show in portrait mode. How can I do this as well?

ok use ccp function. the body will be like this. ccp(x, y)

OK, cpp function means the same as CGPointMake(x,y) - only creates a point for position of target.
winSize.width - will be xcoordinate of target, and
(target.contentSize.width/2)+actualY - ycoordinate

What version of cocos2d u using? You can change orientation of app in the app delegate.. From landscape to portrait..

ok I solve that problem, I simply change the position of x and y through ccp function

Related

Change resolution (chooseable)

I want to change the resolution of my game in the menu. Now I've made a nice method where it looks up if the resolution is available for this PC and changes then it does:
graphics.PreferredBackBufferWidth = iWidth;
graphics.PreferredBackBufferHeight = iHeight;
ScreenManager.sScreenSize.X = iWidth;
ScreenManager.sScreenSize.Y = iHeight;
graphics.ApplyChanges();
sScreenSize is just a rectangle for the buttons to position and such things.
When I call this function at start then everything is right, but if I call it in the menu, the resolution changes, but nothing that gets drawn changes. So I see only some percent of the screen. How do I fix it? I can only find online how to initialize the resolution.
I had to remove the screen before I changed the resolution and then add the screen then again.

Block external Window (TV-Out) from changing orientation

I'm playing around with the TV-out Adapter for the iphone. My goal is to have an external window display on my tv in order to play movies from my iphone.
the big problem I've got now, is that if the phones orientation changes (physically) the window that shows on the tv turns as well. which is of course unwanted behaviour..
So far i return NO from shouldAutoRotateToInterfaceOrientation. But it still turns and turns.
I'm very grateful for any help on that topic
cheers
sam..
Ah well the solution was rather simple.
I had to assign a RootViewController to the Window that I'm using. Said Rootviewcontroller then needs to implement a shouldAutoRotateToInterfaceOrientation Method (that of course returns NO).

How to rotate OpenGL to fit iPhone Landscape mode?

I am porting an existing cross-platform program I have made in C++ and with OpenGL/ES on the iPhone. Please keep in mind I do not know anything about Objective-C...
I have just briefly edited the Objective-C files of one of the tutorials to initialize OpenGL properly for the iPhone, and to simply call my C++ multi-platform code for everything else.
My program will only run in landscape mode, that is why I have set it as the only supported interface orientation (in the info.plist file).
What I want to know is how I should tell OpenGL to rotate according to the landscape mode. Currently I have added a glRotate that does it before draawing, but it is a dirty trick.
Another thing : I try to convert the touches into mouse click coordinates equivalent with another quick method, and I get a point located at a distance of 80 pixels on the X axis and 80 pixels on the Y axis. I added yet another dirty fix (with GlTranslatef) to this mess and I get the correct coordinates, except... color picking is broken.
To be clear, color picking does not detect anything on the 160 first pixels on the left (which is both 2 * 80 and 480 - 320, so, huh, 99% chance it is caused by my dirty code...)
What is the proper way of dealing with this ?
You shouldn't have to do anything to use OpenGL in landscape mode. I suspect you aren't actually going into landscape mode. You need to override shouldAutoRotateToInterfaceOrientation: in your view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
return orientation == UIInterfaceOrientationLandscapeLeft; // Or ...Right
}
To verify that it's working, put some random controls (e.g., empty buttons) in the corners of your view, with Interface Builder in landscape mode, and see where they pop up.
On iPhone 3G, this is a bad idea. Rotate using shouldAutoRotateToInterfaceOrientation use OpenGL hardware to perform this operation, so it is better to use a rotation in your OpenGL code. If you have no performance issue, keep it simple.

How can i test tilt efftect? - IPhone Simulator

I am trying to write a game. That game uses tilt effect, but i don't know how to test it on Iphone Simulator 3.0.
I search it on internet, but the result is zero. How can i...?
Short answer: You can't, not directly. You have to use a real device.
Longer answer: You could subclass UIAccelerometer and do as you like. You could simulate input, or write a client and server pair that sends acceleration information from a real device to your app running in the simulator, or from your Macbook's accelerometer if you fancy waving your laptop around.
Try https://code.google.com/p/accelerometer-simulator/. It does the same thing as iSimulate -- it sends accelerometer events from the phone to your computer -- but it's free and open source.
There's an application in the AppStore called iSimulate which lets you feed an actual device's accelerometer inputs into the sim. You do need to have a device for testing.
ON a related note, you can also capture accelerometer data from safari running on your iphone/ipad
See this demo http://www.webdigi.co.uk/blog/2012/using-an-ios-device-to-control-a-game-on-your-browser/
Just saw this when asking a similar question - you can actually set the interface orientation now in the new xcode, so even though you can't 'tilt' it directly, you can make it to where it only supports landscape - then it will load the landscape view in the emulator! :D
From: http://developer.apple.com/library/ios/#documentation/IDEs/Conceptual/iOS_Simulator_Guide/InteractingwiththeiOSSimulator/InteractingwiththeiOSSimulator.html
Place the pointer where you want the rotation to occur.
Hold down the Option key.
Move the circles that represent finger touches to the start position.
Move the center of the pinch target by holding down the Shift key, moving the circles to the desired center position, and releasing the Shift key.
Hold down the mouse button, rotate the circles to the end position, and release the Option key.

iPhone accelerometer in web applications

I want my website to change its layout according to the device positon. The site has 2 layout types: vertical(height > width) ang horizontal(width > height).
do you see any solution?
upd: I don't see any complexity in changing the site layout. I want to know is there any event to handle.
p.s. will iphone's browser change its orientation if i rotate the device 90 degree?
Dave, tnx for emendation.
There is a javascript event called onorientationchange sent when the orientation changes and also there is a property called orientation on the window object that tells what the current orientation is.
See the documentation for more info and sample.