资源简介
如何用Cocos2d-android写一个小游戏案例源代码
代码片段和文件信息
/*
* cocos2d for iPhone: http://www.cocos2d-iphone.org
*
* Copyright (c) 2008-2010 Ricardo Quesada
*
* Permission is hereby granted free of charge to any person obtaining a copy
* of this software and associated documentation files (the “Software“) to deal
* in the Software without restriction including without limitation the rights
* to use copy modify merge publish distribute sublicense and/or sell
* copies of the Software and to permit persons to whom the Software is
* furnished to do so subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
* IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
// cocos2d
#import “CCParticleExamples.h“
#import “CCTextureCache.h“
#import “CCDirector.h“
#import “Support/CGPointExtension.h“
//
// ParticleFireworks
//
@implementation CCParticleFireworks
-(id) init
{
return [self initWithTotalParticles:1500];
}
-(id) initWithTotalParticles:(int)p
{
if( (self=[super initWithTotalParticles:p]) ) {
// duration
duration = kCCParticleDurationInfinity;
// Gravity Mode
self.emitterMode = kCCParticleModeGravity;
// Gravity Mode: gravity
self.gravity = ccp(0-90);
// Gravity Mode: radial
self.radialAccel = 0;
self.radialAccelVar = 0;
// Gravity Mode: speed of particles
self.speed = 180;
self.speedVar = 50;
// emitter position
CGSize winSize = [[CCDirector sharedDirector] winSize];
self.position = ccp(winSize.width/2 winSize.height/2);
// angle
angle = 90;
angleVar = 20;
// life of particles
life = 3.5f;
lifeVar = 1;
// emits per frame
emissionRate = totalParticles/life;
// color of particles
startColor.r = 0.5f;
startColor.g = 0.5f;
startColor.b = 0.5f;
startColor.a = 1.0f;
startColorVar.r = 0.5f;
startColorVar.g = 0.5f;
startColorVar.b = 0.5f;
startColorVar.a = 0.1f;
endColor.r = 0.1f;
endColor.g = 0.1f;
endColor.b = 0.1f;
endColor.a = 0.2f;
endColorVar.r = 0.1f;
endColorVar.g = 0.1f;
endColorVar.b = 0.1f;
endColorVar.a = 0.2f;
// size in pixels
startSize = 8.0f;
startSizeVar = 2.0f;
endSize = kCCParticleStartSizeEqualToEndSize;
self.texture = [[CCTextureCache sharedTextureCache] addImage: @“fire.png“];
// additive
self.blendAdditive = NO;
}
return self;
}
@end
//
// ParticleFire
//
@implementation CCParticleFire
-(id) init
{
return [self initWithTotalParticles:250];
}
-(id) initWithTotalParticles:(int) p
{
if( (self=[super initWithTo
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 280 2011-04-24 19:28 Cocos2DSimpleGameTut1\.classpath
文件 857 2011-04-25 23:16 Cocos2DSimpleGameTut1\.project
文件 689 2011-04-25 23:15 Cocos2DSimpleGameTut1\AndroidManifest.xm
目录 0 2011-04-25 16:30 Cocos2DSimpleGameTut1\assets\
文件 6203 2010-07-05 17:36 Cocos2DSimpleGameTut1\assets\fps_images.png
文件 4329 2011-04-24 19:08 Cocos2DSimpleGameTut1\assets\Pla
文件 4583 2011-04-24 19:08 Cocos2DSimpleGameTut1\assets\Projectile.png
文件 5229 2011-04-24 19:08 Cocos2DSimpleGameTut1\assets\Target.png
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\
文件 514488 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\classes.dex
文件 2008174 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\Cocos2DSimpleGameTut1.apk
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\
文件 6881 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\Gamela
文件 2913 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\GameOverla
文件 379 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\R$attr.class
文件 439 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\R$drawable.class
文件 433 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\R$layout.class
文件 475 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\R$raw.class
文件 466 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\R$string.class
文件 624 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\R.class
文件 1867 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\com\tutorials\cocos2dsimplegame\SimpleGame.class
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\actions\
目录 0 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\actions\ba
文件 1586 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\actions\ba
文件 1560 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\actions\ba
文件 3747 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\actions\ba
文件 1763 2011-04-25 23:17 Cocos2DSimpleGameTut1\bin\org\cocos2d\actions\ba
............此处省略704个文件信息
评论
共有 条评论