1 Star 1 Fork 0

havealex / Cocos2d-x-Tutorial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
GPL-3.0

Cocos2d-x-Tutorial

介绍

本项目来自于https://www.raywenderlich.com/网站上Guanghui Qu写的2015年4月30号的一篇博文Cocos2d-x Tutorial for Beginners,他使用的Cocos2d-x的版本是 version 3.5,我将它翻译成中文,具体可以参考我的博客:Cocos2d-x初学者教程,源代码见SimpleGame目录。另外,关于在Windows10下使用Cocos2d-x 3.17.2构建项目的,可以参考我之前写的博客:Win10+Python2.7.14+cocos2d-x-3.17.2+VS2017环境搭建

Cocos2d-x初学者教程

在此Cocos2d-x教程中,学习如何使用C ++为iOS,Android等创建基本的跨平台游戏! Guanghui Qu 2015年4月30日·文章(30分钟)·初学者 Cocos2d-x

Cocos2d-x是一种快速,强大且易于使用的开源2D游戏引擎。

它与Apple的Sprite Kit非常相似,但具有一个关键优势– Cocos2d-x是跨平台的。

这意味着您可以使用一组代码来制作适用于iOS,Android,Windows Phone,Mac OS X,Windows桌面和Linux的游戏。 对于独立游戏开发者来说,这是意义巨大的!

在本教程中,您将学习如何使用C ++在Cocos2d-x中创建一个简单的2D游戏。 是的-会有忍者! :]

**注意:本教程假定您了解C ++开发的基础知识。 如果您不熟悉C ++,请务必先阅读有关该主题的书。**

入门

www.cocos2d-x.org/download下载最新版本的Cocos2d-x; 本教程使用3.5版

将下载的文件放在您要存储Cocos2d-x安装的位置,例如在主目录中,然后将其解压缩。

打开终端cd到刚解压缩的文件夹中。 例如,如果将项目放置在主目录中,请运行以下命令:

cd ~/cocos2d-x-3.5/

现在运行以下命令:

python setup.py

这将设置必要的Shell环境变量。 当它提示您配置特定于Android的变量NDK_ROOTANDROID_SDK_ROOTANT_ROOT时,只需按3次Enter回车键即可完成配置。

注意:Cocos2D需要在您的机器上安装Python 2.7+。 如果不确定所用的Python版本,请在命令行上键入python,它将显示该版本(然后按Ctrl-D退出)。 如果您使用的是Python的旧版本,请在python.org上安装最新版本的Python。

如下面的屏幕截图所示,该脚本指示您执行另一个命令以完成设置: cocos2d-x-3.5 注意:根据您使用的shell,您可能会看到一些不同的输出。 在上面的屏幕截图中,安装程序包提示输入“ source / Users / rwenderlich / bash_profile”命令,因为我使用的是Bash,但例如如果我一直使用Zsh,它会提示我运行“ source /Users/rwenderlich/.zshrc”。

按照脚本的输出说明输入命令。 节省时间的秘诀:您可以使用代字号(〜)代替/ Users / your_user_name,因此要保存击键,可以键入以下内容:

source ~/.zshrc  (or source ~/.bash_profile)

您输入的命令只是重新处理您的shell配置,并使其可以访问新变量。 现在,您可以从任何目录在终端中调用cocos命令。

运行以下命令以创建一个名为SimpleGame的C ++游戏模板:

cocos new -l cpp -d ~/Cocos2d-x-Tutorial SimpleGame

这将在您的主目录中创建一个名为Cocos2d-x-Tutorial的目录,并在其中创建一个名为SimpleGame的子目录,其中包含您项目的文件。

注意:要了解可用的cocos子命令,请键入cocos --helpcocos -h。 您还可以通过添加“ --help”或“ -h”(例如cocos new -h)来了解任何子命令的选项,以查看new命令的选项。Finder中双击〜/ Cocos2d-x-Tutorial / SimpleGame / proj.ios_mac / SimpleGame.xcodeproj以在Xcode中打开项目。

一旦进入Xcode,请确保SimpleGame Mac是活动方案,如下所示: SimpleGame Mac

尽管Cocos2d-x能够为许多平台构建游戏,但在本教程中,您将重点关注制作OS X应用程序。 将这个项目移植到其他平台上是一件很简单的事情(是的,很简单!),这在本教程的结尾进行了简要讨论。

生成并运行您的应用,以全面了解模板项目: HelloWorld

分辨率设置

默认情况下,Cocos2d-x游戏的名称为“ MyGame”,分辨率为960×640,但是这些细节很容易更改。 打开AppDelegate.cpp并在其中找到以下行 AppDelegate::applicationDidFinishLaunching:

glview = GLViewImpl::create("My Game");

用以下代码替换该行:

glview = GLViewImpl::createWithRect("SimpleGame", Rect(0,0, 480, 320), 1.0);

这会将应用程序的名称更改为“ SimpleGame”,并将其分辨率设置为480×320,以匹配模板随附的背景图片。

再次构建并运行您的应用,以查看新的较小的游戏: SimpleGame 请注意,您传递给createWithRect的第三个参数-1.0。 此参数缩放帧,通常用于测试分辨率大于显示器的帧。 例如,要在小于1920×1080的监视器上测试1920×1080的分辨率,您可以传递0.5以将窗口缩放到960×540。

虽然对createWithRect的调用更改了台式机上的游戏框架,但在iOS设备上这种方式无法正常工作; 而是游戏的分辨率与屏幕尺寸匹配。 这是在iPhone 6上的外观: Big SimpleGame 那么,您如何处理多种分辨率呢? 在本教程中,您将基于960×640分辨率创建一组游戏资源,然后在运行时根据需要简单地按比例放大或缩小资产。 要实现这一点,请在内部添加以下代码: AppDelegate::applicationDidFinishLaunching,位于在Director上调用setDisplayStats的行的上方:

// 1
Size designSize = Size(480,320);
Size resourceSize = Size(960,640);
// 2
director->setContentScaleFactor(resourceSize.height / designSize.height);
director->getOpenGLView()->setDesignResolutionSize(
  designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT);

上面的代码是这样的:

  • .在这里,您可以定义designSize(创建游戏逻辑时要使用的尺寸)和resourceSize(您所有艺术资产所基于的尺寸)。
  • 2.这些行告诉您游戏的Driector根据您提供的设计和资源大小在必要时扩展资产。 有关Cocos2d-x如何处理分辨率的详细说明,请参阅Cocos2d-x Wiki关于多分辨率适配的条目

添加精灵

接下来,下载该项目的资源文件并将其解压缩到方便的位置。

在刚刚提取的SimpleGameResources文件夹中选择所有文件,并将它们拖到``Xcode项目的Resources组中。 在出现的对话框中,请确保在单击“完成”之前选中“复制项目”,SimpleGame iOSSimpleGame MacChoose options for adding these files 接下来打开HelloWorldScene.h,在包含cocos2d.h的行之后添加以下行:

using namespace cocos2d;

这指定您将使用cocos2d命名空间; 这使您可以执行诸如写Sprite *而不是cocos2d :: Sprite *的操作。 这不是绝对必要的,但肯定会使开发更加愉快。 :]

现在,您需要一个私有成员变量来指向您的player精灵。 将以下代码添加到HelloWorld类的声明中:

private:
  Sprite* _player;

接下来,打开HelloWorldScene.cpp并将HelloWorld::init方法的内容替换为以下内容:

// 1
if ( !Layer::init() ) {
  return false;
}
// 2
auto origin = Director::getInstance()->getVisibleOrigin();
auto winSize = Director::getInstance()->getVisibleSize();
// 3
auto background = DrawNode::create();
background->drawSolidRect(origin, winSize, Color4F(0.6,0.6,0.6,1.0));
this->addChild(background);
// 4
_player = Sprite::create("player.png");
_player->setPosition(Vec2(winSize.width * 0.1, winSize.height * 0.5));
this->addChild(_player);
    
return true;

这是此方法的逐步播放:

  • 1.首先,您调用父类的init方法。 只有成功后,您才能继续进行HelloWorldScene的设置。
  • 2.然后,您可以使用游戏的Director单例来获取窗口的边界。
  • 3.然后,您创建一个DrawNode来绘制一个灰色矩形,该矩形将填充屏幕并将其添加到场景中。 这是您游戏的背景。
  • 4.最后,您通过传入图片名称来创建player精灵。 您将其从屏幕的左边缘垂直居中放置10%,并将其添加到场景中。 生成并运行您的应用; 瞧,女士们,先生们,忍者进入了大楼! :] 添加忍者精灵

移动怪物

忍者需要生活中的目标,因此您需要在场景中添加一些怪物,忍者才能战斗。 为了让事情变得更加有趣,您希望怪物们四处走动-否则,这并不会带来太大的挑战! 您将在屏幕右侧的右边创建怪物,并为它们设置一个动作,告诉它们向左移动。

首先,打开HelloWorldScene.h并添加以下方法声明:

void addMonster(float dt);

然后在HelloWorldScene.cpp中添加以下方法实现:

void HelloWorld::addMonster(float dt) {
  auto monster = Sprite::create("monster.png");
    
  // 1
  auto monsterContentSize = monster->getContentSize();
  auto selfContentSize = this->getContentSize();
  int minY = monsterContentSize.height/2;
  int maxY = selfContentSize.height - monsterContentSize.height/2;
  int rangeY = maxY - minY;
  int randomY = (rand() % rangeY) + minY;
    
  monster->setPosition(Vec2(selfContentSize.width + monsterContentSize.width/2, randomY));
  this->addChild(monster);
    
  // 2
  int minDuration = 2.0;
  int maxDuration = 4.0;
  int rangeDuration = maxDuration - minDuration;
  int randomDuration = (rand() % rangeDuration) + minDuration;
    
  // 3
  auto actionMove = MoveTo::create(randomDuration, Vec2(-monsterContentSize.width/2, randomY));
  auto actionRemove = RemoveSelf::create();
  monster->runAction(Sequence::create(actionMove,actionRemove, nullptr));
}

它相对简单,但是上面的代码是这样的:

  • 1.该方法的第一部分与您之前对player进行的操作类似:它会创建一个怪物(monster)精灵并将其放置在屏幕外的右侧。 它将y位置设置为随机值,以保持有趣的状态。
  • 2.接下来,该方法会计算要添加到个怪物(monster)身上的动作的随机持续时间,介于2到4秒之间。 每个怪物(monster)都会在屏幕上移动相同的距离,因此改变持续时间会导致怪物(monster)的速度随机。
  • 3.最后,该方法创建一个动作,该动作使怪物(monster)从右到左在屏幕上移动,并指示怪物(monster)运行它。 下面将对此进行详细说明。

Cocos2d-x提供了许多非常方便的内置动作,可帮助您随时间轻松地更改精灵的状态,包括移动动作,旋转动作,淡入淡出动作,动画动作等。 在这里,您对怪物使用三个动作:

  • MoveTo:在特定的时间内将对象从一个点移动到另一点。
  • RemoveSelf:从其父节点删除节点,从而有效地将其从场景中“删除”。 在这种情况下,您可以使用该操作将不再可见的怪物从场景中移除。 这很重要,因为否则您将有无穷无尽的怪物供不应求,并最终会消耗掉设备的所有资源。
  • Sequence:让您一次执行一系列其他操作。 这意味着您可以让怪物在场景中移动,并在到达目的地时将其从屏幕上移开。

在让忍者进城之前,还有最后一件事要做-您需要实际调用创建怪物的方法! 为了使事情变得有趣,您将创建不断产生的怪物。

只需在return语句之前,将以下代码添加到HelloWorld:: init的末尾:

srand((unsigned int)time(nullptr));
this->schedule(schedule_selector(HelloWorld::addMonster), 1.5); 

srand((unsigned int)time(nullptr));播种随机数生成器。 如果您不这样做,那么每次您运行该应用程序时,您的随机数都会相同。 感觉不会很随意,是吗? :]

然后,将HelloWorld::addMonster传递到schedule方法中,该方法每1.5秒调用一次addMonster()。 在这里,Cocos2d-x利用了C ++指向成员函数的指针。 如果您不了解其工作原理,请参阅ioscpp以获取更多信息。

而已! 建立并运行您的项目; 您现在应该可以看到妖怪在屏幕上快乐地(或愤怒地(视情况而定!))移动: 添加怪物 2

射击弹丸

您勇敢的小忍者需要一种保护自己的方法。 在游戏中实现火力的方法有很多,但是在此项目中,您将让用户单击或轻击屏幕以沿单击或轻击的方向发射弹丸。 ew! :]

为简化起见,您将通过MoveTo操作实现这一点-但这意味着您需要做一些数学运算。

MoveTo操作需要射弹的目标位置,但是您不能直接使用输入位置,因为该点仅代表相对于玩家的射击方向。 您想让子弹一直移动到该点,直到子弹到达屏幕外的最终目的地。

这是说明问题的图片: 射击弹丸的物理图 从原点到触摸位置的x和y偏移会创建一个小三角形; 您只需要制作一个具有相同比率的大三角形即可,并且您知道要使其中一个端点不在屏幕上。

利用Cocos2d-x随附的矢量数学例程,可以轻松执行这些计算。 但是,在计算移动位置之前,您需要启用输入事件处理功能才能弄清楚用户触摸的位置! 将以下代码添加到HelloWorld:: init的末尾,就在return语句的上方:

auto eventListener = EventListenerTouchOneByOne::create();
eventListener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(eventListener, _player);

Cocos2d-x版本3及更高版本使用EventDispatcher来调度各种事件,例如触摸,加速计和键盘事件。

注意:在整个讨论中,术语“触摸”是指触摸设备上的点击以及桌面上的点击。 Cocos2d-x使用相同的方法来处理两种类型的事件。

为了从EventDispatcher接收事件,您需要注册一个EventListener。 触摸事件侦听器有两种类型:

  • EventListenerTouchOneByOne:此类型为每个触摸事件调用一次您的回调方法。
  • EventListenerTouchAllAtOnce:此类型对所有触摸事件调用一次您的回调方法。

触摸事件侦听器支持四个回调,但是您只需要为您关心的事件绑定方法。

  • onTouchBegan:在手指首次触摸屏幕时调用。 如果使用的是EventListenerTouchOneByOne,则必须返回true才能接收其他三个触摸事件中的任何一个。
  • onTouchMoved:当您的手指已经触摸屏幕而没有离开屏幕而移动时调用。
  • onTouchEnded:当手指离开屏幕时调用。
  • onTouchCancelled:在某些情况下被调用以停止事件处理,例如当您触摸屏幕时,然后像电话之类的中断应用程序。 在这个游戏中,您实际上只在乎何时发生触摸。 声明您的回调以在HelloWorldScene.h中接收触摸通知,如下所示:
bool onTouchBegan(Touch *touch, Event *unused_event);

然后在HelloWorldScene.cpp中实现您的回调:

bool HelloWorld::onTouchBegan(Touch *touch, Event *unused_event) {
  // 1  - Just an example for how to get the  _player object
  //auto node = unused_event->getCurrentTarget();
    
  // 2
  Vec2 touchLocation = touch->getLocation();
  Vec2 offset = touchLocation - _player->getPosition();
    
  // 3
  if (offset.x < 0) {
    return true;
  }

  // 4
  auto projectile = Sprite::create("projectile.png");
  projectile->setPosition(_player->getPosition());
  this->addChild(projectile);

  // 5
  offset.normalize();
  auto shootAmount = offset * 1000;

  // 6
  auto realDest = shootAmount + projectile->getPosition();

  // 7
  auto actionMove = MoveTo::create(2.0f, realDest);
  auto actionRemove = RemoveSelf::create();
  projectile->runAction(Sequence::create(actionMove,actionRemove, nullptr));
    
  return true;
}

上面的方法正在进行很多工作,因此请花点时间逐步检查一下。

  • 1.第一行已被注释掉,但是它在那里向您展示了如何访问作为第二个参数传递给addEventListenerWithSceneGraphPriority(eventListener, _player)_player对象。
  • 2.您可以在此处获得场景坐标系内触摸的坐标,然后计算该点与播放器当前位置的偏移量。这是Cocos2d-x中向量数学的一个示例。
  • 3.如果offsetx值为负,则表示玩家正在尝试向后射击。在此游戏中不允许这样做(真正的忍者永不回头!),因此只需返回而无需发射弹丸。
  • 4.在玩家的位置上创建一个弹丸,并将其添加到场景中。
  • 5.然后,您调用normalize()将偏移量转换为单位向量,该向量是长度为1的向量。将其乘以1000可得到长度为1000的向量,该向量指向用户点击的方向。为什么是1000?该长度应足以以该分辨率延伸超出屏幕边缘:]
  • 6.将向量添加到弹丸的位置即可得到目标位置。
  • 7.最后,创建一个动作,将弹丸移至目标位置超过两秒钟,然后将其从场景中移除。 生成并运行您的应用;触摸屏幕,使您的忍者向即将来临的部落射击! 添加飞镖

碰撞检测与物理

现在您已经拥有飞镖飞来飞去的地方-但您的忍者真正想要做的就是放下一些零头。 因此,您需要一些代码来检测弹丸何时与目标相交。

关于Cocos2d-x的一件好事是它内置了一个物理引擎! 物理引擎不仅对于模拟逼真的运动非常有用,而且对于检测碰撞也非常有用。 您将使用Cocos2d-x的物理引擎来确定怪物和投射物何时发生碰撞。

首先在HelloWorld::createScene的实现上方,向HelloWorldScene.cpp添加以下代码:

enum class PhysicsCategory {
  None = 0,
  Monster = (1 << 0),    // 1
  Projectile = (1 << 1), // 2
  All = PhysicsCategory::Monster | PhysicsCategory::Projectile // 3
};

些位掩码定义了您需要的物理类别-并非双关语! :]在这里,您已经创建了两种类型,MonsterProjectile,以及两个特殊值,用于指定没有类型或所有类型。 您将使用这些类别为对象分配类型,从而允许您指定允许哪些对象类型相互碰撞。

注意:您可能想知道这种奇特的语法是什么。 Cocos2d-x上的类别只是一个32位整数。 此语法将整数中的特定位设置为代表不同的类别,最多给您32种可能的类别。 在这里,您将第一位设置为指示怪物,将下一位设置为代表弹丸,依此类推。

接下来,用以下代码替换HelloWorld::createScene的第一行:

auto scene = Scene::createWithPhysics();
scene->getPhysicsWorld()->setGravity(Vec2(0,0));
scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);

这将创建一个启用了物理的场景。 Cocos2d-x使用PhysicsWorld来控制其物理模拟。 在这里,您可以在两个方向上将世界的重力设置为零,这实际上会禁用重力,并且可以启用调试绘图以查看物理物体。 在对物理相互作用进行原型设计时,启用调试绘图很有帮助,这样可以确保事情正常进行。

HelloWorld::addMonster中,在创建怪物精灵的第一行之后添加以下代码:

// 1
auto monsterSize = monster->getContentSize();
auto physicsBody = PhysicsBody::createBox(Size(monsterSize.width , monsterSize.height),
                                          PhysicsMaterial(0.1f, 1.0f, 0.0f));
// 2
physicsBody->setDynamic(true);
// 3
physicsBody->setCategoryBitmask((int)PhysicsCategory::Monster);
physicsBody->setCollisionBitmask((int)PhysicsCategory::None);
physicsBody->setContactTestBitmask((int)PhysicsCategory::Projectile);
    
monster->setPhysicsBody(physicsBody);

这是上面的代码的作用:

  • 1.为精灵创建一个PhysicsBody。物理实体代表Cocos2d-x物理仿真中的对象,您可以使用任何形状来定义它们。在这种情况下,可以使用与精灵大小相同的矩形作为怪兽的近似值。您可以使用更精确的形状,但是更简单的形状足以满足大多数游戏和更高的性能要求。
  • 2.将精灵设置为动态。这意味着物理引擎不会向怪物施加力。相反,您将直接通过之前创建的MoveTo操作对其进行控制。
  • 3.在这里,您可以设置类别,碰撞和接触测试位掩码:
    • 类别:定义对象的类型–Monster
    • 碰撞:定义在碰撞期间应以何种类型的对象物理影响该对象-在这种情况下为None。因为此对象也是动态的,所以此字段无效,但出于完整性考虑,在此将其包括在内。
    • 接触测试:定义碰撞应通过其生成通知的对象类型-Projectile。您将在本教程的稍后部分注册并处理这些通知。
    • 最后,将物理物体分配给怪物。 接下来,将以下代码添加到HelloWorld::onTouchBegan中,紧接设置弹丸位置的行之后:
auto projectileSize = projectile->getContentSize();
auto physicsBody = PhysicsBody::createCircle(projectileSize.width/2 );
physicsBody->setDynamic(true); 
physicsBody->setCategoryBitmask((int)PhysicsCategory::Projectile);
physicsBody->setCollisionBitmask((int)PhysicsCategory::None);
physicsBody->setContactTestBitmask((int)PhysicsCategory::Monster);
projectile->setPhysicsBody(physicsBody);

这与您为怪物执行的物理设置非常相似,不同的是它使用圆形而不是矩形来定义物理物体。 请注意,并不是绝对必要设置接触测试位掩码,因为怪物已经在检查与射弹的碰撞,但这有助于使代码的意图更加清晰。

立即构建并运行您的项目; 您会看到红色形状叠加在物理物体上,如下所示: SimpleGame final 射弹被设置为可以击中怪物,因此当它们碰撞时,您需要将它们都移除。

还记得早先的物理学世界吗? 好吧,您可以在其上设置一个联系人代表,以在两个物理物体碰撞时得到通知。 在那里,您将编写一些代码来检查对象的类别,如果它们是怪物和弹丸,则可以使其蓬勃发展!

首先,将以下方法声明添加到HelloWorldScene.h中:

bool onContactBegan(PhysicsContact &contact);

这是您注册以接收联系事件的方法。

接下来,在HelloWorldScene.cpp中实现以下方法:

bool HelloWorld::onContactBegan(PhysicsContact &contact) {
  auto nodeA = contact.getShapeA()->getBody()->getNode();
  auto nodeB = contact.getShapeB()->getBody()->getNode();
    
  nodeA->removeFromParent();
  nodeB->removeFromParent();
  return true;
}

传递给此方法的PhysicsContact包含有关碰撞的信息。 在这个游戏中,您知道唯一会碰撞的对象是怪物和射弹。 因此,您将使节点参与碰撞并将其从场景中移除。

最后,您需要注册以接收联系人通知。 在return语句之前,将以下行添加到HelloWorld ::init的末尾:

auto contactListener = EventListenerPhysicsContact::create();
contactListener->onContactBegin = CC_CALLBACK_1(HelloWorld::onContactBegan, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(contactListener, this);

这将创建一个联系人侦听器,注册HelloWorld::onContactBegan以接收事件并将侦听器添加到EventDispatcher。 现在,只要两个物理物体发生碰撞并且它们的类别位掩码与它们的接触测试位掩码匹配,EventDispatcher就会调用onContactBegan

生成并运行您的应用; 现在,当您的弹丸与目标相交时,它们应该消失: Simple 碰撞检测

画龙点睛

您现在已经快要制作出一款可行(但非常简单)的游戏了。 您只需要添加一些声音效果和音乐(因为哪种游戏都没有声音!)和一些简单的游戏逻辑即可。

Cocos2d-x带有一个称为CocosDenshion的简单音频引擎,您将使用它来播放声音。

注意:Cocos2d-x还包括第二个音频引擎,旨在代替简单的音频引擎模块。 但是,它仍处于试验阶段,并且不适用于所有受支持的平台,因此您将不在此处使用它。

该项目已经包含了一些很酷的背景音乐以及您之前导入的超赞的“ pew-pew”音效。 您只需要玩它们!

为此,在其他#include语句之后,将以下代码添加到HelloWorldScene.cpp的顶部:

using namespace CocosDenshion;

这将导入SimpleAudioEngine模块,并指定您将在此文件中使用CocosDenshion命名空间。

接下来,将以下定义添加到PhysicsCategory枚举上方的HelloWorldScene.cpp

#define PEW_PEW_SFX           "pew-pew-lei.mp3"

在这里,您定义了两个字符串常量:BACKGROUND_MUSIC_SFXPEW_PEW_SFX。 这只是将文件名放在一个位置,这使得以后更容易更改它们。 像这样组织代码(甚至使用完全独立的文件甚至更好),可以更轻松地支持特定于平台的更改,例如在iPhone上使用.mp3文件,在Windows Phone上使用.wav文件。

现在,在return语句之前,将以下行添加到HelloWorld::init的末尾:

SimpleAudioEngine::getInstance()->playBackgroundMusic(BACKGROUND_MUSIC_SFX, true);

场景建立后,即会开始播放背景音乐。

至于声音效果,请将以下行添加到HelloWorld::onTouchBeganreturn语句上方:

SimpleAudioEngine::getInstance()->playEffect(PEW_PEW_SFX);

每当忍者发动攻击时,这都会起到很好的“ pew-pew”声音效果。 很方便,是吗? 您仅需一行代码即可播放声音效果。

生成并运行,并享受您的时髦音乐!

然后去哪儿? 这是上面教程中完成的示例游戏

希望您喜欢Cocos2d-x,并从中获得灵感来制作自己的游戏! 要了解有关Cocos2d-x的更多信息,请访问Cocos2d-x网站以获取大量学习资源

如果对本教程有任何疑问或意见,请加入下面的讨论!

关于本项目在其他系统如Windows上的移植

我使用的是Window7系统,Cocos2d-x的版本是3.17.2,Python是2.7.18 使用VS2017打开项目下的SimpleGame\proj.win32\文件夹下的SimpleGame.sln,然后编译运行,前提是需要配置好Cocos2d-x 3.17.2的开发环境,关于环境搭建可以参考我之前写的一篇博客:Win10+Python2.7.14+cocos2d-x-3.17.2+VS2017环境搭建,下面是我在VS2017中运行本项目的截图: VS2017中的运行结果截图 最终的项目源代码我已经托管到GithubGitee上,需要的话执行如下命令自取:

从github上获取cocos2d-x-tutorial源代码

git clone https://github.com/ccf19881030/Cocos2d-x-Tutorial.git

从gitee码云上获取cocos2d-x-tutorial源代码

git clone https://gitee.com/havealex/cocos2d-x-tutorial.git

参考资料

GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

简介

本项目来自于https://www.raywenderlich.com/网站上Guanghui Qu写的2015年4月30号的一篇博文Cocos2d-x Tutorial for Beginners:https://www.raywenderlich.com/1848-cocos2d-x-tutorial-for-beginners,他使用的Cocos2d-x的版本是 version 3.5。另外,关于在Windows10下使用Cocos2d-x 3.17.2构建项目的,可以参考我之前写的博客:Win10+Python2.7.14+cocos2d-x-3.17.2+VS2017环境搭建:https://blog.csdn.net/ccf19881030/article/details/... 展开 收起
C++
GPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/havealex/cocos2d-x-tutorial.git
git@gitee.com:havealex/cocos2d-x-tutorial.git
havealex
cocos2d-x-tutorial
Cocos2d-x-Tutorial
master

搜索帮助