Saturday, July 5, 2014

I am a game development mbc3 framework in a month or two here, and cocos2d. But Japanese document i

game Walkthrough extremely simple on the iPhone using cocos2d - jarinosuke blog
I am a game development mbc3 framework in a month or two here, and cocos2d. But Japanese document is not well-equipped too, where he was visited various web sites and wiki of English. Class names have changed in relation to such version quite, etc. or addicted at boring, wasted time I have made it takes. Found a very good introductory article among such, because it was great in an easy-to-understand article by far in contents, I was allowed to be translated in awkward English.
I was thinking I'm just beginning to learn cocos2d, and some are suitable for start now the cocos2d, tutorials practical There are plenty, but "super simple, But I'm Dattari animation that I wanted I did not find a sample "thing Applied mbc3 can be without the music or was or was a collision. I was thinking on the basis of the experience and, eventually making a simple game on their own, try to make a tutorial toward the newcomer in the future. I think from the beginning to the end, the steps to create mbc3 a simple iPhone game using cocos2d, this tutorial and tells us in attendance. While along the tutorial, or may be working on a sample project at the end of this article at a stretch. Which may be used. I think anyway, mbc3 that there are ninja there.
So using the template of cocos2d you have installed right now, let's create a simple HelloWorld project. Let's make a new cocos2d project by launching the XCode, by selecting the "cocos2d-0.99.0 Application template". And please set to "Cocos2DSimpleGame" is the name of the project. Well First of all, let's build, I should be all green. should this screen appears. cocos2d is composed of the concept of "scenes." I think it is close to the concept for the game, such as the screen or was level. You're going to be having a lot scene. For example, the menu screen or was, or was the action of the main screen of the game, I should have the game over screen in the end also. Some of the scene of them have (something similar to that of Photoshop) layers of a lot, the layers will be included a lot of other node label or sprite, and menu. And they node's may be included to the same node of the other. (Can also sprite Nantes have a child sprite in it)
before adding the sprite, image for use with it, huh necessary. I may be cooked in their own separate but Well, I may be me making this image beloved wife I was created. I wonder if it could get. image a Player image, a Projectile image, a Target Image? mbc3 Let Otoso of XCode among the "Resources" folder by dragging them if possible. And to check "Copy items into destination group's folder (if needed)" and also so as not to forget. Come what may, do not go and does not point to me who the place where he will have to get the image, you want to place the player in this next. I want to remember, but (0, 0), the value of x and y is increased by to the right, and go up to the top, each coordinate of the lower-left in cocos2d. Coordinates of the upper right I'll be (480, 320) finally this project because it is landscape. You want to remember another, when you set the position of an object, Copy all position that by default I do such that I linked to the coordinates of the center of the sprite of us are about to add now. So if it is necessary entries like this I we tried to put them in parallel to the middle of the left edge of the sprite player. Position of [player sprite's width] / 2 y's condition I [window height] / 2 the position of x. Because keep the image below, I be better and consult it.
Well then let's to code it. Let replace Click HelloWorldScene.m open the Classes folder, and following of the init method! - (Id) init {if ((self = [super init])) {CGSize winSize = [[CCDirector sharedDirector] winSize]; CCSprite * player = [CCSprite spriteWithFile: @ "Player.png" rect: CGRectMake (0, 0 , 27, 40)]; player.position = ccp (player.contentSize.width / 2, winSize.height / 2); [self addChild: player];} return self;}
Let's move it to compile, sprite'd be appear alive and well. But I background is I'm still of the default black. But I'm mbc3 white and it is this image. Can be as one of the easy way, it's me change using CCColoredLayer class layer of background. Let's write so long. Let us as follows the definition of the HelloWorld interface Open HelloWorldScene.h. @ Interface HelloWorld: CCColorLayer
Let me added before the init method right now the following methods. - (Void) mbc3 addTarget {CCSprite * target = [CCSprite spriteWithFile: @ "Target.png" mbc3 rect: CGRectMake (0, 0, 27, 40)]; / / Determine where to spawn the target mbc3 along the Y axis CGSize winSize = [ [CCDirector sharedDirector] winSize]; int minY = target.contentSize.height / 2; int maxY = winSize.height - target.contentSize.height / 2; int rangeY = maxY - minY; int actualY = (arc4random ()% rangeY) + minY; / / Create the target slightly off-screen along the right edge, / / and along a random position along the Y axis as calculated above target.position = ccp (winSize.width + (target.contentSize.width / 2) , actualY); [self addChild: mbc3 target]; / / Determine speed of the target int minDuration = 2.0; int maxDuration = 4.0; int rangeDuration = maxDuration - minDuration; int actualDuration = (arc4random ()% rangeDuration) + minDuration; / / 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]];}
Was left as comment out redundant representation to make it easier to understand as much as possible. It is calculated in the same way for me "~ place the object where" you have to talk before fairly mbc3 in the first part. New elements here I would add the action. cocos2d to be incorporated is an extreme mbc3 action a lot of easy, you can do or use to sprite animation of it. They had various, mbc3 or was or was animation fade or jump was or was moving, there is also a lot of animation that I. We shall use to target the action of three here.
Use when moving to the left from the off-screen objects directly to this CCMoveTo. The can also specify the interval at which the moving, you have to take 2-4 seconds at random this time. This callback function to be called when the action of something done CCCallFuncN. You have to name me spriteMoveFinished this time, but it is not over yet to write. I'll do later. mbc3 Use when you connect the action of some CCSequence this. You have to call the CCCallFuncN after it has finished with the first CCMoveTo this time.
Well then one last thing. It 's not to be called the method every time you create a target to be a state of now. To this interesting, let us move on an ongoing basis all the time. Let's call you to schedule continuously callback function in cocos2d mbc3 in order to achieve this. It's going to be before you return in the init method in the following code. [Self schedule: @ selector (gameLogic :) interval: 1.0];
Here, I'll ninja began to action some. So next try to make shooting! I think that there are many ways to make shooting, but I try to to things that, to fire in the direction of the bullet taps from the player if the user tap the screen in this game. I want to use CCMoveTo action to match the beginner level, but it's become such so I have to use only a little math. If you say what why, destination've mbc3 got becomes necessary to CCMoveTo, but I'm no good to the touch point to it, because the touch point, because it was something only for determining the direction of the bullet is fired from the player to the last. I we want to be I do such that it continues to move up until the off-screen bullet through the touch point.
Touch of the layer is activated mbc3 on this, I'll mbc3 know the callback function of the touch event. By me, and try to make ccTouchesEnded method that is called when the touch is completed. - (Void) ccTouchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {/ / Choose o

No comments:

Post a Comment