Hi to all!!!
I am proud to introduce you my new game… Destroy The Oldies. You can check it and download here
And here is the webpage.
Hope you like it!!!
Hi to all!!!
I am proud to introduce you my new game… Destroy The Oldies. You can check it and download here
And here is the webpage.
Hope you like it!!!
As you can guess, the title of the post is a joke…I think a lot about very interesting things…though….nobody knows it. That’s why I am starting a new category on my blog, this is the “thinking” category. In it I’ll post all my strange ideas and that stuff.
This first idea that I am posting is about iOS. As you know, I have and enjoy my iphone and never did a jailbreak. But some times I had been thinking about that because I think that the iOS needs a block screen like Element. Element is an aplication that you can find on Cydia and let you change the lock screen putting some very valuable information in it like new mail, weather, rss, and some other stuff.
So, as you can guess, with this two simple things we have the lock screen all user-configured and the developers can put their applications in it.
Some examples:
If I develop a game with a lot of players and friends around internet I would want them to share their new records and could be great if the records appear in that screen automatically.
Other good example is an rss reader.
One valid solution for both examples is the push notification service, but If I want to see the things without problems this is not a real solution because it only works with few notifications. If you have a lot of them you will have a real mess with push.
So… ¡apple people!, hear my pray and make it better and real
Hi to all!
Today I’m going to explain one little tip I found few days ago. This is not a real howto or a big manual, but only a little trick to make your games even better.
The problem
In my game I have one menu in which one of the options is “start game” and, when you touch this option the scene of cocos changes to the game scene.
In the game scene there is some object that have a box2d body and some velocity and this objects are set in the very begining of the scene (I mean, in the init method).
What I wanted to do is to stop the game just in the moment the game scene starts and wait until the “touch” event of the user to resume game, but I didn’t wanted to change my init method or anything.
The solution
The easy solution that I thought was to put an [[CCDirector sharedDirector] pause]; in the end of the init method…but… this is not good for what I wanted because I was pausing the game before the scene object is returned. And the effect was that I was pausing the game in the menu scene, not in the game.
So, the final solution that was great for me was pretty simple too.
- first of all I had to set my “replace scene” method for one call with transition. Just like this:
[[CCDirector sharedDirector] replaceScene:[CCCrossFadeTransition transitionWithDuration:0.5f scene:[Attack scene]]];
- second and was to set the onEnterTransitionDidFinish method in my game scene:
-(void) onEnterTransitionDidFinish{ [super onEnterTransitionDidFinish]; [[CCDirector sharedDirector] pause]; }
It’s very important the “super” call inside the method.
- And the last thing was to set the resume call in the correct position. In my case was in the touchesBegan method:
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ // boring code [[CCDirector sharedDirector] resume]; //more boring code }
And that’s all.
So, as always, hope you liked it and enjoy
First of all: Hi, and welcome to my new blog
For my first post I am going to talk about a little thing that I am using in my new game that I hope will be on app store in a few days.
This thing I call auto-hidden labels..this is because are labels and are self-hidden
Ok, stop joking and start with the code.
The game I am developing is some kind of breakout game and as this we have a ball, a pallete and some blocks to destroy. When the ball touches a block it destroys.
My problem was that I wanted to show a little text telling how many points the user won destroying this block. For that I tried some different things, but I didn’t liked any of them a lot. So..I developed my own solution.
This is what I wanted
For that I started creating one CCLabel’s son object and I called it “LabelToDie”. I know, so smart name
And this is the code for
LabelToDie.h:
@interface LabelToDie : CCLabel { float dt; } @property (nonatomic) float dt; -(id) initWithText:(NSString *)text size:(float)size time:(float)dt; @end
LabelToDie.mm
#import "LabelToDie.h" @implementation LabelToDie @synthesize dt; -(id) initWithText:(NSString *)text size:(float)size time:(float) dt1{ if ((self=[super initWithString:text fontName:@"Verdana-Bold" fontSize:size])!=nil){ self.dt = dt1; } return self; } @end
So, with this we’ve got a brand new label with a time of creation. Now, with this class we have to:
1.- Create the label with the time and position
2.- Destroy labels that have been created a long time ago
Go with it:
1.- In our collision detection method we have to destroy the bad block and show the new label in its position:
-(void)tick:(ccTime)dt{ //some collision detection code and get the sprite to destroy //... LabelToDie *labelPoints = [[LabelToDie alloc] initWithText: [NSString stringWithFormat:@"%d", pointsToPut] size:12.0 time:dt]; labelPoints.position = ccp(sprite.position.x, sprite.position.y); labelPoints.color = ccc3(0, 150, 0); [self removeChild:sprite cleanup:YES]; [arrayLabels addObject:labelPoints]; [self addChild:labelPoints]; // some other boring code
2.- So this is the real clue. We are maintaining an array of labels called arrayLabels (another smart name) and with it finally we only need to check this array in our tick method and see if has passed so many time
//same boring code of before int numLabels = [arrayLabels count]; for (int l=numLabels-1; l>=0; l--){ LabelToDie * ld = (LabelToDie *)[arrayLabels objectAtIndex:l]; if (([ld dt])>0.4){ //Check that the time passed is more than 0.4 [self removeChild:(CCLabel *)ld cleanup:YES]; [ld release]; [arrayLabels removeObjectAtIndex:l]; }else { [ld setDt:[ld dt]+dt]; } } } //close the tick method
And that’s all! As you saw is very easy and you can use this method for show lives up or lives down, points, etc..
Hope you liked and bye!
Edit:
You should read the two comments of Gaming Horror in this post for a very improved version of this LabelToDie code. Enjoy!!!