IOS | Techbirds | Page 3
Step1:Making the sprite at the angle where we want to place the b2body:Assuming rX and rY are the scaling factors
CCSprite *rect=CCSprite::create(“rect.png”); rect->setScaleX(rX); rect->setScaleY(rY); rect->setRotation(-7); rect->setPosition(ccp((winSize.width*0.5)/PTM_RATIO, (winSize.height*0.5)/PTM_RATIO)); this->addChild(rect,1);
CCSprite *rect=CCSprite::create(“rect.png”); rect->setScaleX(rX); rect->setScaleY(rY); rect->setRotation(-7); rect->setPosition(ccp((winSize.width*0.5)/PTM_RATIO, (winSize.height*0.5)/PTM_RATIO)); this->addChild(rect,1); |
Step2:Then make the corresponding b2body.Here i am loading the body from the physics editor,therefore adding it using the GB2ShapeCache by adding the plist file.
GB2ShapeCache::sharedGB2ShapeCache()->addShapesWithFile(“dummy.plist”); void class_name::add body() { b2BodyDef bodyDef; bodyDef.type=b2_dynamicBody; bodyDef.userData = rect; MyPhysicsBody *body=(MyPhysicsBody*)world->CreateBody(&bodyDef); body->setTypeFlag(1); body->SetTransform(b2Vec2((winSize.width*0.5)/PTM_RATIO,(winSize.height*0.5) /PTM_RATIO), rect->getRotation()); // add the fixture definitions to the body GB2ShapeCache *sc = GB2ShapeCache::sharedGB2ShapeCache(); sc->addFixturesToBody(body,”body_name in plist file”, rect); rect->setAnchorPoint(sc->anchorPointForShape(“body_name in plist file”)); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
GB2ShapeCache::sharedGB2ShapeCache()->addShapesWithFile(“dummy.plist”); void class_name::add body() { b2BodyDef bodyDef; bodyDef.type=b2_dynamicBody; bodyDef.userData = rect; MyPhysicsBody *body=(MyPhysicsBody*)world->CreateBody(&bodyDef); body->setTypeFlag(1); body->SetTransform(b2Vec2((winSize.width*0.5)/PTM_RATIO,(winSize.height*0.5) /PTM_RATIO), rect->getRotation()); // add the fixture definitions to the body GB2ShapeCache *sc = GB2ShapeCache::sharedGB2ShapeCache(); sc->addFixturesToBody(body,”body_name in plist file”, rect); rect->setAnchorPoint(sc->anchorPointForShape(“body_name in plist file”)); } |
Step3:Now make some changes in the update function which
Read More →
1,749 total views, no views today
Steps to Download/include/Use DropBox Core Api into your iOS Project/app Goto “https://www.dropbox.com/developers/core/sdks/ios” and download the core Api from there. Adding to existing projects Open your project in Xcode. Navigate to where you uncompressed the SDK and drag the DropboxSDK.framework folder into your project in Xcode. Make sure Copy items into destination group’s folder is selected.
Read More →
1,442 total views, no views today
In order to get the current date,time,we can use 2 methods-either using the localtime of the desktop or using GMT(GREENWICH MEAN TIME) //USING THE LOCAL TIME time_t time; struct tm * timeinfo; time (&time); timeinfo = localtime (&time); CCLog(“year->%d”,timeinfo->tm_year+1900); CCLog(“month->%d”,timeinfo->tm_mon+1); CCLog(“date->%d”,timeinfo->tm_mday); CCLog(“hour->%d”,timeinfo->tm_hour); CCLog(“minutes->%d”,timeinfo->tm_min); CCLog(“seconds->%d”,timeinfo->tm_sec); //USIMG GMT Replace the above line timeinfo = localtime (&time);withtimeinfo =gmtime
Read More →
4,360 total views, no views today
In order to enable multitouch just go to your AppController.mm. Then in the function didFinishLaunchingWithOptions after creating the EAGL View add the following line. [__glView setMultipleTouchEnabled:YES]; Then the didfinishlaunchingwithoptions will look like: (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Add the view controller’s view to the window and
Read More →
4,214 total views, no views today
Hi readers, In this blog we will be looking at the possibilities that are provided by Sencha in building your Mobile Applications. If you use Sencha to build native mobile applications you have two options: 1. Android 2. ios. For Windows, Blackberry you need to provide phonegap support. Building native application using sencha I expect
Read More →
2,072 total views, no views today