Archive for the ‘iPhone’ Category

27
Apr
NSMutableAttributedString *myAttrStr = [[NSMutableAttributedString alloc] initWithString:@"my test string"]; // Creating a NSAttributedString object

CGColorRef myRedColor = [UIColor redColor].CGColor; // Creating a CGColorRef to set the value to

NSDictionary *newAttribute = [NSDictionary dictionaryWithObject:(id) myRedColor forKey:(id)kCTForegroundColorAttributeName]; // Setting the foreground attribute value the color reference created.

[myAttrStr addAttributes:newAttribute range:NSMakeRange(0, [myAttrStr length])]; // Setting the attribute dictionary to the NSAttributedString object

, ,

27
Apr

Let us say you have a sprite named “sprite1″ and you need to find out whether any action is running on it or not by

int actionsCount = [sprite1 numberOfRunningActions];

27
Apr

Each CCNode and its descendants has the ability to get a position relative to the scene:

CGPoint worldCoord = [mySprite convertToWorldSpace: mySprite.position];

This world Coordinate will be relative to the scene as opposed to the parent node!

27
Apr
b2Vec2 vel = body->GetLinearVelocity();

27
Apr

Use ‘CCEaseIn’ action in cocos2d for obtaining acceleration in the beginning.

// acceleration at the beginning
id action = [CCMoveTo actionWithDuration:2 position:ccp(100,100)];
id ease = [CCEaseIn actionWithAction:action rate:2];
[sprite runAction: ease];

27
Apr
CCLayer* subview = //initialize
[subview setPosition:ccp(X,Y)];

[self addChild:subview];

25
Apr
[NSObject cancelPreviousPerformRequestsWithTarget:self];

The above code will cancel all selectors called with target “self”

, ,

25
Apr

After you’ve successfully unlocked your iphone, you can follow these simple instructions to take a backup of the activation ticket:

Step 1: Launch Cydia

Step 2: Install iFile (skip this step if you have already installed iFile)

  • Tap on the Search tab
  • Search for iFile
  • Tap on iFile from the search results
  • Buy iFile as it is a paid jailbreak app
  • After you have purchased iFile, tap on the Install button in the top right corner.
  • Then tap on the Confirm button
  • Tap on the Return to Cydia button when prompted

Note: If you don’t want to use iFile, you can always SSH into the folder on your iPhone and copy the contents to your computer.

Step 3: After iFile is successfully installed, press on the Home button and launch iFile from the iPhone’s Home screen.

Step 4: You need to navigate to the Library folder:

  • Tap on /var (top left corner)
  • Then tap on the root folder from the list
  • Then tap on the Library folder

Step 5:  Here the objective is to create the zip file of the Lockdown folder as it contains the activation ticket:

  • Tap on the Edit button in the top right corner
  • Then tap on the Lockdown folder to select it
  • Then tap on the zip icon (second icon from the left at the bottom)
  • Here you will be prompted to select the name of the archive
  • You can either leave it as Lockdown or name the archive and tap on the Create button
  • iFile will create the archive file in the Library Folder

Step 6: Email the archive file that you have just created to yourself.

  • Tap on the archive file to select it.
  • Then tap on the Mail icon (third icon from the right at the bottom)
  • Enter your email address, the appropriate subject and then tap the Send button.

25
Apr

  • Scene management (workflow)
  • Transitions between scenes
  • Sprites and Sprite Sheets
  • Effects: Lens, Ripple, Waves, Liquid, etc.
  • Actions (behaviours):
    • Transformation Actions: Move, Rotate, Scale, Fade, Tint, etc.
    • Composable actions: Sequence, Spawn, Repeat, Reverse
    • Ease Actions: Exp, Sin, Cubic, Elastic, etc.
    • Misc actions: CallFunc, OrbitCamera, Follow, Tween
  • Basic menus and buttons
  • Integrated with physics engines: Box2d and Chipmunk
  • Particle system
  • Fonts:
    • Fast font rendering using Fixed and Variable width fonts
    • Support for .ttf fonts
  • Texture Atlas support
  • Tile Map support: Orthogonal, Isometric and Hexagonal
  • Parallax scrolling
  • Motion Streak
  • Render To Texture
  • High Score server (cocosLive library)
  • Touch/Accelerometer on iOS
  • Touch/Mouse/Keyboard on Mac
  • Portrait and Landscape mode on iOS
  • Sound Engine support (CocosDenshion library) based on OpenAL
  • Integrated Pause/Resume
  • Integrated Slow motion/Fast forward
  • Fast textures: PVR compressed and uncompressed textures
  • Point based: iPhone4 + RetinaDisplay mode compatible
  • Language: objective-c
  • Open Source: Compatible with open and closed source projects
  • OpenGL ES 1.1 (iOS) / OpenGL 1.5 based (Mac)

25
Apr

External/3rd party libraries used by cocos2d or any other project.

  • Chipmunk/: physics library
  • Box2d/: physics library
  • TouchJSON/: JSON parser
  • Tremor/: OGG audio decoder