The 4th and final chapter (for a while) of my iBook is now available…

Well I’ve made it through 91 pages! Phew, I feel like a writer.  I’ll be breaking for a bit on this project, but not before I give away yet another chapter for FREEEE…..

Chapter 4 goes into everyone’s not-so-favorite subject, Creating Your Own Classes with Cocos2D!  But don’t worry, I’ve made this as easy as possible. And of course there’s lots of fun images, and even some video.

If you don’t have an iPad, you can view it online as a PDF or download it as a PDF. Click here to grab it! Just remember, you miss out on the video and some of the nice formatting as a PDF.

And for you lucky folk with an iPad and a recently updated version of iBooks, you can download the latest version by clicking here if you are reading this from your iPad (it might take a bit to load) And I would probably recommend deleting the old version of the book if you previously downloaded it.

And you can also download a zip file of the iBook, by clicking here, then once unzipped on your home computer, you can just drag the iBooks file to iTunes. Sync your device and enjoy!

Advertisements

4 thoughts on “The 4th and final chapter (for a while) of my iBook is now available…

  1. Vishal says:

    Justin – Looks good. However on my device, iBooks crashes each time I try to scroll through to chapter 2. Figured I’d give you a heads up.

  2. here is the answer i did for Test 1 works fine but i get message in console don’t know why

    CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: 3.00 to 1.00

    -(id) init
    {
    // always call “super” init
    // Apple recommends to re-assign “self” with the “super” return value
    if( (self=[super init])) {

    winSize = [[CCDirector sharedDirector]winSize];
    enemy = [CCSprite spriteWithFile:@”enemy_still.png”];
    enemy.position = CGPointMake(winSize.width/2, winSize.height/2);
    [self addChild:enemy z:1 tag:kEnemyTag];

    leftBoarder= 0;
    rightBoarder =winSize.height;
    topBoarder = winSize.height;
    bottomBorder = 0;
    delay=5;

    [self schedule:@selector(walk:) interval:1.0/5.0f];

    [self schedule:@selector(gameLoop:) interval:1.0/30.0f];
    maxWalkNum = 2;
    currentWalkNum =1;

    }
    return self;
    }
    -(void)walk:(ccTime)dt{

    [self schedule:@selector(goToDirection:) interval:delay];

    delay=arc4random()%5+1;
    walking=YES;
    NSString *enemyTexture = [NSString stringWithFormat:@”enemy_walk%i.png”,currentWalkNum];
    [enemy setTexture:[[CCSprite spriteWithFile:enemyTexture]texture]];

    if (currentWalkNum == maxWalkNum) {
    currentWalkNum=1;
    }else {
    currentWalkNum++;
    }

    }
    -(void)goToDirection:(ccTime)dt{
    randomDirection= arc4random()%5;
    speed=arc4random()%5+1;
    NSLog(@”the random direction is %i”,randomDirection);
    NSLog(@”speed is %i”,speed);
    NSLog(@”delay is %i”,delay);

    }

    -(void)gameLoop:(ccTime)dt{
    // [self schedule:@selector(goToDirection:) interval:delay];
    if ([self enemyIsInBounds:enemy]) {

    switch (randomDirection) {
    case kLeftDirection:
    enemy.rotation=90;
    enemy.position=CGPointMake(enemy.position.x -speed, enemy.position.y);
    if (walking==NO) {
    [self schedule:@selector(walk:) interval:1.0/5.0f];
    }
    break;
    case kRightDirection:
    enemy.rotation=0;
    enemy.rotation=270;
    if (walking==NO) {
    [self schedule:@selector(walk:) interval:1.0/5.0f];
    }
    enemy.position=CGPointMake(enemy.position.x + speed, enemy.position.y);

    break;
    case kUpDirection:
    enemy.rotation=0;
    enemy.rotation=180;
    if (walking==NO) {
    [self schedule:@selector(walk:) interval:1.0/5.0f];
    }
    enemy.position=CGPointMake(enemy.position.x, enemy.position.y+speed);
    break;
    case kDownDirection:
    enemy.rotation=0;

    if (walking==NO) {
    [self schedule:@selector(walk:) interval:1.0/5.0f];
    }
    enemy.position=CGPointMake(enemy.position.x, enemy.position.y -speed);
    break;
    case kStopDirection:
    walking=NO;
    enemy.position=CGPointMake(enemy.position.x, enemy.position.y);
    [self unschedule:@selector(walk:)];
    enemy.texture=[[CCSprite spriteWithFile:@”enemy_still.png”]texture];
    break;

    default:
    break;
    }

    }else {
    if (enemy.position.x > winSize.width) {
    walking=NO;
    enemy.position=CGPointMake(enemy.position.x, enemy.position.y);
    [self unschedule:@selector(walk:)];
    [self goToDirection:delay];
    enemy.texture=[[CCSprite spriteWithFile:@”enemy_still.png”]texture];
    enemy.position=CGPointMake(winSize.width, enemy.position.y);
    }else if (enemy.position.x winSize.height) {
    walking=NO;
    enemy.position=CGPointMake(enemy.position.x, enemy.position.y);
    [self unschedule:@selector(walk:)];
    [self goToDirection:delay];
    enemy.texture=[[CCSprite spriteWithFile:@”enemy_still.png”]texture];
    enemy.position=CGPointMake(enemy.position.x, winSize.height);

    }else if (enemy.position.y winSize.width || sprite.position.x winSize.height || sprite.position.y<0 ) {
    return NO;
    }
    return YES;

    }

  3. the thing is i don’t see where i’m calling the same selector twice
    i think its this line[self schedule:@selector(goToDirection:) interval:delay];
    i’m up to chapter 5 and i gotta say its really a great book so far really enjoying it

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s