"My hand travel debut-Star card" with code

Source: Internet
Author: User
Tags addchild

Use framework for Cocos2d-x, language C + +, editor Cocostudio Studio, adapter (1334,750)

A. Baidu network disk (new version)
Account Number: 13143525203
Password: 610767SS

Two. Link address (old version)

Http://android.myapp.com/myapp/detail.htm?apkName=susake.game.yzp

Http://a.app.qq.com/o/simple.jsp?pkgname=susake.game.yzp

Main logic

#include"MiniGame.h"#include"SimpleAudioEngine.h"#include<unistd.h>#include"WapsAd.h" //include WapsAd.h * in the called fileScene*Mini::createscene () {//' Scene ' is an Autorelease objectAuto scene =scene::create (); //' Layer ' is an Autorelease objectAuto Layer =mini::create (); //add layer as a child to sceneScene->addChild (layer); //return the scene    returnscene;}BOOLMini::init () {//Get device ResolutionVisiblesize = Director::getinstance ()getvisiblesize (); //system Return key callbackAuto Listener1 =eventlistenerkeyboard::create (); Listener1->onkeyreleased = Cc_callback_2 (mini::onkeyreleased, This); Director::getinstance ()->geteventdispatcher ()->addeventlistenerwithscenegraphpriority (Listener1, This); //Multi-Touch callbackAuto 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); //backgroundGamedir =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); //Initialize Game DirectionSp_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); //placing a stack of cardsCards = Sprite::create ("Uiminigame.img/mapleonecard.custom.3.deck.default.png"); Cards->setposition (VEC2 (Visiblesize.width/2- the, Visiblesize.height/2- -)); Cards->setscale (1.5f);  This->addchild (Cards,2); //load Player 1 (susake)Hero =NewMhero (); Hero->initboard ("Uiminigame.img/custom.element.icon.3.0.0.png","Susake", Visiblesize.width/2-510, Visiblesize.height/2- the); Hero->changeboardbystate (Myturn,true);  This->addchild (Hero->board,3); //Load Player 2 (Oriental unbeaten)MOB1 =NewMhero (); Mob1->initboard ("Uiminigame.img/custom.element.icon.3.0.1.png","The East is undefeated", Visiblesize.width/2-510, Visiblesize.height/2+ the); Mob1->changeboardbystate (NEXT,false);  This->addchild (Mob1->board,3); //load Player 3 (midnight Rattle)MOB2 =NewMhero (); Mob2->initboard ("Uiminigame.img/custom.element.icon.3.0.2.png","Midnight Bell", Visiblesize.width/2+510, Visiblesize.height/2+ the); Mob2->changeboardbystate (WAIT,false);  This->addchild (Mob2->board,3); //load Player 4 (hahaha)MOB3 =NewMhero (); MOB3->initboard ("Uiminigame.img/custom.element.icon.3.0.3.png","ha ha haha", Visiblesize.width/2+510, Visiblesize.height/2- the); MOB3->changeboardbystate (WAIT,false);  This->addchild (Mob3->board,3); //Place Player 1 cards, number of cardsMob1card = 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); //Place player 2 cards, number of cardsMob2card = 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); //Place player 3 cards, number of cardsMob3card = 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); //ShuffleClearcard ( the); //show number of cards_cardnumber = Label::createwithttf (" the","Fonts/marker Felt.ttf", the); _cardnumber->setposition (VEC2 (Visiblesize.width/2- the, Visiblesize.height/2+ the));// the      This->addchild (_cardnumber,2); Mob1cardnumber= Label::createwithttf ("6","Fonts/marker Felt.ttf", $); Mob1cardnumber->setposition (VEC2 (Visiblesize.width/2-380, Visiblesize.height/2+ -));// the      This->addchild (Mob1cardnumber,3); Mob2cardnumber= Label::createwithttf ("6","Fonts/marker Felt.ttf", $); Mob2cardnumber->setposition (VEC2 (Visiblesize.width/2+380, Visiblesize.height/2+ -));// the      This->addchild (Mob2cardnumber,3); Mob3cardnumber= Label::createwithttf ("6","Fonts/marker Felt.ttf", $); Mob3cardnumber->setposition (VEC2 (Visiblesize.width/2+380, Visiblesize.height/2- the));// the      This->addchild (Mob3cardnumber,3); //start the game Countdown     This->scheduleonce (Schedule_selector (Mini::gotime),3.5f); //Frames-per- frame update     This-scheduleupdate (); return true;}

"My hand travel debut-Star card" with code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.