mirror of
https://github.com/wu736139669/OzgGameRPG.git
synced 2026-08-05 06:24:38 +00:00
102 lines
3.1 KiB
C++
102 lines
3.1 KiB
C++
//
|
|
// RPGMapEquipMenuLayer.cpp
|
|
// OzgGameRPG
|
|
//
|
|
// Created by ozg on 14-4-10.
|
|
//
|
|
//
|
|
|
|
#include "RPGMapEquipMenuLayer.h"
|
|
#include "RPGMapMenuLayer.h"
|
|
#include "RPGMapSceneLayer.h"
|
|
|
|
RPGMapEquipMenuLayer::RPGMapEquipMenuLayer()
|
|
{
|
|
|
|
}
|
|
|
|
RPGMapEquipMenuLayer::~RPGMapEquipMenuLayer()
|
|
{
|
|
this->m_stringList->release();
|
|
|
|
CCLog("RPGMapEquipMenuLayer 释放");
|
|
}
|
|
|
|
bool RPGMapEquipMenuLayer::init(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
|
|
{
|
|
if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
|
|
{
|
|
this->m_stringList = stringList;
|
|
this->m_stringList->retain();
|
|
|
|
this->m_db = db;
|
|
|
|
CCMenu *mainMenu = CCMenu::create();
|
|
mainMenu->setTag(kRPGMapEquipMenuLayerTagMainMenu);
|
|
mainMenu->setAnchorPoint(CCPointZero);
|
|
mainMenu->setPosition(CCPointZero);
|
|
this->addChild(mainMenu);
|
|
|
|
CCMenuItemSprite *menuBack = (CCMenuItemSprite*)mainMenu->getChildByTag(kRPGMapEquipMenuLayerTagMainMenuBack);
|
|
if(!menuBack)
|
|
{
|
|
menuBack = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapEquipMenuLayer::onMenu));
|
|
menuBack->setPosition(ccp(40, 600));
|
|
menuBack->setTag(kRPGMapEquipMenuLayerTagMainMenuBack);
|
|
menuBack->setScale(0.5);
|
|
mainMenu->addChild(menuBack);
|
|
}
|
|
|
|
CCTMXTiledMap *mainBg = CCTMXTiledMap::create("map_menu2_style1.tmx");
|
|
mainBg->setPosition(CCPointZero);
|
|
mainBg->setTag(kRPGMapEquipMenuLayerTagBg);
|
|
this->addChild(mainBg);
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
RPGMapEquipMenuLayer* RPGMapEquipMenuLayer::create(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
|
|
{
|
|
RPGMapEquipMenuLayer *obj = new RPGMapEquipMenuLayer();
|
|
if(obj && obj->init(stringList, db, width, height))
|
|
{
|
|
obj->autorelease();
|
|
return obj;
|
|
}
|
|
CC_SAFE_DELETE(obj);
|
|
return NULL;
|
|
}
|
|
|
|
//private
|
|
void RPGMapEquipMenuLayer::onMenu(cocos2d::CCObject *pObject)
|
|
{
|
|
CCMenuItem *menuItem = (CCMenuItem*)pObject;
|
|
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
|
|
|
|
switch (menuItem->getTag())
|
|
{
|
|
case kRPGMapEquipMenuLayerTagMainMenuBack:
|
|
{
|
|
// CCLog("后退");
|
|
|
|
//因为动态获取地图的大小会导致了菜单层显示错位,所以定死了
|
|
float width = 960;
|
|
float height = 640;
|
|
RPGMapMenuLayer *menuLayer = menuLayer = RPGMapMenuLayer::create(this->m_stringList, this->m_db, width, height);
|
|
menuLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - width) / 2.0, (CCDirector::sharedDirector()->getWinSize().height - height) / 2.0));
|
|
menuLayer->setTag(kRPGMapSceneLayerTagMenuLayer);
|
|
this->getParent()->addChild(menuLayer);
|
|
|
|
this->removeFromParentAndCleanup(true);
|
|
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|