使用框架为Cocos2d-X,语言C++,编辑器Cocostudio Studio,适配(1334,750)
下载地址
一.百度网盘(新版本)
账号:13143525203
密码:610767ss
二.链接地址(老版本)
http://android.myapp.com/myapp/detail.htm?apkName=susake.game.yzp
http://a.app.qq.com/o/simple.jsp?pkgname=susake.game.yzp
主要逻辑
#include "MiniGame.h" #include "SimpleAudioEngine.h" #include <unistd.h> #include "WapsAd.h" //在调用的文件中包含 WapsAd.h * Scene* MINI::createScene() { // ‘scene‘ is an autorelease object auto scene = Scene::create(); // ‘layer‘ is an autorelease object auto layer = MINI::create(); // add layer as a child to scene scene->addChild(layer); // return the scene return scene; } bool MINI::init() { //获取设备分辨率 visibleSize = Director::getInstance()->getVisibleSize(); //系统返回键回调 auto listener1 = EventListenerKeyboard::create(); listener1->onKeyReleased = CC_CALLBACK_2(MINI::onKeyReleased,this); Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener1,this); //多点触碰回调 auto listener2 = EventListenerTouchAllAtOnce::create(); listener2->onTouchesBegan = CC_CALLBACK_2(MINI::onTouchesBegan, this); listener2->onTouchesMoved = CC_CALLBACK_2(MINI::onTouchesMoved, this); listener2->onTouchesEnded = CC_CALLBACK_2(MINI::onTouchesEnded, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener2, this); //背景 gamedir = RIGHT; CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("AboveTheTreetops.mp3", true); auto bg = Sprite::create("UIMiniGame.img/mapleOneCard.Board.backgrnd.png"); bg->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2)); this->addChild(bg, 1); //初始化游戏方向 sp_dir = Sprite::create("UIMiniGame.img/mapleOneCard.Board.direction.0.png"); sp_dir->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 + 260)); this->addChild(sp_dir, 2, 2); //放置牌堆 cards = Sprite::create("UIMiniGame.img/mapleOneCard.Custom.3.Deck.default.png"); cards->setPosition(Vec2(visibleSize.width / 2 - 320, visibleSize.height / 2 - 17)); cards->setScale(1.5f); this->addChild(cards, 2); //加载玩家1(Susake) hero = new MHero(); hero->InitBoard("UIMiniGame.img/custom.element.icon.3.0.0.png", "Susake", visibleSize.width / 2 - 510, visibleSize.height / 2 - 230); hero->ChangeBoardByState(MYTURN, true); this->addChild(hero->board, 3); //加载玩家2(东方不败) mob1 = new MHero(); mob1->InitBoard("UIMiniGame.img/custom.element.icon.3.0.1.png", "东方不败", visibleSize.width / 2 - 510, visibleSize.height / 2 + 180); mob1->ChangeBoardByState(NEXT, false); this->addChild(mob1->board, 3); //加载玩家3(午夜凶铃) mob2 = new MHero(); mob2->InitBoard("UIMiniGame.img/custom.element.icon.3.0.2.png", "午夜凶铃", visibleSize.width / 2 + 510, visibleSize.height / 2 + 180); mob2->ChangeBoardByState(WAIT, false); this->addChild(mob2->board, 3); //加载玩家4(哈哈哈) mob3 = new MHero(); mob3->InitBoard("UIMiniGame.img/custom.element.icon.3.0.3.png", "哈哈哈", visibleSize.width / 2 + 510, visibleSize.height / 2 - 230); mob3->ChangeBoardByState(WAIT, false); this->addChild(mob3->board, 3); //放置玩家1卡牌,牌数 mob1card = Sprite::create("UIMiniGame.img/mapleOneCard.Custom.5.Deck.default.png"); mob1card->setPosition(Vec2(mob1->mob1card_x, mob1->mob1card_y)); mob1card->setScale(1.2f); this->addChild(mob1card, 2); //放置玩家2卡牌,牌数 mob2card = Sprite::create("UIMiniGame.img/mapleOneCard.Custom.5.Deck.default.png"); mob2card->setPosition(Vec2(mob2->mob2card_x, mob2->mob2card_y)); mob2card->setScale(1.2f); this->addChild(mob2card, 2); //放置玩家3卡牌,牌数 mob3card = Sprite::create("UIMiniGame.img/mapleOneCard.Custom.5.Deck.default.png"); mob3card->setPosition(Vec2(mob3->mob3card_x, mob3->mob3card_y)); mob3card->setScale(1.2f); this->addChild(mob3card, 2); //洗牌 ClearCard(52); //显示牌数 _cardnumber = Label::createWithTTF("52", "fonts/Marker Felt.ttf", 15); _cardnumber->setPosition(Vec2(visibleSize.width / 2 - 320, visibleSize.height / 2 + 80));//400 300 this->addChild(_cardnumber, 2); mob1cardnumber = Label::createWithTTF("6", "fonts/Marker Felt.ttf", 45); mob1cardnumber->setPosition(Vec2(visibleSize.width / 2 - 380, visibleSize.height / 2 + 240));//400 300 this->addChild(mob1cardnumber, 3); mob2cardnumber = Label::createWithTTF("6", "fonts/Marker Felt.ttf", 45); mob2cardnumber->setPosition(Vec2(visibleSize.width / 2 + 380, visibleSize.height / 2 + 240));//400 300 this->addChild(mob2cardnumber, 3); mob3cardnumber = Label::createWithTTF("6", "fonts/Marker Felt.ttf", 45); mob3cardnumber->setPosition(Vec2(visibleSize.width / 2 + 380, visibleSize.height / 2 - 180));//400 300 this->addChild(mob3cardnumber, 3); //开始游戏倒计时 this->scheduleOnce(schedule_selector(MINI::gotime), 3.5f); //逐帧更新 this->scheduleUpdate(); return true; }
时间: 2024-10-01 18:45:40