NSAlert *alertView = [NSAlert alertWithMessageText:@"title" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"message"]; [alertView runModal];
Archive for the ‘Cocos2d x’ Category
CCCallFunc call1 = CCCallFunc.actionWithTarget(this,new SEL_CallFunc(tracingUnschedule));
The parameter should contain the target and the Call Function which is ‘tracingUnschedule’ in the above given example.
In cocos2d x for windows ccmenu is almost same as that in normal cocos2d.
Here is a sample code. We can add two items in the menu:menuItem1 and menuItem2.
CCMenuItemSprite menuItem1 = CCMenuItemSprite.itemFromNormalSprite(in1, in2, this, new SEL_MenuHandler(informationAction)); CCMenuItemSprite menuItem2 = CCMenuItemSprite.itemFromNormalSprite(in3, in4, this, new SEL_MenuHandler(buttonAction));
In the above code, in1 and in3 are normal sprites and in2 and in4 are selected sprite.Next parameter this is the target. and buttonAction and the informationAction are touch functions.
CCMenu menu1 = CCMenu.menuWithItems(menuItem1, menuItem2);
Now we create the ccmenu menu1 with the above menuItems.
Consider a UITableView object, myTableView.
// To make the background of the tableview transparent, use the following code : myTableView.backgroundColor = [UIColor clearColor];
(or)
[myTableView setBackgroundColor:[UIColor clearColor]]; // The above code will make the color of the tableview's background transparent.
//Now sometimes, this code will not do the trick. In such cases, what you have to do is use the following line of code along with the above code. myTableView.backgroundView = nil;
(or)
[myTableView setBackgroundView:nil]; // The above code will make the background view to nil.
cocos2d family spreads to the last important platform: Windows Phone 7. This branch is named: Cocos2d-x for XNA.
Beta release download: http://cocos2d-x.googlecode.com/files/cocos2d-x-for-xna-0.1.0.zip
Github repository: http://github.com/cocos2d/cocos2d-x-for-xna/
Inheriting the open source spirit from cocos2d-iphone, this branch is also open & free under MIT License.
Many developers hope that WP7 can support C++ and GCC, but the bitter reality is that Windows Phone 7 has not open native language layer and no OpenGL ES support. We have no choice except porting the whole cocos2d framework into C# language, base on Microsoft’s XNA framework. In this way, we can migrate cocos2d games onto WP7 only by programming languages translation, without any knowledge of the difference between OpenGL ES and XNA required.
But features below are semi-finished or TBD in the next version:
- Transition
- Grid
- Dispatcher of hardware keys messages
- Accelerometer
Regards-http://www.cocos2d-iphone.org/
For getting pinch coordinates while using UIPinchGestureRecognizer in cocos2d,
-(void)handlePinchFrom:(UIPinchGestureRecognizer*)recognizer
{
// How to get the coordinates.
CGPoint touchLocation = [recognizer locationInView:recognizer.view];
touchLocation = [[CCDirector sharedDirector] convertToGL:touchLocation];
touchLocation = [self convertToNodeSpace:touchLocation];
// How to get the scale.
float scale = recognizer.scale;
}
For calling a scheduler function in cocos2d-x , use the following code,
this->schedule( schedule_selector(HelloWorld::scheduleFunc), 1.0 );
This will call the ‘scheduleFunc’ every second
Note : ‘scheduleFunc’ must be declared as public
For removing a sprite in Cocos2d-X, use the following line of code,
this->removeChild(sample, true);
this will remove the sprite ‘sample’ from the scene
1. Make the directory of the terminal to the folder where the cocos2d-x installer files are present.
2. Now execute the following line in the terminal
./install-templates-xcode.sh -f -u
3. This will prompt you to give input the versions of Xcode available on the system to which you wish to install Cocos2d-x. Give the input as how you wish to be and it is done.
For setting a colored layer in cocos2d X, use the following sample,
In HelloWorldScene.h,
class HelloWorld : public cocos2d::CCLayerColor
In HelloWorldScene.cpp
Put these lines inside the init()
if ( CCLayerColor::initWithColor( ccc4(255,255,255,255) ) )
{
//Colored layer
return true;
}




