拉伸菜单与返回菜单
来源:互联网 发布:网络词汇用语2017最新 编辑:程序博客网 时间:2024/05/16 09:22
//前言: 希望我的博客能帮助到那些出入cocos2d-x的小伙伴们,我的也刚刚入职没多久差不多一年快一年了,我希望新手小伙伴们不要一味的去抄袭别人的博客,你要带着思考去理解别人为什么要这样写,这样写的作用是什么,有什么不足或者有哪些优点。
废话不多说开始撸码;
ifndef SWALLOWTOUCH_H
define SWALLOWTOUCH_H
include “cocos2d.h”
include “HelloWorldScene.h”
include “cocostudio/CocoStudio.h”
include “ui/CocosGUI.h”
include “swallowTouch.h”
include
class swallowTouch : public Layer{public: swallowTouch(); ~swallowTouch(); static Scene* crectscene(); virtual bool init(); void MoveMenu(Ref *obj); Sprite* sprite_image; bool _isScale; void Hore_Menu(Ref *obj); void Hore_Menu2(Ref *obj); //Hoer footer_soul strongthen team settings_icon CC_SYNTHESIZE(ui::Button*, m_pButton, Button); //footer_soul CC_SYNTHESIZE(ui::Button*, m_pFooter_soulButton, Footer_soulButton); //Strongthen; CC_SYNTHESIZE(ui::Button*, m_pStrongthenButton, StrongthenButton); //Team CC_SYNTHESIZE(ui::Button*, m_pTeamButton, TeamButton); //Settings_icon CC_SYNTHESIZE(ui::Button*, m_pSettings_iconButton, Settings_iconButton); CREATE_FUNC(swallowTouch);};#endif // !__SWALLOWTOUCH_H__
CPP
#include "swallowTouch.h"swallowTouch::swallowTouch() :_isScale(false), m_pButton(nullptr), m_pFooter_soulButton(nullptr), m_pSettings_iconButton(nullptr), m_pStrongthenButton(nullptr), m_pTeamButton(nullptr){}swallowTouch::~swallowTouch(){}bool swallowTouch::init(){ if (!Layer::init()) { return false; } Size size = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); sprite_image = Sprite::create("cbattle_page_name_bg.png"); sprite_image->setPosition(Vec2(size.width / 2 + 703, size.height / 2 - 320)); //sprite_image->setTag(10); this->addChild(sprite_image); /*MoveMenu(Ref *obj);*/ auto hero_button = MenuItemImage::create("footer_menu_close.png", "footer_menu_close1.png", CC_CALLBACK_1(swallowTouch::MoveMenu, this)); hero_button->setPosition(Vec2(size.width / 2 + 470, size.height / 2 - 320)); auto menu = Menu::create(hero_button, NULL); menu->setPosition(Vec2::ZERO); this->addChild(menu, 1); //Hore Button; m_pButton = Button::create("footer_menu_hero.png", "slowleaf.png"); getButton()->setAnchorPoint(ccp(0, 0)); getButton()->setPosition(ccp(0, 0)); sprite_image->addChild(getButton()); ScaleTo* slto1 = ScaleTo::create(0.0f, 0.35f, 0.35f); m_pButton->runAction(slto1); //footer_soul Button; m_pFooter_soulButton = Button::create("footer_menu_soul.png", "slowleaf2.png"); getFooter_soulButton()->setAnchorPoint(ccp(0, 0)); getFooter_soulButton()->setPosition(ccp(35, 0)); sprite_image->addChild(getFooter_soulButton()); ScaleTo* slto2 = ScaleTo::create(0.0f, 0.35f, 0.35f); m_pFooter_soulButton->runAction(slto2); //strongthen Button; m_pSettings_iconButton = Button::create("footer_menu_strongthen.png", "slowleaf3.png"); getSettings_iconButton()->setAnchorPoint(ccp(0, 0)); getSettings_iconButton()->setPosition(ccp(70, 0)); sprite_image->addChild(getSettings_iconButton()); ScaleTo* slto3 = ScaleTo::create(0.0f, 0.35f, 0.35f); m_pSettings_iconButton->runAction(slto3); //team Button; m_pStrongthenButton = Button::create("footer_menu_team.png", "slowleaf4.png"); getStrongthenButton()->setAnchorPoint(ccp(0, 0)); getStrongthenButton()->setPosition(ccp(105, 0)); sprite_image->addChild(getStrongthenButton()); ScaleTo* slto4 = ScaleTo::create(0.0f, 0.35f, 0.35f); m_pStrongthenButton->runAction(slto4); //settings_icon Button; m_pTeamButton = Button::create("settings_icon.png", "slowleaf5.png"); getTeamButton()->setAnchorPoint(ccp(0, 0)); getTeamButton()->setPosition(ccp(140, 0)); sprite_image->addChild(getTeamButton()); ScaleTo* slto5 = ScaleTo::create(0.0f, 0.6f, 0.6f); m_pTeamButton->runAction(slto5);/* auto hero_button4 = MenuItemImage::create("footer_menu_strongthen.png", "footer_menu_close3.png", CC_CALLBACK_1(swallowTouch::MoveMenu, this)); hero_button4->setPosition(Vec2(size.width / 2, size.height / 2)); auto menu4 = Menu::create(hero_button4, NULL); menu4->setPosition(Vec2::ZERO); this->addChild(menu4, 1);*/ return true;}Scene* swallowTouch::crectscene(){ auto scene = Scene::create(); auto layer = swallowTouch::create(); scene->addChild(layer); return scene;}void swallowTouch::MoveMenu(Ref *obj){ Size size = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); ScaleTo* slto = ScaleTo::create(0.0f, 2.0f, 2.0f); sprite_image->runAction(slto); MoveTo* c_moveby; if (_isScale) { //缩 c_moveby = MoveTo::create(0, Vec2(size.width / 2 + 703, size.height / 2 - 320)); sprite_image->runAction(c_moveby); _isScale = false; } else { //伸 c_moveby = MoveTo::create(0, Vec2(size.width / 2 + 270, size.height / 2 - 320)); sprite_image->runAction(c_moveby); _isScale = true; } //移动; Sequence* pSequence = Sequence::create(slto, c_moveby, NULL);}void swallowTouch::Hore_Menu(Ref *obj){ log("hore hore"); //MoveMenu();}void swallowTouch::Hore_Menu2(Ref *obj){ log("--------");}
0 0
- 拉伸菜单与返回菜单
- JQuery经典例子:可拉伸菜单
- 下拉菜单与横向菜单
- 通知与菜单子菜单
- DrawerLayout侧滑菜单按钮与返回按钮切换
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- 菜单
- java中的反射机制
- 减少存储过程封装业务逻辑-web开发与传统软件开发的思维模式不同
- iOS 开发的9个超有用小技巧
- 理财达人五步走
- CSS滤镜(Filters)
- 拉伸菜单与返回菜单
- Android学习笔记--ListView的数据绑定
- 最全的ftp 操作工具(所有方法经过测试,附ftp 服务配置)
- 克服扬长避短,打破坏习惯
- uva 10689 Yet another Number Sequence【矩阵快速幂】
- Android开发_Activity在屏幕旋转时的生命周期
- 12个Flex常用功能代码再现
- 基础加强第四天 正则表达式和XML
- JavaScript 学习网站