mirror of https://github.com/axmolengine/axmol.git
add play ui
This commit is contained in:
parent
1aa92bdef0
commit
111840f37b
File diff suppressed because it is too large
Load Diff
|
@ -51,6 +51,13 @@ void ConfigParser::readConfig()
|
||||||
{
|
{
|
||||||
_initViewSize.width = objectInitView["width"].GetUint();
|
_initViewSize.width = objectInitView["width"].GetUint();
|
||||||
_initViewSize.height = objectInitView["height"].GetUint();
|
_initViewSize.height = objectInitView["height"].GetUint();
|
||||||
|
if (_initViewSize.height>_initViewSize.width)
|
||||||
|
{
|
||||||
|
float tmpvalue =_initViewSize.height;
|
||||||
|
_initViewSize.height = _initViewSize.width;
|
||||||
|
_initViewSize.width = tmpvalue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (objectInitView.HasMember("name") && objectInitView["name"].IsString())
|
if (objectInitView.HasMember("name") && objectInitView["name"].IsString())
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,50 +99,113 @@ bool reloadScript(const string& modulefile)
|
||||||
class ConnectWaitLayer: public Layer
|
class ConnectWaitLayer: public Layer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
LabelTTF* pLabelUploadFile;
|
Label* _labelUploadFile;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ConnectWaitLayer()
|
ConnectWaitLayer()
|
||||||
{
|
{
|
||||||
string strip = getIPAddress();
|
int designWidth = 1280;
|
||||||
char szIPAddress[512]={0};
|
int designHeight = 800;
|
||||||
sprintf(szIPAddress, "LocalIP: %s",strip.c_str());
|
Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designWidth,designHeight,ResolutionPolicy::EXACT_FIT);
|
||||||
auto label = LabelTTF::create(szIPAddress, "Arial", 24);
|
string playEnbleFile = "res/debug/Play1.png";
|
||||||
addChild(label, 9999);
|
string shineFile = "res/debug/shine.png";
|
||||||
label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
string backgroundFile = "res/debug/landscape.png";
|
||||||
|
if (!ConfigParser::getInstance()->isLanscape())
|
||||||
string strShowMsg ="";
|
|
||||||
if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM || CC_PLATFORM_MAC == CC_TARGET_PLATFORM)
|
|
||||||
{
|
{
|
||||||
strShowMsg = "waiting for debugger to connect ...";
|
backgroundFile = "res/debug/portrait.png";
|
||||||
|
Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designHeight,designWidth,ResolutionPolicy::EXACT_FIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto background = Sprite::create(backgroundFile.c_str());
|
||||||
|
if (background)
|
||||||
|
{
|
||||||
|
background->setAnchorPoint(Vec2(0,0));
|
||||||
|
addChild(background,9999);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto playSprite = Sprite::create(playEnbleFile.c_str());
|
||||||
|
if (playSprite)
|
||||||
|
{
|
||||||
|
playSprite->setPosition(Vec2(902,400));
|
||||||
|
addChild(playSprite,9999);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
strShowMsg = "waiting for file transfer ...";
|
auto labelPlay = LabelTTF::create("play", "Arial", 108);
|
||||||
}
|
|
||||||
auto labelwait = LabelTTF::create(strShowMsg.c_str(), "Arial", 22);
|
|
||||||
addChild(labelwait, 10000);
|
|
||||||
labelwait->setPosition( Point(VisibleRect::center().x, VisibleRect::center().y) );
|
|
||||||
|
|
||||||
pLabelUploadFile = LabelTTF::create("", "Arial", 22);
|
|
||||||
addChild(pLabelUploadFile, 10000);
|
|
||||||
pLabelUploadFile->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
|
||||||
|
|
||||||
auto labelPlay = LabelTTF::create("play", "Arial", 36);
|
|
||||||
auto menuItem = MenuItemLabel::create(labelPlay, CC_CALLBACK_1(ConnectWaitLayer::playerCallback, this));
|
auto menuItem = MenuItemLabel::create(labelPlay, CC_CALLBACK_1(ConnectWaitLayer::playerCallback, this));
|
||||||
auto menu = Menu::create(menuItem, NULL);
|
auto menu = Menu::create(menuItem, NULL);
|
||||||
|
|
||||||
menu->setPosition( Point::ZERO );
|
menu->setPosition( Point::ZERO );
|
||||||
menuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) );
|
menuItem->setPosition(Vec2(902,400));
|
||||||
|
if (!ConfigParser::getInstance()->isLanscape()) menuItem->setPosition(Vec2(400,500));
|
||||||
addChild(menu, 1);
|
addChild(menu, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto shineSprite = Sprite::create(shineFile.c_str());
|
||||||
|
if (shineSprite)
|
||||||
|
{
|
||||||
|
shineSprite->setPosition(Vec2(902,400));
|
||||||
|
shineSprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(1.0f, 1.08f),ScaleTo::create(1.0f, 1))));
|
||||||
|
addChild(shineSprite,9999);
|
||||||
|
}
|
||||||
|
|
||||||
|
string strip = getIPAddress();
|
||||||
|
char szIPAddress[512]={0};
|
||||||
|
sprintf(szIPAddress, "LocalIP: %s",strip.c_str());
|
||||||
|
auto IPlabel = Label::create(szIPAddress, "Arial", 36);
|
||||||
|
IPlabel->setAnchorPoint(Vec2(0,0));
|
||||||
|
int spaceSize = 72;
|
||||||
|
IPlabel->setPosition( Point(VisibleRect::leftTop().x+spaceSize, VisibleRect::top().y -spaceSize) );
|
||||||
|
addChild(IPlabel, 9999);
|
||||||
|
|
||||||
|
string strShowMsg = "waiting for file transfer ...";
|
||||||
|
if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM || CC_PLATFORM_MAC == CC_TARGET_PLATFORM)
|
||||||
|
{
|
||||||
|
strShowMsg = "waiting for debugger to connect ...";
|
||||||
|
}
|
||||||
|
|
||||||
|
_labelUploadFile = Label::create(strShowMsg.c_str(), "Arial", 24);
|
||||||
|
_labelUploadFile->setAnchorPoint(Vec2(0,0));
|
||||||
|
_labelUploadFile->setPosition( Point(VisibleRect::leftTop().x+spaceSize, IPlabel->getPositionY()-spaceSize) );
|
||||||
|
_labelUploadFile->setAlignment(TextHAlignment::LEFT);
|
||||||
|
addChild(_labelUploadFile, 10000);
|
||||||
|
|
||||||
|
if (!ConfigParser::getInstance()->isLanscape())
|
||||||
|
{
|
||||||
|
if (playSprite) playSprite->setPosition(400,500);
|
||||||
|
if (shineSprite) shineSprite->setPosition(400,500);
|
||||||
|
_labelUploadFile->setAlignment(TextHAlignment::LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playSprite)
|
||||||
|
{
|
||||||
|
auto listener = EventListenerTouchOneByOne::create();
|
||||||
|
listener->onTouchBegan = [](Touch* touch, Event *event)->bool{
|
||||||
|
auto target = static_cast<Sprite*>(event->getCurrentTarget());
|
||||||
|
Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
|
||||||
|
auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height);
|
||||||
|
if (!rect.containsPoint(point)) return false;
|
||||||
|
target->stopAllActions();
|
||||||
|
target->runAction(Sequence::createWithTwoActions(ScaleBy::create(0.05f, 0.9f),ScaleTo::create(0.125f, 1)));
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
listener->onTouchEnded = [](Touch* touch, Event *event){
|
||||||
|
auto target = static_cast<Sprite*>(event->getCurrentTarget());
|
||||||
|
Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
|
||||||
|
auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height);
|
||||||
|
if (!rect.containsPoint(point)) return;
|
||||||
|
startScript("");
|
||||||
|
};
|
||||||
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, playSprite);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void playerCallback(Object* sender)
|
void playerCallback(Object* sender)
|
||||||
{
|
{
|
||||||
startScript("");
|
startScript("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void showCurRcvFile(string fileName) {
|
void showCurRcvFile(string fileName) {
|
||||||
pLabelUploadFile->setString(fileName);
|
_labelUploadFile->setString(fileName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -98,16 +98,16 @@ std::string getCurAppPath(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!g_landscape)
|
||||||
|
{
|
||||||
|
float tmpvalue =width;
|
||||||
|
width = height;
|
||||||
|
height = tmpvalue;
|
||||||
|
}
|
||||||
|
|
||||||
g_eglView = GLView::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor);
|
g_eglView = GLView::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor);
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
director->setOpenGLView(g_eglView);
|
director->setOpenGLView(g_eglView);
|
||||||
g_landscape = false;
|
|
||||||
g_screenSize.width = width;
|
|
||||||
g_screenSize.height = height;
|
|
||||||
if (width > height)
|
|
||||||
{
|
|
||||||
g_landscape = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
window = glfwGetCocoaWindow(g_eglView->getWindow());
|
window = glfwGetCocoaWindow(g_eglView->getWindow());
|
||||||
[NSApp setDelegate: self];
|
[NSApp setDelegate: self];
|
||||||
|
@ -124,12 +124,15 @@ void createSimulator(const char* viewName, float width, float height,bool isLand
|
||||||
{
|
{
|
||||||
if(g_nsAppDelegate)
|
if(g_nsAppDelegate)
|
||||||
{
|
{
|
||||||
if((isLandscape && height > width) || (!isLandscape && width > height))
|
g_landscape = isLandscape;
|
||||||
|
if(height > width)
|
||||||
{
|
{
|
||||||
float tmpvalue =width;
|
float tmpvalue =width;
|
||||||
width = height;
|
width = height;
|
||||||
height = tmpvalue;
|
height = tmpvalue;
|
||||||
}
|
}
|
||||||
|
g_screenSize.width = width;
|
||||||
|
g_screenSize.height = height;
|
||||||
|
|
||||||
[g_nsAppDelegate createSimulator:[NSString stringWithUTF8String:viewName] viewWidth:width viewHeight:height factor:frameZoomFactor];
|
[g_nsAppDelegate createSimulator:[NSString stringWithUTF8String:viewName] viewWidth:width viewHeight:height factor:frameZoomFactor];
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,17 @@ void createSimulator(const char* viewName, float width, float height, bool isLan
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((isLandscape && height > width) || (!isLandscape && width > height))
|
g_landscape = isLandscape;
|
||||||
|
if(height > width)
|
||||||
|
{
|
||||||
|
float tmpvalue =width;
|
||||||
|
width = height;
|
||||||
|
height = tmpvalue;
|
||||||
|
}
|
||||||
|
g_screenSize.width = width;
|
||||||
|
g_screenSize.height = height;
|
||||||
|
|
||||||
|
if(!g_landscape)
|
||||||
{
|
{
|
||||||
float tmpvalue =width;
|
float tmpvalue =width;
|
||||||
width = height;
|
width = height;
|
||||||
|
@ -318,13 +328,6 @@ void createSimulator(const char* viewName, float width, float height, bool isLan
|
||||||
g_eglView = GLView::createWithRect(viewName,Rect(0,0,width,height),frameZoomFactor);
|
g_eglView = GLView::createWithRect(viewName,Rect(0,0,width,height),frameZoomFactor);
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
director->setOpenGLView(g_eglView);
|
director->setOpenGLView(g_eglView);
|
||||||
g_landscape = false;
|
|
||||||
g_screenSize.width = width;
|
|
||||||
g_screenSize.height = height;
|
|
||||||
if (width > height)
|
|
||||||
{
|
|
||||||
g_landscape = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
HWND hWnd=glfwGetWin32Window(g_eglView->getWindow());
|
HWND hWnd=glfwGetWin32Window(g_eglView->getWindow());
|
||||||
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MENU_COCOS));
|
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MENU_COCOS));
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
After Width: | Height: | Size: 147 KiB |
Binary file not shown.
After Width: | Height: | Size: 131 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue