1 //2 //attgamepoker.hpp3 //Malagame4 //5 //Created by work on 2016/11/09.6 //7 //8 9 #ifndef attgamepoker_hppTen #defineAttgamepoker_hpp One A#include <stdio.h> -#include <cocos2d.h> - the - classAttgamepoker: PublicCocos2d::layer - { - + Private: - +Cocos2d::ui::button * M_btnone;//Button A atCocos2d::ui::button * M_BTNTOW; - Public: - - Virtual BOOLinit (); - - voidONECB (Ref *psender, cocos2d::ui::widget::toucheventtype type);//declaring a Click event in voidTOWCB (REF *Psender, Cocos2d::ui::widget::toucheventtype type); - to + voidOnefloatDT);//Timer Call - the voidTow ();//Animation delay Call * $ Panax Notoginseng Create_func (attgamepoker); - the }; + A #endif/* ATTGAMEPOKER_HPP */
1 //2 //ATTGamePoker.cpp3 //ATT4 //5 //Created by work on 16/10/13.6 //7 //8 9#include"attgamepoker.hpp"Ten#include"SimpleAudioEngine.h" One A using_ns_cc; - -scene*Attgamepoker::createscene () the { - //' Scene ' is an Autorelease object -Auto scene =scene::create (); - + //' Layer ' is an Autorelease object -Auto Layer =attgamepoker::create (); + A //add layer as a child to scene atScene->addChild (layer); - - //return the scene - returnscene; - } - in - BOOLAttgamepoker::init () to { + - the if( !layer::init ()) * { $ return false;Panax Notoginseng } - the + A theAuto Soundbg=cocos2d::ui::scale9sprite::createwithspriteframename ("Gobang_option_sound_off.png"); +Soundbg->setscale (0.667); -M_btnone=controlbutton::create (soundbg); $M_btnone->setpreferredsize (Cocos2d::size (162, -)); $M_btnone->setposition (GetPoint (1136,627)); -M_btnone->addtargetwithactionforcontrolevents ( This, Cccontrol_selector (ATTGAMEPOKER::ONECB), control::eventtype::touch_up_inside); - This-AddChild (m_btnone); the - Wuyi the -Auto Soundbg2=cocos2d::ui::scale9sprite::createwithspriteframename ("Gobang_option_sound_off.png"); WuSoundbg2->setscale (0.667); -m_btntow=controlbutton::create (SOUNDBG2); AboutM_btntow->setpreferredsize (Cocos2d::size (162, -)); $M_btntow->setposition (GetPoint (1036,627)); -M_btntow->addtargetwithactionforcontrolevents ( This, Cccontrol_selector (ATTGAMEPOKER::TOWCB), control::eventtype::touch_up_inside); - This-AddChild (M_btntow); - A + the ThisSchedule (Schedule_selector (Attgamepoker::one),10.0);//10 second Call once - $ the This->runaction (Sequence::create (Delaytime::create (5.0f), Callfunc::create (Cc_callback_0 (Attgamepoker::tow, This)), or NULL);//Action delay call, 5 seconds once the the the - // in the return true; the } About the //Implementing a deferred call method the voidAttgamepoker:: One () the { + This->ONECB ( This, widget::toucheventtype::ended); //Invoke event when passing current this, and determine the type of click - } the Bayi voidAttgamepoker:: Tow ()/***G Score **/ the { the This->TOWCB ( This, widget::toucheventtype::ended); - } - the the the the //Implement button click Invoke Method - voidATTGAMEPOKER::ONECB (COCOS2D::REF *Psender, Cocos2d::ui::widget::toucheventtype type) the { the if(Type! =widget::toucheventtype::ended) //Determine the current click Type, button press release to take effect, execute the PRINT statement, or return directly, do not execute the following print statement the {94 return; the } the theCclog ("This method is called by the timer");98 } About - 101 102 voidATTGAMEPOKER::TOWCB (COCOS2D::REF *Psender, Cocos2d::ui::widget::toucheventtype type)103 {104 if(Type! =widget::toucheventtype::ended) the {106 return;107 }108 109Cclog ("This method is called by the action delay"); the}
COCOS2DX 3.x (timer or delay action automatically invokes button's click-Response event) for automatic beta