Saturday, June 30, 2012

63 days before the last day of my job

So time is flying but I am still stuck at the first tutorial because I cannot proceed if I cannot understand the code, just doing copy paste is not helping much

so my today goal is try to understand what the meaning of each of the complicated file

there is a helloworld.h and helloworld.m

the .h seem like is declare what is the classes and .m contain all the method and function

but i still cannot understand how the entire stuff running

on my helloworld.h i have 2 interface
===========================

@interface helloworld:CCColorLayer

@interface HelloworldScene: CCScene

( I am just guessing we need a scene, inside the scene we have a layer)

on my helloworld.m i have 2 implementation with 10 function
===========================================
@implementation HelloworldScene
-(id)init
-(void)dealloc

(I am guessing one is for initialize and one is for deallocate memory)

@implementation HelloWorld
-(void)spriteMoveFinished:(id)sender
-(void)addTarget
-(void)gameLogic:(ccTime)dt
-(id)init
-(void)update:(ccTime)dt
-(void)pauseGame
-(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
-(void)dealloc

(this one complicate out of me, there are 8 method inside the implementation of hello world, but which one of the method is the timer? i am guessing is the update???? let me check the code inside)

ok, after 2 minutes of reading,

i found inside the -(id)init there is 2 line of scheduling code


// Call game logic about every second
[self schedule:@selector(gameLogic:) interval:1.0];
[self schedule:@selector(update:)];

i guess this is the way it run the timer, every single second it will call the method "gamelogic and also "update"


the (void)gameLogic will calling the (void)addTarget every single second, and (void)addTarget will create an enemy every single second by first declaring the

CCSprite *target = [CCSprite spriteWithFile:@"Target.png" rect:CGRectMake(0, 0, 27, 40)]; 

target.position = ccp(winSize.width + (target.contentSize.width/2), actualY);
[self addChild:target];

notice all this SELF stuff is very confusing i guess you need to memorize them


inside the (void)update there are 4 for loop i guess is to loop through all the stuff every single second
for (CCSprite *projectile in _projectiles) {

              for (CCSprite *target in _targets) {}
}

for (CCSprite *target in targetsToDelete) {}

for (CCSprite *projectile in projectilesToDelete) {}




But I cannot found the code part of enemy movement and projectile movement inside the (void)update method i guess the code must be somewhere

after 2 minute of searching, i found this two code inside the (void)addTarget and (void)ccTouchesEnded


// Create the actions
id actionMove = [CCMoveTo actionWithDuration:actualDuration position:ccp(-target.contentSize.width/2, actualY)];
id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];
[target runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];


// Move projectile to actual endpoint
[projectile runAction:[CCSequence actions:
  [CCMoveTo actionWithDuration:realMoveDuration position:realDest],
  [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)],
  nil]];


Seem like the object CCSprite have its own runAction which will move auto once you set it

ok


So it only mean one thing, the (void)update is only used as a collision detection


first it loop the projectile, for each projectile it check is it collide with the target, if yes, remove both the projectile and the target


ok, i can understand 80% to 90% now, so can move along to the next tutorial






Tuesday, June 26, 2012

Following tutorial on coco2d

So I am following tutorial from http://www.raywenderlich.com/352/how-to-make-a-simple-iphone-game-with-cocos2d-tutorial

and here is what i get, pretty cool, even though i only able to understand 50% of the code, still very blur but i gain little confidence already, hooray


Noob Guide to install cocos2d

After a search on google, i decided to build my game base on cocos2d template

since they provided the following features

  • Scene management (workflow)
  • Transitions between scenes
  • Sprites and Sprite Sheets
  • Effects: Lens, Ripple, Waves, Liquid, Twirl, etc.
  • Actions (behaviors):
    • Trasformation Actions: Move, Rotate, Scale, Jump, etc.
    • Composable actions: Sequence, Spawn, Repeat, Reverse
    • Ease Actions: Exp, Sin, Cubic, etc.
    • Misc actions: CallFunc, OrbitCamera
  • Basic menus and buttons
  • Integrated Box2d and Chipmunk physics engine
  • Particle system
  • Text rendering support
  • Texture Atlas support
  • Tile Map support
  • Parallax scrolling support
  • Streak Motion support
  • High Score server (Cocos Live)
  • Touch/Accelerometer support
  • Sound support
  • Portrait and Landscape mode
  • Integrated Pause/Resume
  • Supports PowerVR Texture Compression (PVRTC) format
  • Language: objective-c
  • Open Source: Compatible with open and closed source projects
  • OpenGL ES 1.1 based
It is super cool

anyway, for a total noob, how do you install it right?

1. go to http://code.google.com/p/cocos2d-iphone/
2. click the download link on the left hand side, click the cocos2d-iphone-2.0-rc2.tar.gz 
3. after download finish, click the download arrow on your top right safari then double click to extract
4. click the magnifying glass to see where it land, 
5. press F4 on your keyboard to open up the application menu, click utilities, click terminal 
6. inside terminal ,go into the folder you have extract 
-  you can check where you are by typing pwd
-  to change directory, type cd <your directory>
-  to see the file under your current directory, type ls
7. install it by typing ./install-templates.sh -f


hopes it help

65 days before the last day of my job

i got 65 days left before the last day of my job and I hope i can at least get something going before I don't have any income

best case scenario is i hope i can publish the game before the last day of my job

I am just home from my day job and even though I am very tired I must force myself to learn Xcode

today objective is that I must learn how to use the view to display my hero and move my hero using touch screen

also why the hell blogspot is sooooo super bad with 0 page view and no one came to read my blog???? sigh

Sunday, June 24, 2012

complete my first tutorial

so i finish my first tutorial with probably 10% understanding what is actually going on,

it is very difficult indeed, so many button to click and so many different file and different code and different syntax

do note i learn java before and code for android but not Xcode, this is very challenging indeed


From Start to Finish, how long will it take for noob?


From Start to Finish, How long will it take?

I am still at the introduction stage, not even installing, i hope i can done it all before the last day of my 9-6 job?????

i got 2 months left before I am jobless, So i must push myself to the limit and finish an app as fast as possible?