• 大小: 9.43MB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2024-02-02
  • 语言: 其他
  • 标签: xcode  cocos2d-x  

资源简介

这个小程序自己写了,时间紧促,其中有不足之处,希望谅解,这个程序只是供大家学习用,开发环境是xcode cocos2d-x

资源截图

代码片段和文件信息

//
//  Gamelayer.cpp
//  MyGoldMan
//
//  Created by HeZhiTao on 13-11-2.
//
//

#include “Gamelayer.h“
#include “Data.h“
#include “Tools.h“
#include “GameWin.h“
#include “Shoplayer.h“
#include “GameOver.h“
#include “Messagelayer.h“
#include “MessageEnd.h“

Gamelayer::~Gamelayer()
{
    miner->release();
    hook->release();
    
}

CCScene* Gamelayer::scene()
{
    CCScene* scene = CCScene::create();
    Gamelayer* layer = Gamelayer::create();
    scene->addChild(layer);
    return scene;
}

bool Gamelayer::init()
{
    if(!CClayer::init())
    {
        return  false;
    }
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    char tmp[50];
    sprintf(tmp “mineBG%d.png“Level + 1);
    CCSprite* sprite = CCSprite::create(tmp);
    sprite->setPosition(ccp(winSize.width/2 winSize.height/2));
    this->addChild(sprite -1);
    
//    //添加炸弹
//    CCSprite* boom = CCSprite::create(“boom.png“);
//    boom->setPosition(ccp(240100));
//    this->addChild(boom);
    
    //添加钩子
    hook = new Hook();
    hook->setPosition(ccp(winSize.width/2-2 winSize.height/2-20));
    this->addChild(hook);
    hook->runRotateAction();
    
    //添加矿工
    miner = new Miner();
    miner->setPosition(ccp(winSize.width/2 winSize.height/2));
   // miner->runStayguyAction();
    this->addChild(miner);
    
    //添加黄金
    ItemUnitArray = CCArray::create();
    ItemUnitArray->retain();
    this->addItem();
    
    
    //添加时钟图标
    alarmClockSprite = CCSprite::create(“clockPlate.png“);
    alarmClockSprite->setPosition(ccp(380 260));
    this->addChild(alarmClockSprite);
    
    sprintf(tmp “%d“TotalTime[Level]);
    alarmClockLB = CCLabelTTF::create(tmp “Zapfino“ 16);
    alarmClockLB->setPosition(ccp(420 250));
    alarmClockLB->setColor(ccc3(0 0 255));
    this->addChild(alarmClockLB);
    
    //添加级别图标
    levelNumberSprite = CCSprite::create(“miner_0707.png“);
    levelNumberSprite->setPosition(ccp(380 300));
    this->addChild(levelNumberSprite);
    
    sprintf(tmp “%d“Level);
    levelNumberLB = CCLabelTTF::create(tmp “Zapfino“ 16);
    levelNumberLB->setPosition(ccp(420 290));
    levelNumberLB->setColor(ccc3(0 0  255));
    this->addChild(levelNumberLB);
    
    //添加分数图标
    totalSocreSprite = CCSprite::create(“rmbImage.png“);
    totalSocreSprite->setPosition(ccp(50 255));
    this->addChild(totalSocreSprite);
    
    sprintf(tmp “%d“ TotalSocre);
    totalSocreSpriteLB = CCLabelTTF::create(tmp “Zapfino“ 16);
    totalSocreSpriteLB->setPosition(ccp(110 250));
    totalSocreSpriteLB->setColor(ccc3(0 0 255));
    this->addChild(totalSocreSpriteLB);
    
    //添加目标分数
    goalNumberSprite = CCSprite::create(“Gold.png“);
    goalNumberSprite->setPosition(ccp(50 290));
    this->addChild(goalNumberSprite);
    
    sprintf(tmp “%d“ NeedTotalScore[Level]);
    goalNumberSpriteLB = CCLabelTTF::create(tmp “Zapfino“ 16);
    goalNumberSpriteLB->setPosition(ccp(110 290));
    goalNumberSpriteLB->setColor(ccc3

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-11-04 15:35  MyGoldMan\
     文件        6148  2013-11-04 20:17  MyGoldMan\.DS_Store
     目录           0  2013-11-12 08:31  __MACOSX\
     目录           0  2013-11-12 08:31  __MACOSX\MyGoldMan\
     文件          82  2013-11-04 20:17  __MACOSX\MyGoldMan\._.DS_Store
     目录           0  2013-11-11 11:43  MyGoldMan\MyGoldMan\
     文件        6148  2013-11-02 11:58  MyGoldMan\MyGoldMan\.DS_Store
     目录           0  2013-11-12 08:31  __MACOSX\MyGoldMan\MyGoldMan\
     文件          82  2013-11-02 11:58  __MACOSX\MyGoldMan\MyGoldMan\._.DS_Store
     目录           0  2013-11-07 20:27  MyGoldMan\MyGoldMan\Classes\
     文件        1807  2013-11-07 20:27  MyGoldMan\MyGoldMan\Classes\AppDelegate.cpp
     目录           0  2013-11-12 08:31  __MACOSX\MyGoldMan\MyGoldMan\Classes\
     文件         171  2013-11-07 20:27  __MACOSX\MyGoldMan\MyGoldMan\Classes\._AppDelegate.cpp
     文件        1142  2013-11-02 11:57  MyGoldMan\MyGoldMan\Classes\AppDelegate.h
     文件         171  2013-11-02 11:57  __MACOSX\MyGoldMan\MyGoldMan\Classes\._AppDelegate.h
     文件         692  2013-11-11 11:39  MyGoldMan\MyGoldMan\Data.h
     文件         171  2013-11-11 11:39  __MACOSX\MyGoldMan\MyGoldMan\._Data.h
     文件       14508  2013-11-11 09:17  MyGoldMan\MyGoldMan\Gamelayer.cpp
     文件         171  2013-11-11 09:17  __MACOSX\MyGoldMan\MyGoldMan\._Gamelayer.cpp
     文件        2020  2013-11-07 15:07  MyGoldMan\MyGoldMan\Gamelayer.h
     文件         171  2013-11-07 15:07  __MACOSX\MyGoldMan\MyGoldMan\._Gamelayer.h
     文件        2150  2013-11-06 15:06  MyGoldMan\MyGoldMan\GameOver.cpp
     文件         171  2013-11-06 15:06  __MACOSX\MyGoldMan\MyGoldMan\._GameOver.cpp
     文件         427  2013-11-06 10:33  MyGoldMan\MyGoldMan\GameOver.h
     文件         171  2013-11-06 10:33  __MACOSX\MyGoldMan\MyGoldMan\._GameOver.h
     文件        1734  2013-11-06 10:01  MyGoldMan\MyGoldMan\GameWin.cpp
     文件         171  2013-11-06 10:01  __MACOSX\MyGoldMan\MyGoldMan\._GameWin.cpp
     文件         415  2013-11-06 09:53  MyGoldMan\MyGoldMan\GameWin.h
     文件         171  2013-11-06 09:53  __MACOSX\MyGoldMan\MyGoldMan\._GameWin.h
     文件        2466  2013-11-07 12:16  MyGoldMan\MyGoldMan\Hook.cpp
     文件         171  2013-11-07 12:16  __MACOSX\MyGoldMan\MyGoldMan\._Hook.cpp
............此处省略1352个文件信息

评论

共有 条评论