diff --git a/Extensions/PanelSpriteObject/JsExtension.cpp b/Extensions/PanelSpriteObject/JsExtension.cpp index 3892e3d6e3..ce9ce3964b 100644 --- a/Extensions/PanelSpriteObject/JsExtension.cpp +++ b/Extensions/PanelSpriteObject/JsExtension.cpp @@ -29,7 +29,8 @@ public: GetObjectMetadata("PanelSpriteObject::PanelSprite") .SetIncludeFile("PanelSpriteObject/panelspriteruntimeobject.js") - .AddIncludeFile("PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js"); + .AddIncludeFile("PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js") + .AddIncludeFile("PanelSpriteObject/panelspriteruntimeobject-cocos-renderer.js"); GetAllActionsForObject("PanelSpriteObject::PanelSprite")["PanelSpriteObject::Width"].SetFunctionName("setWidth").SetGetter("getWidth"); GetAllConditionsForObject("PanelSpriteObject::PanelSprite")["PanelSpriteObject::Width"].SetFunctionName("getWidth"); diff --git a/Extensions/TextObject/JsExtension.cpp b/Extensions/TextObject/JsExtension.cpp index 5efab5cdfc..a8f4e75848 100644 --- a/Extensions/TextObject/JsExtension.cpp +++ b/Extensions/TextObject/JsExtension.cpp @@ -30,7 +30,8 @@ public: GetObjectMetadata("TextObject::Text") .SetIncludeFile("TextObject/textruntimeobject.js") - .AddIncludeFile("TextObject/textruntimeobject-pixi-renderer.js"); + .AddIncludeFile("TextObject/textruntimeobject-pixi-renderer.js") + .AddIncludeFile("TextObject/textruntimeobject-cocos-renderer.js"); GetAllActionsForObject("TextObject::Text")["TextObject::String"].SetFunctionName("setString").SetGetter("getString").SetIncludeFile("TextObject/textruntimeobject.js"); GetAllConditionsForObject("TextObject::Text")["TextObject::String"].SetFunctionName("getString").SetIncludeFile("TextObject/textruntimeobject.js"); diff --git a/Extensions/TiledSpriteObject/JsExtension.cpp b/Extensions/TiledSpriteObject/JsExtension.cpp index 22c824263d..6db4e84fbf 100644 --- a/Extensions/TiledSpriteObject/JsExtension.cpp +++ b/Extensions/TiledSpriteObject/JsExtension.cpp @@ -31,7 +31,8 @@ public: GetObjectMetadata("TiledSpriteObject::TiledSprite") .SetIncludeFile("TiledSpriteObject/tiledspriteruntimeobject.js") - .AddIncludeFile("TiledSpriteObject/tiledspriteruntimeobject-pixi-renderer.js"); + .AddIncludeFile("TiledSpriteObject/tiledspriteruntimeobject-pixi-renderer.js") + .AddIncludeFile("TiledSpriteObject/tiledspriteruntimeobject-cocos-renderer.js"); GetAllActionsForObject("TiledSpriteObject::TiledSprite")["TiledSpriteObject::Width"].SetFunctionName("setWidth").SetGetter("getWidth").SetIncludeFile("TiledSpriteObject/tiledspriteruntimeobject.js"); GetAllConditionsForObject("TiledSpriteObject::TiledSprite")["TiledSpriteObject::Width"].SetFunctionName("getWidth").SetIncludeFile("TiledSpriteObject/tiledspriteruntimeobject.js"); diff --git a/GDJS/GDJS/Extensions/JsPlatform.cpp b/GDJS/GDJS/Extensions/JsPlatform.cpp index bfacaa8152..a394ef1345 100644 --- a/GDJS/GDJS/Extensions/JsPlatform.cpp +++ b/GDJS/GDJS/Extensions/JsPlatform.cpp @@ -71,8 +71,8 @@ public: Exporter exporter(gd::NativeFileSystem::Get()); bool exportSuccessed = externalLayout ? - exporter.ExportExternalLayoutForPreview(project, layout, *externalLayout, exportDir) : - exporter.ExportLayoutForPreview(project, layout, exportDir); + exporter.ExportExternalLayoutForPixiPreview(project, layout, *externalLayout, exportDir) : + exporter.ExportLayoutForPixiPreview(project, layout, exportDir); if (!exportSuccessed) { diff --git a/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.cpp b/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.cpp index 52dd28c0fc..290371b55e 100644 --- a/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.cpp +++ b/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.cpp @@ -180,48 +180,88 @@ BaseProjectExportDialog::BaseProjectExportDialog(wxWindow* parent, wxWindowID id flexGridSizer1147->Add(m_staticText6768, 0, wxALL|wxEXPAND|wxALIGN_CENTER|wxALIGN_LEFT, 5); - m_panel71 = new wxPanel(exportChoice, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); - exportChoice->AddPage(m_panel71, _("Mobile and web stores using CocoonJS (Experimental)"), false); + m_panel611 = new wxPanel(exportChoice, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL); + exportChoice->AddPage(m_panel611, _("Export to a website or native game with Cocos2d (experimental)"), false); - wxFlexGridSizer* flexGridSizer551 = new wxFlexGridSizer(0, 1, 0, 0); - flexGridSizer551->SetFlexibleDirection( wxBOTH ); - flexGridSizer551->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - flexGridSizer551->AddGrowableCol(0); - flexGridSizer551->AddGrowableRow(1); - m_panel71->SetSizer(flexGridSizer551); + wxFlexGridSizer* flexGridSizer342 = new wxFlexGridSizer(0, 1, 0, 0); + flexGridSizer342->SetFlexibleDirection( wxBOTH ); + flexGridSizer342->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer342->AddGrowableCol(0); + m_panel611->SetSizer(flexGridSizer342); - cocoonjslogoPanel2 = new wxPanel(m_panel71, wxID_ANY, wxDefaultPosition, wxSize(-1,-1), wxTAB_TRAVERSAL|wxBORDER_SIMPLE); - cocoonjslogoPanel2->SetBackgroundColour(wxColour(wxT("rgb(51,16,69)"))); + wxFlexGridSizer* flexGridSizer353 = new wxFlexGridSizer(0, 3, 0, 0); + flexGridSizer353->SetFlexibleDirection( wxBOTH ); + flexGridSizer353->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer353->AddGrowableCol(0); + flexGridSizer353->AddGrowableRow(0); - flexGridSizer551->Add(cocoonjslogoPanel2, 0, wxALL|wxALIGN_CENTER, 0); + flexGridSizer342->Add(flexGridSizer353, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - wxFlexGridSizer* flexGridSizer633 = new wxFlexGridSizer(0, 2, 0, 0); - flexGridSizer633->SetFlexibleDirection( wxBOTH ); - flexGridSizer633->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - cocoonjslogoPanel2->SetSizer(flexGridSizer633); + wxFlexGridSizer* flexGridSizer364 = new wxFlexGridSizer(0, 2, 0, 0); + flexGridSizer364->SetFlexibleDirection( wxBOTH ); + flexGridSizer364->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer364->AddGrowableCol(1); - m_staticBitmap574 = new wxStaticBitmap(cocoonjslogoPanel2, wxID_ANY, wxXmlResource::Get()->LoadBitmap(wxT("cocoonjslogo")), wxDefaultPosition, wxSize(-1,-1), 0 ); + flexGridSizer353->Add(flexGridSizer364, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - flexGridSizer633->Add(m_staticBitmap574, 0, wxALL, 0); + ID_STATICTEXT45 = new wxStaticText(m_panel611, wxID_ANY, _("Export folder:"), wxDefaultPosition, wxSize(-1,-1), 0); - m_staticText655 = new wxStaticText(m_panel71, wxID_ANY, _("CocoonJS is a technology that helps HTML5 developers\npublish their web-based games and apps in the most\nimportant mobile and web stores."), wxDefaultPosition, wxSize(-1,-1), wxALIGN_CENTRE); + flexGridSizer364->Add(ID_STATICTEXT45, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); - flexGridSizer551->Add(m_staticText655, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_TOP, 10); + wxFlexGridSizer* flexGridSizer386 = new wxFlexGridSizer(0, 3, 0, 0); + flexGridSizer386->SetFlexibleDirection( wxBOTH ); + flexGridSizer386->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer386->AddGrowableCol(0); + flexGridSizer386->AddGrowableRow(0); - wxStaticBoxSizer* staticBoxSizer112 = new wxStaticBoxSizer( new wxStaticBox(m_panel71, wxID_ANY, _("Note")), wxVERTICAL); + flexGridSizer364->Add(flexGridSizer386, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - flexGridSizer551->Add(staticBoxSizer112, 1, wxALL|wxEXPAND, 5); + cocosExportFolderEdit = new wxTextCtrl(m_panel611, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + #if wxVERSION_NUMBER >= 3000 + cocosExportFolderEdit->SetHint(wxT("")); + #endif - wxFlexGridSizer* flexGridSizer114 = new wxFlexGridSizer(0, 2, 0, 0); - flexGridSizer114->SetFlexibleDirection( wxBOTH ); - flexGridSizer114->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - flexGridSizer114->AddGrowableCol(0); + flexGridSizer386->Add(cocosExportFolderEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); - staticBoxSizer112->Add(flexGridSizer114, 1, wxALL|wxEXPAND, 0); + cocosExportBrowseBt = new wxButton(m_panel611, wxID_ANY, _("..."), wxDefaultPosition, wxSize(30,-1), 0); - m_staticText676 = new wxStaticText(m_panel71, wxID_ANY, _("Just click on the \"Export\" button and GDevelop will\npackage your game in a single zip file.\nYou'll then be able to upload this file on the cloud compiler\nat cloud.ludei.com, which will allows you to compile\nthe game into an iOS/Android app."), wxDefaultPosition, wxSize(-1,-1), wxALIGN_LEFT); + flexGridSizer386->Add(cocosExportBrowseBt, 1, wxRIGHT|wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); - flexGridSizer114->Add(m_staticText676, 0, wxALL|wxEXPAND|wxALIGN_CENTER|wxALIGN_LEFT, 5); + ID_STATICTEXT213 = new wxStaticText(m_panel611, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + flexGridSizer342->Add(ID_STATICTEXT213, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); + + ID_STATICTEXT114 = new wxStaticText(m_panel611, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), 0); + + flexGridSizer342->Add(ID_STATICTEXT114, 1, wxLEFT|wxRIGHT|wxBOTTOM|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); + + wxStaticBoxSizer* staticBoxSizer4515 = new wxStaticBoxSizer( new wxStaticBox(m_panel611, wxID_ANY, _("Note")), wxVERTICAL); + + flexGridSizer342->Add(staticBoxSizer4515, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + wxFlexGridSizer* flexGridSizer4616 = new wxFlexGridSizer(0, 1, 0, 0); + flexGridSizer4616->SetFlexibleDirection( wxBOTH ); + flexGridSizer4616->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + flexGridSizer4616->AddGrowableCol(0); + + staticBoxSizer4515->Add(flexGridSizer4616, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + + ID_STATICTEXT31719 = new wxStaticText(m_panel611, wxID_ANY, _("When the exportation is done, send the files to your website (you need a web hosting) and just go to the website to start the game."), wxDefaultPosition, wxSize(-1,-1), 0); + ID_STATICTEXT31719->Wrap(450); + + flexGridSizer4616->Add(ID_STATICTEXT31719, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + + ID_STATICTEXT317 = new wxStaticText(m_panel611, wxID_ANY, _("If you install Cocos2d-x, you can also use it to export the game to Android, iOS, Windows, Mac or Linux."), wxDefaultPosition, wxSize(-1,-1), 0); + ID_STATICTEXT317->Wrap(450); + + flexGridSizer4616->Add(ID_STATICTEXT317, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); + + ID_HYPERLINKCTRL218 = new wxHyperlinkCtrl(m_panel611, wxID_ANY, _("Click here to learn more about Cocos2d export"), wxT("http://wiki.compilgames.net/doku.php/en/game_develop/tutorials/howtoexportwithcocos2dx"), wxDefaultPosition, wxSize(-1,-1), wxHL_DEFAULT_STYLE); + ID_HYPERLINKCTRL218->SetNormalColour(wxColour(wxT("#0000FF"))); + ID_HYPERLINKCTRL218->SetHoverColour(wxColour(wxT("#0000FF"))); + ID_HYPERLINKCTRL218->SetVisitedColour(wxColour(wxT("#FF0000"))); + + flexGridSizer4616->Add(ID_HYPERLINKCTRL218, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); wxFlexGridSizer* flexGridSizer50 = new wxFlexGridSizer(0, 3, 0, 0); flexGridSizer50->SetFlexibleDirection( wxBOTH ); @@ -281,6 +321,7 @@ BaseProjectExportDialog::BaseProjectExportDialog(wxWindow* parent, wxWindowID id #endif // Connect events browseBt->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnBrowseBtClick), NULL, this); + cocosExportBrowseBt->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnCocosExportBrowseBtClick), NULL, this); closeBt->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnCloseBtClicked), NULL, this); exportBt->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnExportBtClicked), NULL, this); @@ -289,6 +330,7 @@ BaseProjectExportDialog::BaseProjectExportDialog(wxWindow* parent, wxWindowID id BaseProjectExportDialog::~BaseProjectExportDialog() { browseBt->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnBrowseBtClick), NULL, this); + cocosExportBrowseBt->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnCocosExportBrowseBtClick), NULL, this); closeBt->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnCloseBtClicked), NULL, this); exportBt->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BaseProjectExportDialog::OnExportBtClicked), NULL, this); diff --git a/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.h b/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.h index 25d9796133..a023767b3a 100644 --- a/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.h +++ b/GDJS/GDJS/IDE/Dialogs/GDJSDialogs.h @@ -53,11 +53,15 @@ protected: wxStaticBitmap* m_staticBitmap5744; wxStaticText* m_staticText6555; wxStaticText* m_staticText6768; - wxPanel* m_panel71; - wxPanel* cocoonjslogoPanel2; - wxStaticBitmap* m_staticBitmap574; - wxStaticText* m_staticText655; - wxStaticText* m_staticText676; + wxPanel* m_panel611; + wxStaticText* ID_STATICTEXT45; + wxTextCtrl* cocosExportFolderEdit; + wxButton* cocosExportBrowseBt; + wxStaticText* ID_STATICTEXT213; + wxStaticText* ID_STATICTEXT114; + wxStaticText* ID_STATICTEXT31719; + wxStaticText* ID_STATICTEXT317; + wxHyperlinkCtrl* ID_HYPERLINKCTRL218; wxStaticBitmap* ID_STATICBITMAP2; wxHyperlinkCtrl* ID_HYPERLINKCTRL1; wxButton* closeBt; @@ -65,6 +69,7 @@ protected: protected: virtual void OnBrowseBtClick(wxCommandEvent& event) { event.Skip(); } + virtual void OnCocosExportBrowseBtClick(wxCommandEvent& event) { event.Skip(); } virtual void OnCloseBtClicked(wxCommandEvent& event) { event.Skip(); } virtual void OnExportBtClicked(wxCommandEvent& event) { event.Skip(); } @@ -85,11 +90,15 @@ public: wxStaticText* GetStaticText6555() { return m_staticText6555; } wxStaticText* GetStaticText6768() { return m_staticText6768; } wxPanel* GetPanel118() { return m_panel118; } - wxStaticBitmap* GetStaticBitmap574() { return m_staticBitmap574; } - wxPanel* GetCocoonjslogoPanel2() { return cocoonjslogoPanel2; } - wxStaticText* GetStaticText655() { return m_staticText655; } - wxStaticText* GetStaticText676() { return m_staticText676; } - wxPanel* GetPanel71() { return m_panel71; } + wxStaticText* GetID_STATICTEXT45() { return ID_STATICTEXT45; } + wxTextCtrl* GetCocosExportFolderEdit() { return cocosExportFolderEdit; } + wxButton* GetCocosExportBrowseBt() { return cocosExportBrowseBt; } + wxStaticText* GetID_STATICTEXT213() { return ID_STATICTEXT213; } + wxStaticText* GetID_STATICTEXT114() { return ID_STATICTEXT114; } + wxStaticText* GetID_STATICTEXT31719() { return ID_STATICTEXT31719; } + wxStaticText* GetID_STATICTEXT317() { return ID_STATICTEXT317; } + wxHyperlinkCtrl* GetID_HYPERLINKCTRL218() { return ID_HYPERLINKCTRL218; } + wxPanel* GetPanel611() { return m_panel611; } wxChoicebook* GetExportChoice() { return exportChoice; } wxStaticBitmap* GetID_STATICBITMAP2() { return ID_STATICBITMAP2; } wxHyperlinkCtrl* GetID_HYPERLINKCTRL1() { return ID_HYPERLINKCTRL1; } diff --git a/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.cpp b/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.cpp index 35e810d5b9..4807aad7d7 100644 --- a/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.cpp +++ b/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.cpp @@ -13,7 +13,7 @@ #include "GDCore/Tools/HelpFileAccess.h" #include "GDCore/Project/Project.h" #include "GDCore/CommonTools.h" -#include "GDJS/IDE/Exporter.h" +#include "GDJS/IDE/ExporterHelper.h" #include "GDCore/IDE/wxTools/SkinHelper.h" namespace gdjs @@ -23,15 +23,17 @@ ProjectExportDialog::ProjectExportDialog(wxWindow* parent, gd::Project & project BaseProjectExportDialog(parent), project(project_) { - //TODO: Remove when CocoonJS support is fully working. - exportChoice->RemovePage(2); - exportFolderEdit->AutoCompleteDirectories(); + cocosExportFolderEdit->AutoCompleteDirectories(); if ( wxDirExists(project.GetLastCompilationDirectory()) ) + { exportFolderEdit->SetValue(project.GetLastCompilationDirectory()); + cocosExportFolderEdit->SetValue(project.GetLastCompilationDirectory()); + } else { exportFolderEdit->SetValue(wxFileName::GetHomeDir()+wxFileName::GetPathSeparator()+DeleteInvalidCharacters(project.GetName())); + cocosExportFolderEdit->SetValue(wxFileName::GetHomeDir()+wxFileName::GetPathSeparator()+DeleteInvalidCharacters(project.GetName())); } //Open the latest used export type. @@ -39,7 +41,7 @@ ProjectExportDialog::ProjectExportDialog(wxWindow* parent, gd::Project & project wxConfigBase::Get()->Read("Export/JS platform/LatestExportType", &latestPage, 0); exportChoice->SetSelection(latestPage); - hasNode = !Exporter::GetNodeExecutablePath().empty(); + hasNode = !ExporterHelper::GetNodeExecutablePath().empty(); nodejsLink->Show(!hasNode); if ( !hasNode ) { @@ -57,11 +59,11 @@ ProjectExportDialog::ExportType ProjectExportDialog::GetExportType() switch(exportChoice->GetSelection()) { case 1: - return Cordova; + return PixiCordova; case 2: - return CocoonJS; + return Cocos2d; default: - return Normal; + return Pixi; } } @@ -107,18 +109,27 @@ void ProjectExportDialog::OnBrowseBtClick(wxCommandEvent& event) exportFolderEdit->SetValue(dialog.GetPath()); } +void ProjectExportDialog::OnCocosExportBrowseBtClick(wxCommandEvent& event) +{ + wxDirDialog dialog(this, _("Choose a folder, empty if possible, where the game should be exported.")); + if ( dialog.ShowModal() == wxID_OK ) + cocosExportFolderEdit->SetValue(dialog.GetPath()); +} + gd::String ProjectExportDialog::GetExportDir() { - if ( GetExportType() == Normal ) - return gd::String(exportFolderEdit->GetValue()); - else + if ( GetExportType() == PixiCordova ) return gd::String(wxFileName::GetHomeDir())+wxString(wxFileName::GetPathSeparator())+gd::String(DeleteInvalidCharacters(project.GetName())); + if ( GetExportType() == Cocos2d ) + return gd::String(cocosExportFolderEdit->GetValue()); + else + return gd::String(exportFolderEdit->GetValue()); } bool ProjectExportDialog::RequestMinify() { if (!hasNode) return false; - return GetExportType() != Normal || minifyCheck->GetValue(); + return GetExportType() == PixiCordova || minifyCheck->GetValue(); } } diff --git a/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.h b/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.h index ae0d7eb4c6..c7f1bbc877 100644 --- a/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.h +++ b/GDJS/GDJS/IDE/Dialogs/ProjectExportDialog.h @@ -28,9 +28,9 @@ public: enum ExportType { - Normal, - Cordova, - CocoonJS + Pixi, + PixiCordova, + Cocos2d }; /** @@ -49,6 +49,7 @@ public: bool RequestMinify(); protected: + virtual void OnCocosExportBrowseBtClick(wxCommandEvent& event); virtual void OnBrowseBtClick(wxCommandEvent& event); virtual void OnCloseBtClicked(wxCommandEvent& event); virtual void OnExportBtClicked(wxCommandEvent& event); diff --git a/GDJS/GDJS/IDE/Exporter.cpp b/GDJS/GDJS/IDE/Exporter.cpp index 4f01484d44..92dddaff0a 100644 --- a/GDJS/GDJS/IDE/Exporter.cpp +++ b/GDJS/GDJS/IDE/Exporter.cpp @@ -32,6 +32,7 @@ #include "GDCore/IDE/ProjectStripper.h" #include "GDCore/CommonTools.h" #include "GDJS/IDE/Exporter.h" +#include "GDJS/IDE/ExporterHelper.h" #include "GDJS/Events/CodeGeneration/EventsCodeGenerator.h" #include "GDJS/IDE/Dialogs/ProjectExportDialog.h" #include "GDJS/IDE/Dialogs/CocoonJSUploadDialog.h" @@ -41,418 +42,73 @@ namespace gdjs { -//Nice tools functions -static void InsertUnique(std::vector & container, gd::String str) -{ - if ( std::find(container.begin(), container.end(), str) == container.end() ) - container.push_back(str); -} - -static void GenerateFontsDeclaration(gd::AbstractFileSystem & fs, const gd::String & outputDir, gd::String & css, gd::String & html) -{ - std::vector ttfFiles = fs.ReadDir(outputDir, ".TTF"); - for(std::size_t i = 0; i."; - } -} - Exporter::~Exporter() { } -bool Exporter::ExportLayoutForPreview(gd::Project & project, gd::Layout & layout, gd::String exportDir) +bool Exporter::ExportLayoutForPixiPreview(gd::Project & project, gd::Layout & layout, gd::String exportDir) { - return ExportLayoutForPreview(project, layout, exportDir, ""); + ExporterHelper helper(fs); + return helper.ExportLayoutForPixiPreview(project, layout, exportDir, ""); } -bool Exporter::ExportExternalLayoutForPreview(gd::Project & project, gd::Layout & layout, +bool Exporter::ExportExternalLayoutForPixiPreview(gd::Project & project, gd::Layout & layout, gd::ExternalLayout & externalLayout, gd::String exportDir) { gd::SerializerElement options; options.AddChild("injectExternalLayout").SetValue(externalLayout.GetName()); - return ExportLayoutForPreview(project, layout, exportDir, + ExporterHelper helper(fs); + return helper.ExportLayoutForPixiPreview(project, layout, exportDir, gd::Serializer::ToJSON(options) ); } -bool Exporter::ExportLayoutForPreview(gd::Project & project, gd::Layout & layout, gd::String exportDir, gd::String additionalSpec) -{ - fs.MkDir(exportDir); - fs.ClearDir(exportDir); - fs.MkDir(exportDir+"/libs"); - fs.MkDir(exportDir+"/Extensions"); - std::vector includesFiles; - - gd::Project exportedProject = project; - - //Export resources (*before* generating events as some resources filenames may be updated) - ExportResources(fs, exportedProject, exportDir); - //Generate events code - if ( !ExportEventsCode(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) - return false; - - //Export source files - if ( !ExportExternalSourceFiles(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) - { - gd::LogError(_("Error during exporting! Unable to export source files:\n")+lastError); - return false; - } - - //Strip the project (*after* generating events as the events may use stripped things (objects groups...)) - gd::ProjectStripper::StripProject(exportedProject); - exportedProject.SetFirstLayout(layout.GetName()); - - //Export the project - ExportToJSON(fs, exportedProject, fs.GetTempDir() + "/GDTemporaries/JSCodeTemp/data.js", - "gdjs.projectData"); - includesFiles.push_back(fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/data.js"); - - //Copy all the dependencies - ExportIncludesAndLibs(includesFiles, exportDir, false); - - //Create the index file - if (!ExportIndexFile("./JsPlatform/Runtime/index.html", exportDir, includesFiles, additionalSpec)) - return false; - - return true; -} - -gd::String Exporter::ExportToJSON(gd::AbstractFileSystem &fs, const gd::Project &project, gd::String filename, - gd::String wrapIntoVariable) -{ - fs.MkDir(fs.DirNameFrom(filename)); - - //Save the project to JSON - gd::SerializerElement rootElement; - project.SerializeTo(rootElement); - - gd::String output = gd::Serializer::ToJSON(rootElement); - if (!wrapIntoVariable.empty()) output = wrapIntoVariable + " = " + output + ";"; - - if (!fs.WriteToFile(filename, output)) - return "Unable to write "+filename; - - return ""; -} - -bool Exporter::ExportIndexFile(gd::String source, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec) -{ - gd::String str = fs.ReadFile(source); - - //Generate custom declarations for font resources - gd::String customCss; - gd::String customHtml; - GenerateFontsDeclaration(fs, exportDir, customCss, customHtml); - - //Generate the file - if (!CompleteIndexFile(str, customCss, customHtml, exportDir, includesFiles, additionalSpec)) - return false; - - //Write the index.html file - if (!fs.WriteToFile(exportDir + "/index.html", str)) - { - lastError = "Unable to write index file."; - return false; - } - - return true; -} - -bool Exporter::ExportCordovaConfigFile(const gd::Project & project, gd::String exportDir) -{ - gd::String str = fs.ReadFile("./JsPlatform/Runtime/Cordova/config.xml") - .FindAndReplace("GDJS_PROJECTNAME", project.GetName()) - .FindAndReplace("GDJS_PACKAGENAME", project.GetPackageName()) - .FindAndReplace("GDJS_ORIENTATION", "default"); - - if (!fs.WriteToFile(exportDir + "/config.xml", str)) - { - lastError = "Unable to write configuration file."; - return false; - } - - return true; -} - -bool Exporter::CompleteIndexFile(gd::String & str, gd::String customCss, gd::String customHtml, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec) -{ - if (additionalSpec.empty()) additionalSpec = "{}"; - - gd::String codeFilesIncludes; - for (std::vector::const_iterator it = includesFiles.begin(); it != includesFiles.end(); ++it) - { - if ( !fs.FileExists(exportDir + "/" + *it) ) - { - std::cout << "Warning: Unable to found " << exportDir+"/"+*it << "." << std::endl; - continue; - } - - gd::String relativeFile = exportDir+"/"+*it; - fs.MakeRelative(relativeFile, exportDir); - codeFilesIncludes += "\t\n"; - } - - str = str.FindAndReplace("/* GDJS_CUSTOM_STYLE */", customCss) - .FindAndReplace("", customHtml) - .FindAndReplace("", codeFilesIncludes) - .FindAndReplace("{}/*GDJS_ADDITIONAL_SPEC*/", additionalSpec); - - return true; -} - -bool Exporter::ExportEventsCode(gd::Project & project, gd::String outputDir, std::vector & includesFiles) -{ - fs.MkDir(outputDir); - - //First, do not forget common includes (they must be included before events generated code files). - InsertUnique(includesFiles, "libs/jshashtable.js"); - InsertUnique(includesFiles, "gd.js"); - InsertUnique(includesFiles, "libs/hshg.js"); - InsertUnique(includesFiles, "pixi-renderers/pixi.js"); - InsertUnique(includesFiles, "pixi-renderers/runtimegame-pixi-renderer.js"); - InsertUnique(includesFiles, "pixi-renderers/runtimescene-pixi-renderer.js"); - InsertUnique(includesFiles, "pixi-renderers/layer-pixi-renderer.js"); - InsertUnique(includesFiles, "pixi-renderers/pixi-image-manager.js"); - InsertUnique(includesFiles, "pixi-renderers/spriteruntimeobject-pixi-renderer.js"); - InsertUnique(includesFiles, "pixi-renderers/loadingscreen-pixi-renderer.js"); - InsertUnique(includesFiles, "howler-sound-manager/howler.min.js"); - InsertUnique(includesFiles, "howler-sound-manager/howler-sound-manager.js"); - InsertUnique(includesFiles, "inputmanager.js"); - InsertUnique(includesFiles, "timemanager.js"); - InsertUnique(includesFiles, "runtimeobject.js"); - InsertUnique(includesFiles, "profiler.js"); - InsertUnique(includesFiles, "runtimescene.js"); - InsertUnique(includesFiles, "scenestack.js"); - InsertUnique(includesFiles, "polygon.js"); - InsertUnique(includesFiles, "force.js"); - InsertUnique(includesFiles, "layer.js"); - InsertUnique(includesFiles, "timer.js"); - InsertUnique(includesFiles, "runtimegame.js"); - InsertUnique(includesFiles, "variable.js"); - InsertUnique(includesFiles, "variablescontainer.js"); - InsertUnique(includesFiles, "eventscontext.js"); - InsertUnique(includesFiles, "runtimebehavior.js"); - InsertUnique(includesFiles, "spriteruntimeobject.js"); - - //Common includes for events only. - InsertUnique(includesFiles, "events-tools/commontools.js"); - InsertUnique(includesFiles, "events-tools/runtimescenetools.js"); - InsertUnique(includesFiles, "events-tools/inputtools.js"); - InsertUnique(includesFiles, "events-tools/objecttools.js"); - InsertUnique(includesFiles, "events-tools/cameratools.js"); - InsertUnique(includesFiles, "events-tools/soundtools.js"); - InsertUnique(includesFiles, "events-tools/storagetools.js"); - InsertUnique(includesFiles, "events-tools/stringtools.js"); - InsertUnique(includesFiles, "events-tools/windowtools.js"); - InsertUnique(includesFiles, "events-tools/networktools.js"); - - for (std::size_t i = 0;i eventsIncludes; - gd::Layout & exportedLayout = project.GetLayout(i); - gd::String eventsOutput = EventsCodeGenerator::GenerateSceneEventsCompleteCode(project, exportedLayout, - exportedLayout.GetEvents(), eventsIncludes, false /*Export for edittime*/); - gd::String filename = outputDir+"code"+gd::String::From(i)+".js"; - - //Export the code - if (fs.WriteToFile(filename, eventsOutput)) - { - for ( std::set::iterator include = eventsIncludes.begin() ; include != eventsIncludes.end(); ++include ) - InsertUnique(includesFiles, *include); - - InsertUnique(includesFiles, filename); - } - else { - lastError = _("Unable to write ") + filename; - return false; - } - } - - return true; -} - -bool Exporter::ExportExternalSourceFiles(gd::Project & project, gd::String outputDir, std::vector & includesFiles) -{ - const std::vector < std::shared_ptr > & allFiles = project.GetAllSourceFiles(); - for (std::size_t i = 0;i() ) continue; - if (allFiles[i]->GetLanguage() != "Javascript" ) continue; - - gd::SourceFile & file = *allFiles[i]; - - gd::String filename = file.GetFileName(); - fs.MakeAbsolute(filename, fs.DirNameFrom(project.GetProjectFile())); - gd::String outFilename = "ext-code"+gd::String::From(i)+".js"; - if (!fs.CopyFile(filename, outputDir+outFilename)) - gd::LogWarning(_("Could not copy external file") + filename); - - InsertUnique(includesFiles, outputDir+outFilename); - } - - return true; -} - -bool Exporter::ExportIncludesAndLibs(std::vector & includesFiles, gd::String exportDir, bool minify) -{ - #if !defined(GD_NO_WX_GUI) - //Includes files : - if ( minify ) - { - gd::String nodeExec = GetNodeExecutablePath(); - if ( nodeExec.empty() || !fs.FileExists(nodeExec) ) - { - std::cout << "Node.js executable not found." << std::endl; - gd::LogWarning(_("The exported script could not be minified: Please check that you installed Node.js on your system.")); - minify = false; - } - else - { - gd::String jsPlatformDir = wxGetCwd()+"/JsPlatform/"; - gd::String cmd = nodeExec+" \""+jsPlatformDir+"Tools/uglify-js/bin/uglifyjs\" "; - - gd::String allJsFiles; - for ( std::vector::iterator include = includesFiles.begin() ; include != includesFiles.end(); ++include ) - { - if ( fs.FileExists(jsPlatformDir+"Runtime/"+*include) ) - allJsFiles += "\""+jsPlatformDir+"Runtime/"+*include+"\" "; - else if ( fs.FileExists(jsPlatformDir+"Runtime/Extensions/"+*include) ) - allJsFiles += "\""+jsPlatformDir+"Runtime/Extensions/"+*include+"\" "; - else if ( fs.FileExists(*include) ) - allJsFiles += "\""+*include+"\" "; - } - - cmd += allJsFiles; - cmd += "-o \""+exportDir+"/code.js\""; - - wxArrayString output; - wxArrayString errors; - long res = wxExecute(cmd, output, errors); - if ( res != 0 ) - { - std::cout << "Execution of \"UglifyJS\" failed (Command line : " << cmd << ")." << std::endl; - std::cout << "Output: "; - for (size_t i = 0;i::iterator include = includesFiles.begin() ; include != includesFiles.end(); ++include ) - { - if ( fs.FileExists("./JsPlatform/Runtime/"+*include) ) - { - gd::String path = fs.DirNameFrom(exportDir+"/"+*include); - if ( !fs.DirExists(path) ) fs.MkDir(path); - - fs.CopyFile("./JsPlatform/Runtime/"+*include, exportDir+"/"+*include); - //Ok, the filename is relative to the export dir. - } - else if ( fs.FileExists("./JsPlatform/Runtime/Extensions/"+*include) ) - { - gd::String path = fs.DirNameFrom(exportDir+"/Extensions/"+*include); - if ( !fs.DirExists(path) ) fs.MkDir(path); - - fs.CopyFile("./JsPlatform/Runtime/Extensions/"+*include, exportDir+"/Extensions/"+*include); - *include = "Extensions/"+*include; //Ensure filename is relative to the export dir. - } - else if ( fs.FileExists(*include) ) - { - fs.CopyFile(*include, exportDir+"/"+fs.FileNameFrom(*include)); - *include = fs.FileNameFrom(*include); //Ensure filename is relative to the export dir. - } - else - { - std::cout << "Could not copy include file " << *include << " (File not found)." << std::endl; - } - } - } - - return true; -} - -void Exporter::ExportResources(gd::AbstractFileSystem & fs, gd::Project & project, gd::String exportDir, wxProgressDialog * progressDialog) -{ - gd::ProjectResourcesCopier::CopyAllResourcesTo(project, fs, exportDir, true, progressDialog, false, false); -} - void Exporter::ShowProjectExportDialog(gd::Project & project) { #if !defined(GD_NO_WX_GUI) ProjectExportDialog dialog(NULL, project); if ( dialog.ShowModal() != 1 ) return; - bool exportForCocoonJS = dialog.GetExportType() == ProjectExportDialog::CocoonJS; - bool exportForCordova = dialog.GetExportType() == ProjectExportDialog::Cordova; + if (dialog.GetExportType() == ProjectExportDialog::Cocos2d) + { + ExportWholeCocos2dProject(project, dialog.GetExportDir()); + } + else + { + bool exportForCordova = dialog.GetExportType() == ProjectExportDialog::PixiCordova; + ExportWholePixiProject(project, dialog.GetExportDir(), dialog.RequestMinify(), + exportForCordova); + } - ExportWholeProject(project, dialog.GetExportDir(), dialog.RequestMinify(), - exportForCocoonJS, exportForCordova); #else gd::LogError("BAD USE: Exporter::ShowProjectExportDialog is not available."); #endif } -bool Exporter::ExportWholeProject(gd::Project & project, gd::String exportDir, - bool minify, bool exportForCocoonJS, bool exportForCordova) +bool Exporter::ExportWholePixiProject(gd::Project & project, gd::String exportDir, + bool minify, bool exportForCordova) { + ExporterHelper helper(fs); + auto exportProject = [this, &project, &minify, - &exportForCocoonJS, &exportForCordova](gd::String exportDir) + &exportForCordova, &helper](gd::String exportDir) { + wxProgressDialog * progressDialogPtr = NULL; #if !defined(GD_NO_WX_GUI) wxProgressDialog progressDialog(_("Export in progress ( 1/2 )"), _("Exporting the project...")); + progressDialogPtr = &progressDialog; #endif //Prepare the export directory fs.MkDir(exportDir); fs.ClearDir(exportDir); - fs.MkDir(exportDir+"/libs"); - fs.MkDir(exportDir+"/pixi-renderers"); - fs.MkDir(exportDir+"/Extensions"); std::vector includesFiles; - if (exportForCocoonJS) - { - fs.MkDir(exportDir+"/libs/CocoonJS"); - includesFiles.push_back("libs/CocoonJS/cocoon.min.js"); - } - gd::Project exportedProject = project; //Export the resources (before generating events as some resources filenames may be updated) - #if !defined(GD_NO_WX_GUI) - ExportResources(fs, exportedProject, exportDir, &progressDialog); - #else - ExportResources(fs, exportedProject, exportDir, NULL); - #endif + helper.ExportResources(fs, exportedProject, exportDir, progressDialogPtr); #if !defined(GD_NO_WX_GUI) progressDialog.SetTitle(_("Export in progress ( 2/2 )")); @@ -460,32 +116,25 @@ bool Exporter::ExportWholeProject(gd::Project & project, gd::String exportDir, #endif //Export events - if ( !ExportEventsCode(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) + if ( !helper.ExportEventsCode(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) { gd::LogError(_("Error during exporting! Unable to export events:\n")+lastError); return false; } + helper.AddLibsInclude(true, false, includesFiles); //Export source files - if ( !ExportExternalSourceFiles(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) + if ( !helper.ExportExternalSourceFiles(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) { gd::LogError(_("Error during exporting! Unable to export source files:\n")+lastError); return false; } - #if !defined(GD_NO_WX_GUI) - progressDialog.Update(60, _("Preparing the project...")); - #endif - //Strip the project (*after* generating events as the events may use stripped things like objects groups...)... gd::ProjectStripper::StripProject(exportedProject); - #if !defined(GD_NO_WX_GUI) - progressDialog.Update(70, _("Exporting files...")); - #endif - //...and export it - ExportToJSON(fs, exportedProject, fs.GetTempDir() + "/GDTemporaries/JSCodeTemp/data.js", + helper.ExportToJSON(fs, exportedProject, fs.GetTempDir() + "/GDTemporaries/JSCodeTemp/data.js", "gdjs.projectData"); includesFiles.push_back(fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/data.js"); @@ -494,59 +143,19 @@ bool Exporter::ExportWholeProject(gd::Project & project, gd::String exportDir, #endif //Copy all dependencies and the index (or metadata) file. - gd::String additionalSpec = exportForCocoonJS ? "{forceFullscreen:true}" : ""; - ExportIncludesAndLibs(includesFiles, exportDir, minify); + helper.RemoveIncludes(false, true, includesFiles); + helper.ExportIncludesAndLibs(includesFiles, exportDir, minify); gd::String source = exportForCordova ? "./JsPlatform/Runtime/Cordova/www/index.html" : "./JsPlatform/Runtime/index.html"; - if (!ExportIndexFile(source, exportDir, includesFiles, additionalSpec)) + if (!helper.ExportPixiIndexFile(source, exportDir, includesFiles, "")) { gd::LogError(_("Error during export:\n") + lastError); return false; } - //Exporting for online upload requires to zip the whole game. - if (exportForCocoonJS) - { - #if !defined(GD_NO_WX_GUI) - progressDialog.Update(90, _("Creating the zip file...")); - - //Getting all the files to includes in the directory - wxArrayString files; - wxDir::GetAllFiles(exportDir, &files); - - wxString zipTempName = fs.GetTempDir()+"/GDTemporaries/zipped_"+gd::String::From(&project)+".zip"; - wxFFileOutputStream out(zipTempName); - wxZipOutputStream zip(out); - for(std::size_t i = 0; i < files.size(); ++i) - { - wxFileName filename(files[i]); - filename.MakeRelativeTo(exportDir); - wxFileInputStream file(files[i]); - if ( file.IsOk() ) - { - zip.PutNextEntry(filename.GetFullPath()); - zip.Write(file); - } - } - - if ( !zip.Close() || !out.Close() ) - gd::LogWarning(_("Unable to finalize the creation of the zip file!\n\nThe exported project won't be put in a zip file.")); - else - { - progressDialog.Update(95, _("Cleaning files...")); - - fs.ClearDir(exportDir); - fs.CopyFile(zipTempName, exportDir+"/packaged_game.zip"); - wxRemoveFile(zipTempName); - } - #else - gd::LogError("BAD USE: Trying to export to a zip file, but this feature is not available when wxWidgets support is disabled."); - #endif - } - return true; }; @@ -554,7 +163,7 @@ bool Exporter::ExportWholeProject(gd::Project & project, gd::String exportDir, { //Prepare the export directory fs.MkDir(exportDir); - if (!ExportCordovaConfigFile(project, exportDir)) + if (!helper.ExportCordovaConfigFile(project, exportDir)) return false; if (!exportProject(exportDir + "/www")) @@ -566,12 +175,7 @@ bool Exporter::ExportWholeProject(gd::Project & project, gd::String exportDir, //Finished! #if !defined(GD_NO_WX_GUI) - if ( exportForCocoonJS ) - { - CocoonJSUploadDialog uploadDialog(NULL, exportDir+wxString(wxFileName::GetPathSeparator())+"packaged_game.zip"); - uploadDialog.ShowModal(); - } - else if ( exportForCordova ) + if ( exportForCordova ) { CordovaPackageDialog packageDialog(NULL, exportDir); packageDialog.ShowModal(); @@ -589,44 +193,86 @@ bool Exporter::ExportWholeProject(gd::Project & project, gd::String exportDir, return true; } +bool Exporter::ExportWholeCocos2dProject(gd::Project & project, gd::String exportDir) +{ + ExporterHelper helper(fs); + + wxProgressDialog * progressDialogPtr = NULL; + #if !defined(GD_NO_WX_GUI) + wxProgressDialog progressDialog(_("Export in progress ( 1/2 )"), _("Exporting the project...")); + progressDialogPtr = &progressDialog; + #endif + + //Prepare the export directory + fs.MkDir(exportDir); + fs.ClearDir(exportDir); + std::vector includesFiles; + + gd::Project exportedProject = project; + + //Export the resources (before generating events as some resources filenames may be updated) + helper.ExportResources(fs, exportedProject, exportDir + "/res", progressDialogPtr); + + #if !defined(GD_NO_WX_GUI) + progressDialog.SetTitle(_("Export in progress ( 2/2 )")); + progressDialog.Update(50, _("Exporting events...")); + #endif + + //Export events + if ( !helper.ExportEventsCode(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) + { + gd::LogError(_("Error during exporting! Unable to export events:\n")+lastError); + return false; + } + helper.AddLibsInclude(false, true, includesFiles); + + //Export source files + if ( !helper.ExportExternalSourceFiles(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) + { + gd::LogError(_("Error during exporting! Unable to export source files:\n")+lastError); + return false; + } + + //Strip the project (*after* generating events as the events may use stripped things like objects groups...)... + gd::ProjectStripper::StripProject(exportedProject); + + //...and export it + helper.ExportToJSON(fs, exportedProject, fs.GetTempDir() + "/GDTemporaries/JSCodeTemp/data.js", + "gdjs.projectData"); + includesFiles.push_back(fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/data.js"); + + #if !defined(GD_NO_WX_GUI) + progressDialog.Update(80, _("Exporting files...")); + #endif + + //Copy all dependencies and the index (or metadata) file. + helper.RemoveIncludes(true, false, includesFiles); + helper.ExportIncludesAndLibs(includesFiles, exportDir + "/src", false); + + gd::String source = "./JsPlatform/Runtime/index.html"; + + if (!helper.ExportCocos2dFiles(project, exportDir, includesFiles)) + { + gd::LogError(_("Error during export:\n") + lastError); + return false; + } + + //Finished! + #if !defined(GD_NO_WX_GUI) + //TODO: Factor/update message? + if ( wxMessageBox(_("Compilation achieved. Do you want to open the folder where the project has been compiled\?"), + _("Compilation finished"), wxYES_NO) == wxYES ) + { + gd::ShowFolder(exportDir); + } + #endif + + return true; +} + gd::String Exporter::GetProjectExportButtonLabel() { return _("Export to the web"); } -#if !defined(GD_NO_WX_GUI) -gd::String Exporter::GetNodeExecutablePath() -{ - std::vector guessPaths; - wxString userPath; - if ( wxConfigBase::Get()->Read("Paths/Node" , &userPath) && !userPath.empty() ) - guessPaths.push_back(userPath); - else - { - //Try some common paths. - #if defined(WINDOWS) - guessPaths.push_back("C:/Program Files/nodejs/node.exe"); - guessPaths.push_back("C:/Program Files (x86)/nodejs/node.exe"); - #elif defined(LINUX) || defined(MACOS) - guessPaths.push_back("/usr/bin/env/nodejs"); - guessPaths.push_back("/usr/bin/nodejs"); - guessPaths.push_back("/usr/local/bin/nodejs"); - guessPaths.push_back("/usr/bin/env/node"); - guessPaths.push_back("/usr/bin/node"); - guessPaths.push_back("/usr/local/bin/node"); - #else - #warning Please complete this so as to return a path to the Node executable. - #endif - } - - for (size_t i = 0;i & includesFiles, gd::String exportDir, bool minify); - - /** - * \brief Generate the events JS code, and save them to the export directory. - * - * Files are named "codeX.js", X being the number of the layout in the project. - * \param project The project with resources to be exported. - * \param outputDir The directory where the events code must be generated. - * \param includesFiles A reference to a vector that will be filled with JS files to be exported along with the project. - * ( including "codeX.js" files ). - */ - bool ExportEventsCode(gd::Project & project, gd::String outputDir, std::vector & includesFiles); - - /** - * \brief Copy the external source files used by the game into the export directory, and add them into files - * to be included. - * - * Files are named "ext-codeX.js", X being the index of the external source file in the project. - * \param project The project with resources to be exported. - * \param outputDir The directory where the events code must be generated. - * \param includesFiles A reference to a vector that will be filled with JS files to be exported along with the project. - * (including "ext-codeX.js" files). - */ - bool ExportExternalSourceFiles(gd::Project & project, gd::String outputDir, std::vector & includesFiles); - - /** - * \brief Generate the standard index file and save it to the export directory. - * - * The includes files must be relative to the export directory. - * - * \param project The project with layouts to be exported. - * \param source The file to be used as a template for the final file. - * \param exportDir The directory where the preview must be created. - * \param includesFiles The JS files to be included in the HTML file. Order is important. - * \param additionalSpec JSON string that will be passed to the gdjs.RuntimeGame object. - */ - bool ExportIndexFile(gd::String source, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec = ""); - - /** - * \brief Replace the annotations in a index.html file by the specified content. - * - * \param indexFileContent The source of the index.html file. - * \param customCss "" will be replaced by the content of the string. - * \param customHtml "" will be replaced by the content of the string. - * \param exportDir The directory where the project must be generated. - * \param codeFilesIncludes "" will be replaced by HTML tags to include the filenames contained inside the vector. - * \param additionalSpec The string "GDJS_ADDITIONAL_SPEC" surrounded by comments marks will be replaced by the content of the string. - */ - bool CompleteIndexFile(gd::String & indexFileContent, gd::String customCss, gd::String customHtml, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec); - - /** - * \brief Generate the Cordova configuration file and save it to the export directory. - * - * \param project The project to be used to generate the configuration file. - * \param exportDir The directory where the config.xml must be created. - */ - bool ExportCordovaConfigFile(const gd::Project & project, gd::String exportDir); - - /** - * \brief Launch all export methods to generate a complete, stand-alone game for previewing. - * - * \param layout The layout to be previewed. - * \param exportDir The directory where the preview must be created. - * \param additionalSpec Any additional parameters to be passed to the gdjs.RuntimeGame. - * \return true if export was successful. - */ - bool ExportLayoutForPreview(gd::Project & project, gd::Layout & layout, gd::String exportDir, gd::String additionalSpec); - gd::AbstractFileSystem & fs; ///< The abstract file system to be used for exportation. gd::String lastError; ///< The last error that occurred. }; diff --git a/GDJS/GDJS/IDE/ExporterHelper.cpp b/GDJS/GDJS/IDE/ExporterHelper.cpp new file mode 100644 index 0000000000..10864a73ae --- /dev/null +++ b/GDJS/GDJS/IDE/ExporterHelper.cpp @@ -0,0 +1,512 @@ +/* + * GDevelop JS Platform + * Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved. + * This project is released under the MIT License. + */ +#include +#include +#include +#include +#include +#if !defined(GD_NO_WX_GUI) +#include +#include +#include +#include +#include +#include +#include +#endif +#include "GDCore/Tools/Localization.h" +#include "GDCore/Tools/Log.h" +#include "GDCore/TinyXml/tinyxml.h" +#include "GDCore/Project/Project.h" +#include "GDCore/Project/Layout.h" +#include "GDCore/Project/ExternalLayout.h" +#include "GDCore/IDE/AbstractFileSystem.h" +#include "GDCore/Serialization/Serializer.h" +#include "GDCore/Project/ExternalEvents.h" +#include "GDCore/Project/SourceFile.h" +#include "GDCore/IDE/wxTools/ShowFolder.h" +#include "GDCore/IDE/Project/ProjectResourcesCopier.h" +#include "GDCore/IDE/ProjectStripper.h" +#include "GDCore/CommonTools.h" +#include "GDJS/Events/CodeGeneration/EventsCodeGenerator.h" +#include "GDJS/IDE/ExporterHelper.h" +#undef CopyFile //Disable an annoying macro + +namespace gdjs +{ + +//Nice tools functions +static void InsertUnique(std::vector & container, gd::String str) +{ + if ( std::find(container.begin(), container.end(), str) == container.end() ) + container.push_back(str); +} + +static void GenerateFontsDeclaration(gd::AbstractFileSystem & fs, const gd::String & outputDir, gd::String & css, gd::String & html) +{ + std::vector ttfFiles = fs.ReadDir(outputDir, ".TTF"); + for(std::size_t i = 0; i."; + } +} + + +bool ExporterHelper::ExportLayoutForPixiPreview(gd::Project & project, gd::Layout & layout, gd::String exportDir, gd::String additionalSpec) +{ + fs.MkDir(exportDir); + fs.ClearDir(exportDir); + std::vector includesFiles; + + gd::Project exportedProject = project; + + //Export resources (*before* generating events as some resources filenames may be updated) + ExportResources(fs, exportedProject, exportDir); + //Generate events code + if ( !ExportEventsCode(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) + return false; + + AddLibsInclude(true, false, includesFiles); + + //Export source files + if ( !ExportExternalSourceFiles(exportedProject, fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/", includesFiles) ) + { + gd::LogError(_("Error during exporting! Unable to export source files:\n")+lastError); + return false; + } + + //Strip the project (*after* generating events as the events may use stripped things (objects groups...)) + gd::ProjectStripper::StripProject(exportedProject); + exportedProject.SetFirstLayout(layout.GetName()); + + //Export the project + ExportToJSON(fs, exportedProject, fs.GetTempDir() + "/GDTemporaries/JSCodeTemp/data.js", + "gdjs.projectData"); + includesFiles.push_back(fs.GetTempDir()+"/GDTemporaries/JSCodeTemp/data.js"); + + //Copy all the dependencies + RemoveIncludes(false, true, includesFiles); + ExportIncludesAndLibs(includesFiles, exportDir, false); + + //Create the index file + if (!ExportPixiIndexFile("./JsPlatform/Runtime/index.html", exportDir, includesFiles, additionalSpec)) + return false; + + return true; +} + +gd::String ExporterHelper::ExportToJSON(gd::AbstractFileSystem &fs, const gd::Project &project, gd::String filename, + gd::String wrapIntoVariable) +{ + fs.MkDir(fs.DirNameFrom(filename)); + + //Save the project to JSON + gd::SerializerElement rootElement; + project.SerializeTo(rootElement); + + gd::String output = gd::Serializer::ToJSON(rootElement); + if (!wrapIntoVariable.empty()) output = wrapIntoVariable + " = " + output + ";"; + + if (!fs.WriteToFile(filename, output)) + return "Unable to write "+filename; + + return ""; +} + +bool ExporterHelper::ExportPixiIndexFile(gd::String source, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec) +{ + gd::String str = fs.ReadFile(source); + + //Generate custom declarations for font resources + gd::String customCss; + gd::String customHtml; + GenerateFontsDeclaration(fs, exportDir, customCss, customHtml); + + //Generate the file + if (!CompleteIndexFile(str, customCss, customHtml, exportDir, includesFiles, additionalSpec)) + return false; + + //Write the index.html file + if (!fs.WriteToFile(exportDir + "/index.html", str)) + { + lastError = "Unable to write index file."; + return false; + } + + return true; +} + +bool ExporterHelper::ExportCordovaConfigFile(const gd::Project & project, gd::String exportDir) +{ + gd::String str = fs.ReadFile("./JsPlatform/Runtime/Cordova/config.xml") + .FindAndReplace("GDJS_PROJECTNAME", project.GetName()) + .FindAndReplace("GDJS_PACKAGENAME", project.GetPackageName()) + .FindAndReplace("GDJS_ORIENTATION", "default"); + + if (!fs.WriteToFile(exportDir + "/config.xml", str)) + { + lastError = "Unable to write configuration file."; + return false; + } + + return true; +} + +bool ExporterHelper::ExportCocos2dFiles(const gd::Project & project, gd::String exportDir, const std::vector & includesFiles) +{ + if (!fs.CopyFile("./JsPlatform/Runtime/Cocos2d/main.js", exportDir + "/main.js")) + { + lastError = "Unable to write Cocos2d main.js file."; + return false; + } + + if (!fs.CopyFile("./JsPlatform/Runtime/Cocos2d/index.html", exportDir + "/index.html")) + { + lastError = "Unable to write Cocos2d index.html file."; + return false; + } + + if (!fs.CopyFile("./JsPlatform/Runtime/Cocos2d/cocos2d-js-v3.10.js", exportDir + "/cocos2d-js-v3.10.js")) + { + lastError = "Unable to write Cocos2d cocos2d-js-v3.10.js file."; + return false; + } + + gd::String includeFilesStr = ""; + bool first = true; + for(auto & file : includesFiles) + { + if ( !fs.FileExists(exportDir + "/src/" + file) ) + { + std::cout << "Warning: Unable to find " << exportDir + "/" + file << "." << std::endl; + continue; + } + + includeFilesStr += gd::String(first ? "" : ", ") + "\"src/" + file + "\"\n"; + first = false; + } + + gd::String str = fs.ReadFile("./JsPlatform/Runtime/Cocos2d/project.json") + .FindAndReplace("// GDJS_INCLUDE_FILES", includeFilesStr); + + if (!fs.WriteToFile(exportDir + "/project.json", str)) + { + lastError = "Unable to write Cocos2d project.json file."; + return false; + } + + return true; +} + +bool ExporterHelper::CompleteIndexFile(gd::String & str, gd::String customCss, gd::String customHtml, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec) +{ + if (additionalSpec.empty()) additionalSpec = "{}"; + + gd::String codeFilesIncludes; + for (std::vector::const_iterator it = includesFiles.begin(); it != includesFiles.end(); ++it) + { + if ( !fs.FileExists(exportDir + "/" + *it) ) + { + std::cout << "Warning: Unable to find " << exportDir+"/"+*it << "." << std::endl; + continue; + } + + gd::String relativeFile = exportDir+"/"+*it; + fs.MakeRelative(relativeFile, exportDir); + codeFilesIncludes += "\t\n"; + } + + str = str.FindAndReplace("/* GDJS_CUSTOM_STYLE */", customCss) + .FindAndReplace("", customHtml) + .FindAndReplace("", codeFilesIncludes) + .FindAndReplace("{}/*GDJS_ADDITIONAL_SPEC*/", additionalSpec); + + return true; +} + +void ExporterHelper::AddLibsInclude(bool pixiRenderers, bool cocosRenderers, std::vector & includesFiles) +{ + if (pixiRenderers) + { + InsertUnique(includesFiles, "pixi-renderers/pixi.js"); + InsertUnique(includesFiles, "pixi-renderers/runtimegame-pixi-renderer.js"); + InsertUnique(includesFiles, "pixi-renderers/runtimescene-pixi-renderer.js"); + InsertUnique(includesFiles, "pixi-renderers/layer-pixi-renderer.js"); + InsertUnique(includesFiles, "pixi-renderers/pixi-image-manager.js"); + InsertUnique(includesFiles, "pixi-renderers/spriteruntimeobject-pixi-renderer.js"); + InsertUnique(includesFiles, "pixi-renderers/loadingscreen-pixi-renderer.js"); + InsertUnique(includesFiles, "howler-sound-manager/howler.min.js"); + InsertUnique(includesFiles, "howler-sound-manager/howler-sound-manager.js"); + } + + if (cocosRenderers) + { + InsertUnique(includesFiles, "cocos-renderers/cocos-director-manager.js"); + InsertUnique(includesFiles, "cocos-renderers/cocos-image-manager.js"); + InsertUnique(includesFiles, "cocos-renderers/cocos-tools.js"); + InsertUnique(includesFiles, "cocos-renderers/layer-cocos-renderer.js"); + InsertUnique(includesFiles, "cocos-renderers/loadingscreen-cocos-renderer.js"); + InsertUnique(includesFiles, "cocos-renderers/runtimegame-cocos-renderer.js"); + InsertUnique(includesFiles, "cocos-renderers/runtimescene-cocos-renderer.js"); + InsertUnique(includesFiles, "cocos-renderers/spriteruntimeobject-cocos-renderer.js"); + InsertUnique(includesFiles, "cocos-sound-manager/cocos-sound-manager.js"); + } +} + +void ExporterHelper::RemoveIncludes(bool pixiRenderers, bool cocosRenderers, std::vector & includesFiles) +{ + if (pixiRenderers) + { + for (auto it = includesFiles.begin(); it != includesFiles.end(); ) + { + if (it->find("pixi-renderer") != gd::String::npos) + includesFiles.erase(it++); + else + ++it; + } + } + if (cocosRenderers) + { + for (auto it = includesFiles.begin(); it != includesFiles.end(); ) + { + if (it->find("cocos-renderer") != gd::String::npos) + includesFiles.erase(it++); + else + ++it; + } + } +} + +bool ExporterHelper::ExportEventsCode(gd::Project & project, gd::String outputDir, std::vector & includesFiles) +{ + fs.MkDir(outputDir); + + //First, do not forget common includes (they must be included before events generated code files). + InsertUnique(includesFiles, "libs/jshashtable.js"); + InsertUnique(includesFiles, "gd.js"); + InsertUnique(includesFiles, "libs/hshg.js"); + InsertUnique(includesFiles, "inputmanager.js"); + InsertUnique(includesFiles, "timemanager.js"); + InsertUnique(includesFiles, "runtimeobject.js"); + InsertUnique(includesFiles, "profiler.js"); + InsertUnique(includesFiles, "runtimescene.js"); + InsertUnique(includesFiles, "scenestack.js"); + InsertUnique(includesFiles, "polygon.js"); + InsertUnique(includesFiles, "force.js"); + InsertUnique(includesFiles, "layer.js"); + InsertUnique(includesFiles, "timer.js"); + InsertUnique(includesFiles, "runtimegame.js"); + InsertUnique(includesFiles, "variable.js"); + InsertUnique(includesFiles, "variablescontainer.js"); + InsertUnique(includesFiles, "eventscontext.js"); + InsertUnique(includesFiles, "runtimebehavior.js"); + InsertUnique(includesFiles, "spriteruntimeobject.js"); + + //Common includes for events only. + InsertUnique(includesFiles, "events-tools/commontools.js"); + InsertUnique(includesFiles, "events-tools/runtimescenetools.js"); + InsertUnique(includesFiles, "events-tools/inputtools.js"); + InsertUnique(includesFiles, "events-tools/objecttools.js"); + InsertUnique(includesFiles, "events-tools/cameratools.js"); + InsertUnique(includesFiles, "events-tools/soundtools.js"); + InsertUnique(includesFiles, "events-tools/storagetools.js"); + InsertUnique(includesFiles, "events-tools/stringtools.js"); + InsertUnique(includesFiles, "events-tools/windowtools.js"); + InsertUnique(includesFiles, "events-tools/networktools.js"); + + for (std::size_t i = 0;i eventsIncludes; + gd::Layout & exportedLayout = project.GetLayout(i); + gd::String eventsOutput = EventsCodeGenerator::GenerateSceneEventsCompleteCode(project, exportedLayout, + exportedLayout.GetEvents(), eventsIncludes, false /*Export for edittime*/); + gd::String filename = outputDir+"code"+gd::String::From(i)+".js"; + + //Export the code + if (fs.WriteToFile(filename, eventsOutput)) + { + for ( std::set::iterator include = eventsIncludes.begin() ; include != eventsIncludes.end(); ++include ) + InsertUnique(includesFiles, *include); + + InsertUnique(includesFiles, filename); + } + else { + lastError = _("Unable to write ") + filename; + return false; + } + } + + return true; +} + +bool ExporterHelper::ExportExternalSourceFiles(gd::Project & project, gd::String outputDir, std::vector & includesFiles) +{ + const std::vector < std::shared_ptr > & allFiles = project.GetAllSourceFiles(); + for (std::size_t i = 0;i() ) continue; + if (allFiles[i]->GetLanguage() != "Javascript" ) continue; + + gd::SourceFile & file = *allFiles[i]; + + gd::String filename = file.GetFileName(); + fs.MakeAbsolute(filename, fs.DirNameFrom(project.GetProjectFile())); + gd::String outFilename = "ext-code"+gd::String::From(i)+".js"; + if (!fs.CopyFile(filename, outputDir+outFilename)) + gd::LogWarning(_("Could not copy external file") + filename); + + InsertUnique(includesFiles, outputDir+outFilename); + } + + return true; +} + +bool ExporterHelper::ExportIncludesAndLibs(std::vector & includesFiles, gd::String exportDir, bool minify) +{ + #if !defined(GD_NO_WX_GUI) + //Includes files : + if ( minify ) + { + gd::String nodeExec = GetNodeExecutablePath(); + if ( nodeExec.empty() || !fs.FileExists(nodeExec) ) + { + std::cout << "Node.js executable not found." << std::endl; + gd::LogWarning(_("The exported script could not be minified: Please check that you installed Node.js on your system.")); + minify = false; + } + else + { + gd::String jsPlatformDir = wxGetCwd()+"/JsPlatform/"; + gd::String cmd = nodeExec+" \""+jsPlatformDir+"Tools/uglify-js/bin/uglifyjs\" "; + + gd::String allJsFiles; + for ( std::vector::iterator include = includesFiles.begin() ; include != includesFiles.end(); ++include ) + { + if ( fs.FileExists(jsPlatformDir+"Runtime/"+*include) ) + allJsFiles += "\""+jsPlatformDir+"Runtime/"+*include+"\" "; + else if ( fs.FileExists(jsPlatformDir+"Runtime/Extensions/"+*include) ) + allJsFiles += "\""+jsPlatformDir+"Runtime/Extensions/"+*include+"\" "; + else if ( fs.FileExists(*include) ) + allJsFiles += "\""+*include+"\" "; + } + + cmd += allJsFiles; + cmd += "-o \""+exportDir+"/code.js\""; + + wxArrayString output; + wxArrayString errors; + long res = wxExecute(cmd, output, errors); + if ( res != 0 ) + { + std::cout << "Execution of \"UglifyJS\" failed (Command line : " << cmd << ")." << std::endl; + std::cout << "Output: "; + for (size_t i = 0;i::iterator include = includesFiles.begin() ; include != includesFiles.end(); ++include ) + { + if ( fs.FileExists("./JsPlatform/Runtime/"+*include) ) + { + gd::String path = fs.DirNameFrom(exportDir+"/"+*include); + if ( !fs.DirExists(path) ) fs.MkDir(path); + + fs.CopyFile("./JsPlatform/Runtime/"+*include, exportDir+"/"+*include); + //Ok, the filename is relative to the export dir. + } + else if ( fs.FileExists("./JsPlatform/Runtime/Extensions/"+*include) ) + { + gd::String path = fs.DirNameFrom(exportDir+"/Extensions/"+*include); + if ( !fs.DirExists(path) ) fs.MkDir(path); + + fs.CopyFile("./JsPlatform/Runtime/Extensions/"+*include, exportDir+"/Extensions/"+*include); + *include = "Extensions/"+*include; //Ensure filename is relative to the export dir. + } + else if ( fs.FileExists(*include) ) + { + fs.CopyFile(*include, exportDir+"/"+fs.FileNameFrom(*include)); + *include = fs.FileNameFrom(*include); //Ensure filename is relative to the export dir. + } + else + { + std::cout << "Could not copy include file " << *include << " (File not found)." << std::endl; + } + } + } + + return true; +} + +void ExporterHelper::ExportResources(gd::AbstractFileSystem & fs, gd::Project & project, gd::String exportDir, wxProgressDialog * progressDialog) +{ + gd::ProjectResourcesCopier::CopyAllResourcesTo(project, fs, exportDir, true, progressDialog, false, false); +} + +#if !defined(GD_NO_WX_GUI) +gd::String ExporterHelper::GetNodeExecutablePath() +{ + std::vector guessPaths; + wxString userPath; + if ( wxConfigBase::Get()->Read("Paths/Node" , &userPath) && !userPath.empty() ) + guessPaths.push_back(userPath); + else + { + //Try some common paths. + #if defined(WINDOWS) + guessPaths.push_back("C:/Program Files/nodejs/node.exe"); + guessPaths.push_back("C:/Program Files (x86)/nodejs/node.exe"); + #elif defined(LINUX) || defined(MACOS) + guessPaths.push_back("/usr/bin/env/nodejs"); + guessPaths.push_back("/usr/bin/nodejs"); + guessPaths.push_back("/usr/local/bin/nodejs"); + guessPaths.push_back("/usr/bin/env/node"); + guessPaths.push_back("/usr/bin/node"); + guessPaths.push_back("/usr/local/bin/node"); + #else + #warning Please complete this so as to return a path to the Node executable. + #endif + } + + for (size_t i = 0;i +#include +#include +#include "GDCore/IDE/ProjectExporter.h" +namespace gd { class Project; } +namespace gd { class Layout; } +namespace gd { class ExternalLayout; } +namespace gd { class AbstractFileSystem; } +class wxProgressDialog; + +namespace gdjs +{ + +/** + * \brief Export a project or a layout to a playable HTML5/Javascript based game. + */ +class ExporterHelper +{ +public: + ExporterHelper(gd::AbstractFileSystem & fileSystem) : fs(fileSystem) {}; + virtual ~ExporterHelper() {}; + + /** + * \brief Return the error that occurred during the last export. + */ + const gd::String & GetLastError() const { return lastError; }; + + #if !defined(GD_NO_WX_GUI) + /** + * \brief Try to locate the Node.js executable. (Node must be installed in a standard folder). + * \return An empty string if not found, a full path to the node executable otherwise. + */ + static gd::String GetNodeExecutablePath(); + #endif + + /** + * \brief Export a project to JSON + * + * \param fs The abstract file system to use to write the file + * \param project The project to be exported. + * \param filename The filename where export the project + * \param wrapIntoVariable If not empty, the resulting json will be wrapped in this javascript + * variable allowing to use it as a classical javascript object. + * \return Empty string if everthing is ok, description of the error otherwise. + */ + static gd::String ExportToJSON(gd::AbstractFileSystem &fs, const gd::Project &project, gd::String filename, + gd::String wrapIntoVariable); + + /** + * \brief Copy all the resources of the project to to the export directory, updating the resources filenames. + * + * \param fs The abstract file system to use + * \param project The project with resources to be exported. + * \param exportDir The directory where the preview must be created. + * \param progressDlg Optional wxProgressDialog which will be updated with the progress. + */ + static void ExportResources(gd::AbstractFileSystem & fs, gd::Project & project, gd::String exportDir, + wxProgressDialog * progressDlg = NULL); + + + /** + * \brief Add libraries files from Pixi.js or Cocos2d to the list of includes. + */ + void AddLibsInclude(bool pixiRenderers, bool cocosRenderers, std::vector & includesFiles); + + /** + * \brief Remove include files that are Pixi or Cocos2d renderers. + */ + void RemoveIncludes(bool pixiRenderers, bool cocosRenderers, std::vector & includesFiles); + + /** + * \brief Copy all the includes files and the standard libraries files to the export directory. + * + * The includes files are also modified so as to be relative to the export directory + * ( Files with absolute filenames are copied into the export directory and their path are stripped ). + * + * \param includesFiles A vector with filenames to be copied. + * \param exportDir The directory where the preview must be created. + * \param minify If true, the includes files must be merged into one file using Google Closure Compiler. + * ( includesFiles parameter will be updated with the new filename ) + */ + bool ExportIncludesAndLibs(std::vector & includesFiles, gd::String exportDir, bool minify); + + /** + * \brief Generate the events JS code, and save them to the export directory. + * + * Files are named "codeX.js", X being the number of the layout in the project. + * \param project The project with resources to be exported. + * \param outputDir The directory where the events code must be generated. + * \param includesFiles A reference to a vector that will be filled with JS files to be exported along with the project. + * ( including "codeX.js" files ). + */ + bool ExportEventsCode(gd::Project & project, gd::String outputDir, std::vector & includesFiles); + + /** + * \brief Copy the external source files used by the game into the export directory, and add them into files + * to be included. + * + * Files are named "ext-codeX.js", X being the index of the external source file in the project. + * \param project The project with resources to be exported. + * \param outputDir The directory where the events code must be generated. + * \param includesFiles A reference to a vector that will be filled with JS files to be exported along with the project. + * (including "ext-codeX.js" files). + */ + bool ExportExternalSourceFiles(gd::Project & project, gd::String outputDir, std::vector & includesFiles); + + /** + * \brief Generate the standard index file and save it to the export directory. + * + * The includes files must be relative to the export directory. + * + * \param project The project with layouts to be exported. + * \param source The file to be used as a template for the final file. + * \param exportDir The directory where the preview must be created. + * \param includesFiles The JS files to be included in the HTML file. Order is important. + * \param additionalSpec JSON string that will be passed to the gdjs.RuntimeGame object. + */ + bool ExportPixiIndexFile(gd::String source, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec = ""); + + /** + * \brief Replace the annotations in a index.html file by the specified content. + * + * \param indexFileContent The source of the index.html file. + * \param customCss "" will be replaced by the content of the string. + * \param customHtml "" will be replaced by the content of the string. + * \param exportDir The directory where the project must be generated. + * \param codeFilesIncludes "" will be replaced by HTML tags to include the filenames contained inside the vector. + * \param additionalSpec The string "GDJS_ADDITIONAL_SPEC" surrounded by comments marks will be replaced by the content of the string. + */ + bool CompleteIndexFile(gd::String & indexFileContent, gd::String customCss, gd::String customHtml, gd::String exportDir, const std::vector & includesFiles, gd::String additionalSpec); + + /** + * \brief Generate the Cordova configuration file and save it to the export directory. + * + * \param project The project to be used to generate the configuration file. + * \param exportDir The directory where the config.xml must be created. + */ + bool ExportCordovaConfigFile(const gd::Project & project, gd::String exportDir); + + + /** + * \brief Generate the base Cocos2d files. + * + * \param project The project to be used to generate the configuration file. + * \param exportDir The directory where the config.xml must be created. + */ + bool ExportCocos2dFiles(const gd::Project & project, gd::String exportDir, const std::vector & includesFiles); + + /** + * \brief Launch all export methods to generate a complete, stand-alone game for previewing. + * + * \param layout The layout to be previewed. + * \param exportDir The directory where the preview must be created. + * \param additionalSpec Any additional parameters to be passed to the gdjs.RuntimeGame. + * \return true if export was successful. + */ + bool ExportLayoutForPixiPreview(gd::Project & project, gd::Layout & layout, gd::String exportDir, gd::String additionalSpec); + + gd::AbstractFileSystem & fs; ///< The abstract file system to be used for exportation. + gd::String lastError; ///< The last error that occurred. +}; + +} +#endif // EXPORTER_HELPER_H diff --git a/GDJS/Runtime/Cocos2d/cocos2d-js-v3.10.js b/GDJS/Runtime/Cocos2d/cocos2d-js-v3.10.js new file mode 100644 index 0000000000..1bb9dd150d --- /dev/null +++ b/GDJS/Runtime/Cocos2d/cocos2d-js-v3.10.js @@ -0,0 +1,36 @@ +var cc=cc||{};cc._tmp=cc._tmp||{},cc._LogInfos={};var _p=window;_p.gl,_p.WebGLRenderingContext,_p.DeviceOrientationEvent,_p.DeviceMotionEvent,_p.AudioContext,_p.AudioContext||_p.webkitAudioContext,_p.mozAudioContext,_p=Object.prototype,_p._super,_p.ctor,_p=null,cc.ORIENTATION_PORTRAIT=0,cc.ORIENTATION_PORTRAIT_UPSIDE_DOWN=1,cc.ORIENTATION_LANDSCAPE_LEFT=2,cc.ORIENTATION_LANDSCAPE_RIGHT=3,cc._drawingUtil=null,cc._renderContext=null,cc._supportRender=!1,cc._canvas=null,cc.container=null,cc._gameDiv=null,cc.newElement=function(a){return document.createElement(a)},cc.each=function(a,b,c){if(a)if(a instanceof Array){for(var d=0,e=a.length;e>d;d++)if(b.call(c,a[d],d)===!1)return}else for(var f in a)if(b.call(c,a[f],f)===!1)return},cc.extend=function(a){var b=arguments.length>=2?Array.prototype.slice.call(arguments,1):[];return cc.each(b,function(b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}),a},cc.isFunction=function(a){return"function"==typeof a},cc.isNumber=function(a){return"number"==typeof a||"[object Number]"===Object.prototype.toString.call(a)},cc.isString=function(a){return"string"==typeof a||"[object String]"===Object.prototype.toString.call(a)},cc.isArray=function(a){return Array.isArray(a)||"object"==typeof a&&"[object Array]"===Object.prototype.toString.call(a)},cc.isUndefined=function(a){return"undefined"==typeof a},cc.isObject=function(a){return"object"==typeof a&&"[object Object]"===Object.prototype.toString.call(a)},cc.isCrossOrigin=function(a){if(!a)return cc.log("invalid URL"),!1;var b=a.indexOf("://");if(-1===b)return!1;var c=a.indexOf("/",b+3),d=-1===c?a:a.substring(0,c);return d!==location.origin},cc.AsyncPool=function(a,b,c,d,e){var f=this;f._srcObj=a,f._limit=b,f._pool=[],f._iterator=c,f._iteratorTarget=e,f._onEnd=d,f._onEndTarget=e,f._results=a instanceof Array?[]:{},cc.each(a,function(a,b){f._pool.push({index:b,value:a})}),f.size=f._pool.length,f.finishedSize=0,f._workingSize=0,f._limit=f._limit||f.size,f.onIterator=function(a,b){f._iterator=a,f._iteratorTarget=b},f.onEnd=function(a,b){f._onEnd=a,f._onEndTarget=b},f._handleItem=function(){var a=this;if(!(0===a._pool.length||a._workingSize>=a._limit)){var b=a._pool.shift(),c=b.value,d=b.index;a._workingSize++,a._iterator.call(a._iteratorTarget,c,d,function(b){a.finishedSize++,a._workingSize--;var c=Array.prototype.slice.call(arguments,1);return a._results[this.index]=c[0],a.finishedSize===a.size?void(a._onEnd&&a._onEnd.call(a._onEndTarget,null,a._results)):void a._handleItem()}.bind(b),a)}},f.flow=function(){var a=this;if(0===a._pool.length)return void(a._onEnd&&a._onEnd.call(a._onEndTarget,null,[]));for(var b=0;bc;c++)b=(b+(""===b?"":"/")+arguments[c]).replace(/(\/|\\\\)$/,"");return b},extname:function(a){var b=/(\.[^\.\/\?\\]*)(\?.*)?$/.exec(a);return b?b[1]:null},mainFileName:function(a){if(a){var b=a.lastIndexOf(".");if(-1!==b)return a.substring(0,b)}return a},basename:function(a,b){var c=a.indexOf("?");c>0&&(a=a.substring(0,c));var d=/(\/|\\\\)([^(\/|\\\\)]+)$/g,e=d.exec(a.replace(/(\/|\\\\)$/,""));if(!e)return null;var f=e[2];return b&&a.substring(a.length-b.length).toLowerCase()===b.toLowerCase()?f.substring(0,f.length-b.length):f},dirname:function(a){return a.replace(/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,"$2")},changeExtname:function(a,b){b=b||"";var c=a.indexOf("?"),d="";return c>0&&(d=a.substring(c),a=a.substring(0,c)),c=a.lastIndexOf("."),0>c?a+b+d:a.substring(0,c)+b+d},changeBasename:function(a,b,c){if(0===b.indexOf("."))return this.changeExtname(a,b);var d=a.indexOf("?"),e="",f=c?this.extname(a):"";return d>0&&(e=a.substring(d),a=a.substring(0,d)),d=a.lastIndexOf("/"),d=0>=d?0:d+1,a.substring(0,d)+b+f+e},_normalize:function(a){var b=a=String(a);do b=a,a=a.replace(this.normalizeRE,"");while(b.length!==a.length);return a}},cc.loader=function(){var a={},b={},c={},d={},e=new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))|(?:localhost))(?::\\d{2,5})?(?:/\\S*)?$","i");return{resPath:"",audioPath:"",cache:{},getXMLHttpRequest:function(){return window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP")},_getArgs4Js:function(a){var b=a[0],c=a[1],d=a[2],e=["",null,null];if(1===a.length)e[1]=b instanceof Array?b:[b];else if(2===a.length)"function"==typeof c?(e[1]=b instanceof Array?b:[b],e[2]=c):(e[0]=b||"",e[1]=c instanceof Array?c:[c]);else{if(3!==a.length)throw new Error("arguments error to load js!");e[0]=b||"",e[1]=c instanceof Array?c:[c],e[2]=d}return e},loadJs:function(b,c,d){var e=this,f=e._getArgs4Js(arguments),g=f[0],h=f[1],i=f[2];navigator.userAgent.indexOf("Trident/5")>-1?e._loadJs4Dependency(g,h,0,i):cc.async.map(h,function(b,c,d){var f=cc.path.join(g,b);return a[f]?d(null):void e._createScript(f,!1,d)},i)},loadJsWithImg:function(a,b,c){var d=this,e=d._loadJsImg(),f=d._getArgs4Js(arguments);this.loadJs(f[0],f[1],function(a){if(a)throw new Error(a);e.parentNode.removeChild(e),f[2]&&f[2]()})},_createScript:function(b,c,d){var e=document,f=this,g=document.createElement("script");g.async=c,a[b]=!0,cc.game.config.noCache&&"string"==typeof b?f._noCacheRex.test(b)?g.src=b+"&_t="+(new Date-0):g.src=b+"?_t="+(new Date-0):g.src=b,g.addEventListener("load",function(){g.parentNode.removeChild(g),this.removeEventListener("load",arguments.callee,!1),d()},!1),g.addEventListener("error",function(){g.parentNode.removeChild(g),d("Load "+b+" failed!")},!1),e.body.appendChild(g)},_loadJs4Dependency:function(a,b,c,d){if(c>=b.length)return void(d&&d());var e=this;e._createScript(cc.path.join(a,b[c]),!1,function(f){return f?d(f):void e._loadJs4Dependency(a,b,c+1,d)})},_loadJsImg:function(){var a=document,b=a.getElementById("cocos2d_loadJsImg");if(!b){b=document.createElement("img"),cc._loadingImage&&(b.src=cc._loadingImage);var c=a.getElementById(cc.game.config.id);c.style.backgroundColor="transparent",c.parentNode.appendChild(b);var d=getComputedStyle?getComputedStyle(c):c.currentStyle;d||(d={width:c.width,height:c.height}),b.style.left=c.offsetLeft+(parseFloat(d.width)-b.width)/2+"px",b.style.top=c.offsetTop+(parseFloat(d.height)-b.height)/2+"px",b.style.position="absolute"}return b},loadTxt:function(a,b){if(cc._isNodeJs){var c=require("fs");c.readFile(a,function(a,c){a?b(a):b(null,c.toString())})}else{var d=this.getXMLHttpRequest(),e="load "+a+" failed!";d.open("GET",a,!0),/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?(d.setRequestHeader("Accept-Charset","utf-8"),d.onreadystatechange=function(){4===d.readyState&&(200===d.status?b(null,d.responseText):b({status:d.status,errorMessage:e},null))}):(d.overrideMimeType&&d.overrideMimeType("text/plain; charset=utf-8"),d.onload=function(){4===d.readyState&&(200===d.status?b(null,d.responseText):b({status:d.status,errorMessage:e},null))},d.onerror=function(){b({status:d.status,errorMessage:e},null)}),d.send(null)}},_loadTxtSync:function(a){if(cc._isNodeJs){var b=require("fs");return b.readFileSync(a).toString()}var c=this.getXMLHttpRequest();return c.open("GET",a,!1),/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)?c.setRequestHeader("Accept-Charset","utf-8"):c.overrideMimeType&&c.overrideMimeType("text/plain; charset=utf-8"),c.send(null),4===!c.readyState||200!==c.status?null:c.responseText},loadCsb:function(a,b){var c=new XMLHttpRequest,d="load "+a+" failed!";c.open("GET",a,!0),c.responseType="arraybuffer",c.onload=function(){var a=c.response;a&&(window.msg=a),4===c.readyState&&(200===c.status?b(null,c.response):b({status:c.status,errorMessage:d},null))},c.onerror=function(){b({status:c.status,errorMessage:d},null)},c.send(null)},loadJson:function(a,b){this.loadTxt(a,function(c,d){if(c)b(c);else{try{var e=JSON.parse(d)}catch(f){throw new Error("parse json ["+a+"] failed : "+f)}b(null,e)}})},_checkIsImageURL:function(a){var b=/(\.png)|(\.jpg)|(\.bmp)|(\.jpeg)|(\.gif)/.exec(a);return null!=b},loadImg:function(a,b,c){var d={isCrossOrigin:!0};void 0!==c?d.isCrossOrigin=null===b.isCrossOrigin?d.isCrossOrigin:b.isCrossOrigin:void 0!==b&&(c=b);var e=this.getRes(a);if(e)return c&&c(null,e),e;e=new Image,d.isCrossOrigin&&"file://"!==location.origin&&(e.crossOrigin="Anonymous");var f=function(){this.removeEventListener("load",f,!1),this.removeEventListener("error",h,!1),cc.loader.cache[a]=e,c&&c(null,e)},g=this,h=function(){this.removeEventListener("error",h,!1),e.crossOrigin&&"anonymous"===e.crossOrigin.toLowerCase()?(d.isCrossOrigin=!1,g.release(a),cc.loader.loadImg(a,d,c)):"function"==typeof c&&c("load image failed")};return e.addEventListener("load",f),e.addEventListener("error",h),e.src=a,e},_loadResIterator:function(a,c,d){var f=this,g=null,h=a.type;h?(h="."+h.toLowerCase(),g=a.src?a.src:a.name+h):(g=a,h=cc.path.extname(g));var i=f.getRes(g);if(i)return d(null,i);var j=null;if(h&&(j=b[h.toLowerCase()]),!j)return cc.error("loader for ["+h+"] not exists!"),d();var k=g;if(!e.test(g)){var l=j.getBasePath?j.getBasePath():f.resPath;k=f.getUrl(l,g)}cc.game.config.noCache&&"string"==typeof k&&(k+=f._noCacheRex.test(k)?"&_t="+(new Date-0):"?_t="+(new Date-0)),j.load(k,g,a,function(a,b){a?(cc.log(a),f.cache[g]=null,delete f.cache[g],d({status:520,errorMessage:a},null)):(f.cache[g]=b,d(null,b))})},_noCacheRex:/\?/,getUrl:function(a,d){var e=this,f=cc.path;if(void 0!==a&&void 0===d){d=a;var g=f.extname(d);g=g?g.toLowerCase():"";var h=b[g];a=h&&h.getBasePath?h.getBasePath():e.resPath}if(d=cc.path.join(a||"",d),d.match(/[\/(\\\\)]lang[\/(\\\\)]/i)){if(c[d])return c[d];var i=f.extname(d)||"";d=c[d]=d.substring(0,d.length-i.length)+"_"+cc.sys.language+i}return d},load:function(a,b,c){var d=this,e=arguments.length;if(0===e)throw new Error("arguments error!");3===e?"function"==typeof b&&(b="function"==typeof c?{trigger:b,cb:c}:{cb:b,cbTarget:c}):2===e?"function"==typeof b&&(b={cb:b}):1===e&&(b={}),a instanceof Array||(a=[a]);var f=new cc.AsyncPool(a,0,function(a,c,e,f){d._loadResIterator(a,c,function(a){var c=Array.prototype.slice.call(arguments,1);b.trigger&&b.trigger.call(b.triggerTarget,c[0],f.size,f.finishedSize),e(a,c[0])})},b.cb,b.cbTarget);return f.flow(),f},_handleAliases:function(a,b){var c=[];for(var e in a){var f=a[e];d[e]=f,c.push(f)}this.load(c,b)},loadAliases:function(a,b){var c=this,d=c.getRes(a);d?c._handleAliases(d.filenames,b):c.load(a,function(a,d){c._handleAliases(d[0].filenames,b)})},register:function(a,c){if(a&&c){if("string"==typeof a)return b[a.trim().toLowerCase()]=c;for(var d=0,e=a.length;e>d;d++)b["."+a[d].trim().toLowerCase()]=c}},getRes:function(a){return this.cache[a]||this.cache[d[a]]},_getAliase:function(a){return d[a]},release:function(a){var b=this.cache;delete b[a],delete b[d[a]],delete d[a]},releaseAll:function(){var a=this.cache;for(var b in a)delete a[b];for(var b in d)delete d[b]}}}(),cc.formatStr=function(){var a=arguments,b=a.length;if(1>b)return"";var c=a[0],d=!0;"object"==typeof c&&(d=!1);for(var e=1;b>e;++e){var f=a[e];if(d)for(;;){var g=null;if("number"==typeof f&&(g=c.match(/(%d)|(%s)/))){c=c.replace(/(%d)|(%s)/,f);break}g=c.match(/%s/),g?c=c.replace(/%s/,f):c+=" "+f;break}else c+=" "+f}return c},function(){function a(a){var b=cc.game.CONFIG_KEY,c=parseInt(a[b.renderMode])||0,d=[cc.sys.OS_ANDROID],e=[];(isNaN(c)||c>2||0>c)&&(a[b.renderMode]=0),cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0,(2===c||0===c&&-1===d.indexOf(cc.sys.os)&&-1===e.indexOf(cc.sys.browserType))&&(cc.sys.capabilities.opengl?(cc._renderType=cc.game.RENDER_TYPE_WEBGL,cc._supportRender=!0):cc._supportRender=!1),(1===c||0===c&&!cc._supportRender)&&(cc.sys.capabilities.canvas?(cc._renderType=cc.game.RENDER_TYPE_CANVAS,cc._supportRender=!0):cc._supportRender=!1)}function b(a,c,d){if(i[c])return null;d=d||"";var e=[],f=a[c];if(!f)throw new Error("can not find module ["+c+"]");for(var g=cc.path,h=0,j=f.length;j>h;h++){var k=f[h];if(!i[k]){var l=g.extname(k);if(l)".js"===l.toLowerCase()&&e.push(g.join(d,k));else{var m=b(a,k,d);m&&(e=e.concat(m))}i[k]=1}}return e}function c(a){cc._initDebugSetting&&cc._initDebugSetting(a[cc.game.CONFIG_KEY.debugMode]),cc._engineLoaded=!0,cc.log(cc.ENGINE_VERSION),k&&k()}function d(a){var d=cc.game.CONFIG_KEY,e=a[d.engineDir],f=cc.loader;if(cc.Class)c(a);else{var g=cc.path.join(e,"moduleConfig.json");f.loadJson(g,function(d,f){if(d)throw new Error(d);var g=a.modules||[],h=f.module,i=[];cc.sys.capabilities.opengl&&g.indexOf("base4webgl")<0?g.splice(0,0,"base4webgl"):g.indexOf("core")<0&&g.splice(0,0,"core");for(var j=0,k=g.length;k>j;j++){var l=b(h,g[j],e);l&&(i=i.concat(l))}cc.loader.loadJsWithImg(i,function(b){if(b)throw b;c(a)})})}}function e(){this.removeEventListener("load",e,!1),d(cc.game.config)}var f=document.createElement("canvas"),g=document.createElement("canvas");cc.create3DContext=function(a,b){for(var c=["webgl","experimental-webgl","webkit-3d","moz-webgl"],d=null,e=0;e-1&&(c.onfocus=function(){e()}),"onpageshow"in window&&"onpagehide"in window&&(c.addEventListener("pagehide",d,!1),c.addEventListener("pageshow",e,!1)),cc.eventManager.addCustomListener(cc.game.EVENT_HIDE,function(){cc.game.pause()}),cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){cc.game.resume()})}},Function.prototype.bind=Function.prototype.bind||function(a){if(!cc.isFunction(this))throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e},cc._urlRegExp=new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))|(?:localhost))(?::\\d{2,5})?(?:/\\S*)?$","i"),cc.EventHelper=function(){},cc.EventHelper.prototype={constructor:cc.EventHelper,apply:function(a){a.addEventListener=cc.EventHelper.prototype.addEventListener,a.hasEventListener=cc.EventHelper.prototype.hasEventListener,a.removeEventListener=cc.EventHelper.prototype.removeEventListener,a.dispatchEvent=cc.EventHelper.prototype.dispatchEvent},addEventListener:function(a,b,c){if("load"===a&&this._textureLoaded)return void setTimeout(function(){b.call(c)},0);void 0===this._listeners&&(this._listeners={});var d=this._listeners;void 0===d[a]&&(d[a]=[]),this.hasEventListener(a,b,c)||d[a].push({callback:b,eventTarget:c})},hasEventListener:function(a,b,c){if(void 0===this._listeners)return!1;var d=this._listeners;if(void 0!==d[a])for(var e=0,f=d.length;f>e;e++){var g=d[e];if(g.callback===b&&g.eventTarget===c)return!0}return!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners,d=c[a];if(void 0!==d)for(var e=0;eg;g++)e[g]=d[g];for(g=0;f>g;g++)e[g].callback.call(e[g].eventTarget,this);b&&(d.length=0)}}}},cc.EventHelper.prototype.apply(cc.game);var cc=cc||{};if(cc._loadingImage="data:image/gif;base64,R0lGODlhEAAQALMNAD8/P7+/vyoqKlVVVX9/fxUVFUBAQGBgYMDAwC8vL5CQkP///wAAAP///wAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFAAANACwAAAAAEAAQAAAEO5DJSau9OOvNex0IMnDIsiCkiW6g6BmKYlBFkhSUEgQKlQCARG6nEBwOgl+QApMdCIRD7YZ5RjlGpCUCACH5BAUAAA0ALAAAAgAOAA4AAAQ6kLGB0JA4M7QW0hrngRllkYyhKAYqKUGguAws0ypLS8JxCLQDgXAIDg+FRKIA6v0SAECCBpXSkstMBAAh+QQFAAANACwAAAAACgAQAAAEOJDJORAac6K1kDSKYmydpASBUl0mqmRfaGTCcQgwcxDEke+9XO2WkxQSiUIuAQAkls0n7JgsWq8RACH5BAUAAA0ALAAAAAAOAA4AAAQ6kMlplDIzTxWC0oxwHALnDQgySAdBHNWFLAvCukc215JIZihVIZEogDIJACBxnCSXTcmwGK1ar1hrBAAh+QQFAAANACwAAAAAEAAKAAAEN5DJKc4RM+tDyNFTkSQF5xmKYmQJACTVpQSBwrpJNteZSGYoFWjIGCAQA2IGsVgglBOmEyoxIiMAIfkEBQAADQAsAgAAAA4ADgAABDmQSVZSKjPPBEDSGucJxyGA1XUQxAFma/tOpDlnhqIYN6MEAUXvF+zldrMBAjHoIRYLhBMqvSmZkggAIfkEBQAADQAsBgAAAAoAEAAABDeQyUmrnSWlYhMASfeFVbZdjHAcgnUQxOHCcqWylKEohqUEAYVkgEAMfkEJYrFA6HhKJsJCNFoiACH5BAUAAA0ALAIAAgAOAA4AAAQ3kMlJq704611SKloCAEk4lln3DQgyUMJxCBKyLAh1EMRR3wiDQmHY9SQslyIQUMRmlmVTIyRaIgA7",cc._fpsImage="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAAgCAYAAAD9qabkAAAKQ2lDQ1BJQ0MgcHJvZmlsZQAAeNqdU3dYk/cWPt/3ZQ9WQtjwsZdsgQAiI6wIyBBZohCSAGGEEBJAxYWIClYUFRGcSFXEgtUKSJ2I4qAouGdBiohai1VcOO4f3Ke1fXrv7e371/u855zn/M55zw+AERImkeaiagA5UoU8Otgfj09IxMm9gAIVSOAEIBDmy8JnBcUAAPADeXh+dLA//AGvbwACAHDVLiQSx+H/g7pQJlcAIJEA4CIS5wsBkFIAyC5UyBQAyBgAsFOzZAoAlAAAbHl8QiIAqg0A7PRJPgUA2KmT3BcA2KIcqQgAjQEAmShHJAJAuwBgVYFSLALAwgCgrEAiLgTArgGAWbYyRwKAvQUAdo5YkA9AYACAmUIszAAgOAIAQx4TzQMgTAOgMNK/4KlfcIW4SAEAwMuVzZdL0jMUuJXQGnfy8ODiIeLCbLFCYRcpEGYJ5CKcl5sjE0jnA0zODAAAGvnRwf44P5Dn5uTh5mbnbO/0xaL+a/BvIj4h8d/+vIwCBAAQTs/v2l/l5dYDcMcBsHW/a6lbANpWAGjf+V0z2wmgWgrQevmLeTj8QB6eoVDIPB0cCgsL7SViob0w44s+/zPhb+CLfvb8QB7+23rwAHGaQJmtwKOD/XFhbnauUo7nywRCMW735yP+x4V//Y4p0eI0sVwsFYrxWIm4UCJNx3m5UpFEIcmV4hLpfzLxH5b9CZN3DQCshk/ATrYHtctswH7uAQKLDljSdgBAfvMtjBoLkQAQZzQyefcAAJO/+Y9AKwEAzZek4wAAvOgYXKiUF0zGCAAARKCBKrBBBwzBFKzADpzBHbzAFwJhBkRADCTAPBBCBuSAHAqhGJZBGVTAOtgEtbADGqARmuEQtMExOA3n4BJcgetwFwZgGJ7CGLyGCQRByAgTYSE6iBFijtgizggXmY4EImFINJKApCDpiBRRIsXIcqQCqUJqkV1II/ItchQ5jVxA+pDbyCAyivyKvEcxlIGyUQPUAnVAuagfGorGoHPRdDQPXYCWomvRGrQePYC2oqfRS+h1dAB9io5jgNExDmaM2WFcjIdFYIlYGibHFmPlWDVWjzVjHVg3dhUbwJ5h7wgkAouAE+wIXoQQwmyCkJBHWExYQ6gl7CO0EroIVwmDhDHCJyKTqE+0JXoS+cR4YjqxkFhGrCbuIR4hniVeJw4TX5NIJA7JkuROCiElkDJJC0lrSNtILaRTpD7SEGmcTCbrkG3J3uQIsoCsIJeRt5APkE+S+8nD5LcUOsWI4kwJoiRSpJQSSjVlP+UEpZ8yQpmgqlHNqZ7UCKqIOp9aSW2gdlAvU4epEzR1miXNmxZDy6Qto9XQmmlnafdoL+l0ugndgx5Fl9CX0mvoB+nn6YP0dwwNhg2Dx0hiKBlrGXsZpxi3GS+ZTKYF05eZyFQw1zIbmWeYD5hvVVgq9ip8FZHKEpU6lVaVfpXnqlRVc1U/1XmqC1SrVQ+rXlZ9pkZVs1DjqQnUFqvVqR1Vu6k2rs5Sd1KPUM9RX6O+X/2C+mMNsoaFRqCGSKNUY7fGGY0hFsYyZfFYQtZyVgPrLGuYTWJbsvnsTHYF+xt2L3tMU0NzqmasZpFmneZxzQEOxrHg8DnZnErOIc4NznstAy0/LbHWaq1mrX6tN9p62r7aYu1y7Rbt69rvdXCdQJ0snfU6bTr3dQm6NrpRuoW623XP6j7TY+t56Qn1yvUO6d3RR/Vt9KP1F+rv1u/RHzcwNAg2kBlsMThj8MyQY+hrmGm40fCE4agRy2i6kcRoo9FJoye4Ju6HZ+M1eBc+ZqxvHGKsNN5l3Gs8YWJpMtukxKTF5L4pzZRrmma60bTTdMzMyCzcrNisyeyOOdWca55hvtm82/yNhaVFnMVKizaLx5balnzLBZZNlvesmFY+VnlW9VbXrEnWXOss623WV2xQG1ebDJs6m8u2qK2brcR2m23fFOIUjynSKfVTbtox7PzsCuya7AbtOfZh9iX2bfbPHcwcEh3WO3Q7fHJ0dcx2bHC866ThNMOpxKnD6VdnG2ehc53zNRemS5DLEpd2lxdTbaeKp26fesuV5RruutK10/Wjm7ub3K3ZbdTdzD3Ffav7TS6bG8ldwz3vQfTw91jicczjnaebp8LzkOcvXnZeWV77vR5Ps5wmntYwbcjbxFvgvct7YDo+PWX6zukDPsY+Ap96n4e+pr4i3z2+I37Wfpl+B/ye+zv6y/2P+L/hefIW8U4FYAHBAeUBvYEagbMDawMfBJkEpQc1BY0FuwYvDD4VQgwJDVkfcpNvwBfyG/ljM9xnLJrRFcoInRVaG/owzCZMHtYRjobPCN8Qfm+m+UzpzLYIiOBHbIi4H2kZmRf5fRQpKjKqLupRtFN0cXT3LNas5Fn7Z72O8Y+pjLk722q2cnZnrGpsUmxj7Ju4gLiquIF4h/hF8ZcSdBMkCe2J5MTYxD2J43MC52yaM5zkmlSWdGOu5dyiuRfm6c7Lnnc8WTVZkHw4hZgSl7I/5YMgQlAvGE/lp25NHRPyhJuFT0W+oo2iUbG3uEo8kuadVpX2ON07fUP6aIZPRnXGMwlPUit5kRmSuSPzTVZE1t6sz9lx2S05lJyUnKNSDWmWtCvXMLcot09mKyuTDeR55m3KG5OHyvfkI/lz89sVbIVM0aO0Uq5QDhZML6greFsYW3i4SL1IWtQz32b+6vkjC4IWfL2QsFC4sLPYuHhZ8eAiv0W7FiOLUxd3LjFdUrpkeGnw0n3LaMuylv1Q4lhSVfJqedzyjlKD0qWlQyuCVzSVqZTJy26u9Fq5YxVhlWRV72qX1VtWfyoXlV+scKyorviwRrjm4ldOX9V89Xlt2treSrfK7etI66Trbqz3Wb+vSr1qQdXQhvANrRvxjeUbX21K3nShemr1js20zcrNAzVhNe1bzLas2/KhNqP2ep1/XctW/a2rt77ZJtrWv913e/MOgx0VO97vlOy8tSt4V2u9RX31btLugt2PGmIbur/mft24R3dPxZ6Pe6V7B/ZF7+tqdG9s3K+/v7IJbVI2jR5IOnDlm4Bv2pvtmne1cFoqDsJB5cEn36Z8e+NQ6KHOw9zDzd+Zf7f1COtIeSvSOr91rC2jbaA9ob3v6IyjnR1eHUe+t/9+7zHjY3XHNY9XnqCdKD3x+eSCk+OnZKeenU4/PdSZ3Hn3TPyZa11RXb1nQ8+ePxd07ky3X/fJ897nj13wvHD0Ivdi2yW3S609rj1HfnD94UivW2/rZffL7Vc8rnT0Tes70e/Tf/pqwNVz1/jXLl2feb3vxuwbt24m3Ry4Jbr1+Hb27Rd3Cu5M3F16j3iv/L7a/eoH+g/qf7T+sWXAbeD4YMBgz8NZD+8OCYee/pT/04fh0kfMR9UjRiONj50fHxsNGr3yZM6T4aeypxPPyn5W/3nrc6vn3/3i+0vPWPzY8Av5i8+/rnmp83Lvq6mvOscjxx+8znk98ab8rc7bfe+477rfx70fmSj8QP5Q89H6Y8en0E/3Pud8/vwv94Tz+4A5JREAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfcAgcQLxxUBNp/AAAQZ0lEQVR42u2be3QVVZbGv1N17829eRLyIKAEOiISEtPhJTJAYuyBDmhWjAEx4iAGBhxA4wABbVAMWUAeykMCM+HRTcBRWkNH2l5moS0LCCrQTkYeQWBQSCAIgYRXEpKbW/XNH5zS4noR7faPEeu31l0h4dSpvc+t/Z199jkFWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhY/H9D/MR9qfKnLj/00U71aqfJn9+HCkCR/Wk36ddsgyJ/1wF4fkDfqqm9/gPsUeTnVr6a2xlQfnxdI7zs0W7irzD17Ytb2WT7EeNv/r4ox1O3Quf2QP2pgt9utwfout4FQE8AVBSlnaRmfvAURQkg2RlAbwB9AThlW5L0GaiKojhJhgOIBqDa7XaPrusdPtr5kQwF0BVAAoBIABRCKDd5aFUhRDAAw57eAOwAhKIoupft3zoqhB1AqLwuHIBut9uFt02qqvqRDJR2dAEQJj/BAOjn56dqmma+xiaECAEQAWAggLsB6A6HQ2iaZggBhBAqgEAAnQB0kzaEmT4hAITT6VQ8Ho/HJAKKECJQtr8LwD1y/A1/vcdfEUIEyfZ9AcQbYvZ942Px88L2UwlJR0dH0EMPPbRj5syZPUeNGrXR7Xb/641xIwJ1XY9NSUlZm52dfW+XLl1w8uRJzJ8//+OGhoYJqqqe1TSt1Wsm9NN1PSIqKmr12rVrR5WUlHy1bdu2AQCumWc3IYRD1/UwVVXnFRQUTIuNjUVzczN2797dWFJSkq8oymZd15sAGAEnFEUJ1nX9nzIzM1dnZmZGh4SE4OTJk5g5c+Zf29vbp9pstrMej6fVOyhIhgAYU1hY+B+hoaGoqKg4XVlZea+XTULTNFdCQsLGiRMnPuR2u3UhBOV9eeDAAWXTpk095DUe6WsoyRE5OTlr0tLSAux2O/bs2cO5c+e+pijKUpIXSHaQVAGkvPLKK++6XK4OksJLCFlXV2cvKSlJBFAjhU+x2WwhHo9nUHp6+urMzMy7wsLCUF9fjxdffPHjxsbGiTab7WuPx9NiEutOuq4PyMjI+M+srKyYqKgoHD58GDNmzNjq8XhyVFU9b/q+LH7hBAEYu3PnTlZVVRFAGgCX6f/tAHoOHDjwa0p27txp/JO9e/f+QM7cipw9nfL3kQBKt2zZQpJ87rnn6mQmoHilw2EACs+cOUOSrK+vZ1NTE0nyo48+IoBpxswoBcMJ4Ndjx471kOTFixe5d+9ekqTH42H//v13A4jyzpAURfEH0H/OnDnthu1z5sw558MmFUCPWbNmnaMP3nrrLZoyDmP8Hl68eDFJ8siRI9/Yc+zYMQKYKdtAztrTrl27xptRXV1NAKMAOAyBBBA/Y8aMdpLs6Ojgxx9//E37+++//29yvFXppwvAwMcee8xjtDHsuXLlCqOjo//ia3wsfpkoALqFhoZuIckJEyackimm3dQmEMDUmpoakmRISMhhAHOHDx/eQJIbN24kgKEyMAHAFRMTs2XXrl1saWkhSZ0kp0+ffhrAr3wEW/S8efOukORLL72kA1gKYMPWrVtJkk899dRJAHeYrgsEsIQkjx8/TgDvAPjd448/3kaSb7zxBmUa7vC6z53BwcFbSHL9+vU6Sc6aNes8gF5ewWAH0PfVV18lSQL4DMBGIcQ6AKtcLleBFC2jXtFt8ODBe0iyoqKCAJYByC8qKmJDQwOzsrK+MAmqo1OnTveHhoa+GRkZ+XZkZOSWiIiIvzgcjk9mzpypkWRmZuZpmbYbGV4AgPnNzc1sa2sjgN0A5iQmJtaSZHl5OQHcb/K3s81mW0uSTU1NBFAFYFbfvn1Pk+Tbb79NAA8IIVzW42/hByA+Pz/fLR/2ZXIda05NI/z9/TeR5J49ewhgqlxTrtI0jY2NjQQw3zTLuWJiYjaUlJToS5Ys6fjkk080kwDEeAmADcA9GzZsIElGRUW9CyAWwLApU6Y0kOSKFSsog9QICGdERMTGsrIyZmVlEcC9AB4IDw/fTpLbtm0jgN94CUAnAJmVlZVcs2aNZ/LkyRdJcvbs2b4EwAkgZfPmzTxw4AABFAN4BkC6vFeUSewcAO5duXIlSTIhIaEawGMAxgKYAmAGgCS73e5vrKVk/yGythANYEhCQsIhkly+fDkBpKqqGmL6DgIALDKN/3yZpVWQZGVlJQE8aPI3KiMjo5okV61aRQAjAPQBMPfIkSN0u90EUCBtsPiFEwpgbn19PdetW2fM5N4zQ9ekpKQqkty0aRMBpMjiWM6JEydIkoqirJUFJ6iq6pAPVy8A6cZMehMBUACEuVyuFwG8HBwcPEIWx367ZMkSjSQXLVrUJouTRorrkAHdA8BdQogsAOsKCwtJkmPGjDkvMw2bDDo/ADEjRoz4XylyFbm5uY0mAbjLyyZ/AOOrq6tZVlbWsWDBgo69e/eyoqKCgwcPPg4gSQaoIRbp27dvN7KF+tLSUr28vJwFBQXtMpvpYRIM7+wrAkDeqVOnePbsWQIoNKfzpiXPg8uXLydJJicnNwF4f+nSpW6STEtLq5fjYwhk1wkTJtSQ5Ouvv04AqTKj+N2xY8dIkgEBAW/Ie1v8wncRegwZMmQvSfbr12+3Ua33WqPfOWbMmP0kWVpaSgCDZAqcfejQIWNZsEGKgvnh9gfQb9myZd8nAEJVVZtMkUNk8CcNHTq0liR1XWdYWNhmH1mJIme80OnTp18x1rp5eXkEsNJms92Fb7e/IgEsvHz5Mp999tkmAI/l5uZeMC0B7vEqqAYAyL106RJJsra2lpWVld+sucePH38ZQG+5NncBeOrgwYMkqbe3t/Po0aOsra011wAWyl0H7x0JJ4DE+fPnu0kyPT29DsDdUrBuyNKEEAkAdpw/f/6GeoEM8GUmfwEgPCIiopwkGxsbabPZPgOw6L777vvm4p49e26VGYjFLxUhhD+ApLKyMp44ccIoVnXybgbgzkcfffRzklyzZg0BDJYCMMmoCwQFBXkLgLGWvvcWAgBToSsKwNPTp09vMR7UuLi4rwH0lgU8c/Db5ezbeeTIkRWzZ8++aMxu+fn5BPCADBwHgP4LFy701NXVEUAJgAnPP/98kyxMNgHo53A4zH77BQQETMvPz7+Um5vbBuAlAFMSExPPmdbVL0qh8Acw8fDhw5SCchVAEYAVb775JknyhRdeaJYztHfxMwLAaqNwCGC2FArv8x0hAHKNLGPKlCme5OTk/Zs3bzb7O0wKiiG8KXl5ed8IxenTp0mSR48e1UmyW7duWywBuD2xyQcgFECgoih+8H1gyJgZV5Lkyy+/3CbTRIePtl2HDBmyw1QBHyGDdXZdXR1JUghRKkXBjOMHCoBdpr0L3nvvPZLkF198wejo6O0A4lVVDTb74HQ6AwD8Wq7Jh8rgGgDgQ13XjVR8qaxJuADMbmlpYXl5uV5UVNRWUFDgfv/993Vj/ZydnU1c37eHXML4S3viAcQqitJD2l104cIFY8lTKsXSBWBMVVWVcd9yed2A1NTUQ6Zl00CvLMMOoHdubm6zFIlWOf5+PsY/Kj09vdrU11QAwwGsv3jxIk21m2DZr10I0RXAuAcffPBgaWkpV69eTYfDcdiwUxY0w6xw+flX8L1xApjevXv3lREREaW6rofB93aPDUDQpEmTMgHgtddeqwBwEd/utZvpqK6uPgEAcXFxkA94NwB9unfvjrNnz4LklwDcf08iIqv66Zs2bXrl4YcfxooVKxAbG7uqrq5uAYA2TdOEqqpGYIi2tjbl6aeffu/YsWPv5uTk7JaC1wHg4Pnz542MwoVvTx+21dbWYvjw4WLixIl+2dnZ9lGjRgmSTE1NRUpKCkwFTGiaxtTU1OXTpk3707Bhw/6g67pDipnT4biuj7qut+Lbk3Vf1tTUXI9qu91Pjq1QFEUBgJaWFgBo8yGOQ8eNGxcAAOvXr/8QwBUfYygAKL169eoCABcuXACAWtn2hOGv0+kMNO1KiPDw8F4A4rZv3/7R1KlTR0+bNu1ht9u9r1+/fqitrQXJgwDarRC6/QjPzs4+QJIffPCB9/aQmSAA43ft2mW0e1QGoi8CAPyLsZccExNTC2BlRkbGRdOyYJCP2csBIN6UAZzCd7cBbQCijYp/dXU1ExMTz6SmptaMHj36f9LS0vYlJCRsl6mxIWSdu3fv/g5J7t+/nwC2AShMTk6+SJKff/45AWRLYbD7+fndAeDf5BJnLoCCyZMnt5JkdnZ2C4B/F0KEm1Pu+Pj4rST55ZdfEsBWAK+mpaVdMo3raDn7KwDuSEpK+m+S3LBhAwG8DuCtHTt2UBbpjgC408vvcFVV15HkuXPnjMp+p5uMf0RcXNyHJNnQ0EBVVfcCWBQXF3fG+Jv0yxABPwB5LS0tRmFxN4BlTzzxxGWSXLx4sS5F3GGFy+1Hp5SUlJq6ujoWFxdTpsZ2H+0iIyMj/0iSWVlZX5mr5jfJFroPGzasxlhTnjp1iiTZ3NxMl8tlrCd9pfa9SkpKSJI5OTmnZOageLUZZqxvfVFWVkZcPwdgNwnSCKPqb17jkmR8fPzfZMDZ5CRsFBmNI7h95s2b1yhT7/MAYmStwCx4vy0uLqa3v5qmEcCfvSr1QQAeXb16NY3Cm3HQ55133iGAp+SxZTNhKSkpfzUddkrFjYevzAQCeGjp0qXfsYckY2NjTwD4leGDLCL2HTdunNtoY+zWSHFcIHdsFCtcfuZ1vO9Eqs3m7/F47sb1k2qX/f3997W2tl7BjWfpBYDOzzzzzIVJkyZh0KBBCwEsB3AJvl9AETabLcDj8dwRFRW1ctasWb8JCgpSzp07d62wsPC/Wltb8xRFadR1/ZqPXYbgAQMGbI2Pjw/+6quv9ldVVT0r01ezuPRJSUn5Y9euXXVd11WzDaqq6kePHm3+7LPPRgO4KlNuxWazhXo8nuTk5OSXMjIyEl0uFxoaGtqKior+dPXq1VdUVT0jj7r68ieoT58+vx8yZMjdx48fP1JVVTVF9m20VW02WyfZf97YsWPjXS4X6urqWvPy8jYCWCyEuEDS8FdVFKWzruv//OSTTy5OTk7uqWkaPv3007qysrJ8RVH+LI8ym8/rB3Tu3HnRI488knLo0KG2ffv2ZQI4C98vP6mqqoZqmpaclpa2cOTIkX39/f3R0NDQUVxc/G5TU9PLqqrWa5rWLH1QVFUN0TStX1JSUvH48eP7BwYG4uDBg1cKCgpeBbBe2u+2Qug2EwD5N5sMPuNtMe8XP4TT6Qxoa2sbIGeXvUKIK7d4IISiKC5d1wPljOfA9bPwzYqiXNV13dd6Uqiq6qdpml2mpe02m63d4/G4vcTF5fF47LJf71nJA6BZVVW3pmntuPHlmAD5wk6Q9NnbHp9vHaqq6tA0zU/64PZhk1FfCZB9G/23ALiqKEqzD39tpvbGUqoFwFUhRLP3yzpCCDtJpxyXDulfG27+pqRR3DXsUWVd4Yq0x/taVQjhIhksC8L+ABpM9ljBf5sKwI8pIBr75L5E4vvu+UNeG/a+hv+AL7yFH8qPtOfHjtOP6V/Bja8D6z/B2Nys/1u9Xv33tLf4GfF/LC4GCJwByWIAAAAASUVORK5CYII=", +cc._loaderImage="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAAlAAD/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjM4MDBEMDY2QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjM4MDBEMDY1QTU1MjExRTFBQTAzQjEzMUNFNzMxRkQwIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2RTk0OEM4OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2RTk0OEM5OERCNDExRTE5NEUyRkE3M0M3QkE1NTlEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQADQkJCQoJDQoKDRMMCwwTFhENDREWGhUVFhUVGhkUFhUVFhQZGR0fIB8dGScnKionJzk4ODg5QEBAQEBAQEBAQAEODAwOEA4RDw8RFA4RDhQVERISERUfFRUXFRUfKB0ZGRkZHSgjJiAgICYjLCwoKCwsNzc1NzdAQEBAQEBAQEBA/8AAEQgAyACgAwEiAAIRAQMRAf/EALAAAAEFAQEAAAAAAAAAAAAAAAQAAgMFBgcBAQEAAwEBAAAAAAAAAAAAAAAAAQMEAgUQAAIBAgIEBwoLBgQGAwAAAAECAwAEEQUhMRIGQVFxsTITFGGBwdEiQlKSMzWRoeFicqKyI1NzFYJjJDQWB9KjVCbxwkNkJWXik3QRAAIBAgMFBQcDBQEAAAAAAAABAhEDIRIEMUFRcTJhwVIUBZGhsSJyEzOB0ULhYpIjUxX/2gAMAwEAAhEDEQA/AMJSpUqAVKlXuFAeUq9wpUB5XuFe4V6ooDzZHDox0CnGMinzwl7Z8NajaHeoO3vmTBZBtp9YUIqTEV5ROxHKnWRnaU8VRMhFBUjpV7hSoSeUq9pUB5Sr2lhQHlKvcK8oBV7hSFSRrtaKAZs07YNPM1pG2xJIAw1jSeandry/8X4m8VCKkWwaWwam7Xl/4v1W8VLtmX/i/VbxUoKkWwakSM407tmX/i/VbxUmzGwjQsjdY41IARie/U0IbZO0kNtCXnOCkEBeFu4KI3Bs7DNb27ya+jDx3kJeEnpJJEcQVbWDsk17u5urd591ucZkWhym2Vnd9RkCDEpFxDRpbw0bunu5mlp2De2FMLYXOD2wB2xbOeraUcYGJ72mlSUiqzzdzMd3Z3mixltA2yzcK/NlHM1DQyRXce1HocdNOEfJXZ88y9ZojOqhiBszIRiHQ8Y4cK5TvHuzLljHNMqxNoDjLFraHHnjPxcNCGVbxEUzYNTx5jZSxhpW6qTzlwJ+DCvO2Zf+L9VvFSgqyHYNLYNTdssPxfibxUu15f8Ai/VPiqCakOwa82DU/a8v/F+JvFTDdWPBL8R8VKCvYRYV5UzoMAy6QdIIqI0B4KJtxiRQwou16QoGUkntH5Tz0RbZbmF2hktraSVBo2lUkY8tDye0flPPXTslVUyiyVRsjqUOA4yMT8dW2ram2m6UVTNq9S7EIyUVJydMTn/6DnP+im9Wl+g5z/opvVrpteEhQWY4AaSTwAVf5WPiZh/9S5/zj7zltzlmYWkfWXNvJDGTgGcYDHirR7i7mSbwXParsFMrgb7w6jKw/wCmnc9I14kF3vpvCljbMyWMOJL4aEiB8qU/ObUK7HYWVrl1pFZWiCOCBQqKOLjPGTrNZZqKbUXVHq2nNwTuJRk1VpbgXN8s7Rk5ym0UQQzhIG2NAjhxHWbI+gCBVjBBFbwxwQqEiiUJGg1BVGAFe7dV28WYLYZFmF2Th1UD7JGjymGyn1iK5OyzIBGB1HgrLZhamzumQAGJwSqnSCh1q3GOCodxt4cxurdcpzuN4cyhiWaF5Bg09udUmnWw1H/jV9nFuJ7Quo+8h8peThFA+047vduyMtk7fYqTl07YFdfUufMPzT5p71UdtlmYXaGS2t3mQHAsgxANdadYJopLe4QS2867EsZ4QfCNYrCFbjdDPmgkYyWFxgVf04ifJf6ScNdRUW1XBb6FU5TjF5EpSSrGu/s5lN+g5z/opvVpfoOc/wCim9WtdHnatvObJXDW7xLGhB8nrPaY9/HCr+tEdPCVaSeDoYLnqF63lzW4/PFSW3ecxbI84VSzWUwUaSdg0DXXK5nvAipnd6qgKvWnQO7pri9ZUEmm3Vl2j1kr8pRlFRyquBNZjGxQ/S56Y1S2fu9OVueon11Szahoou06QoQUXadIVCD2FJJ7R+U89dMydv8Axdn+TH9muZye0flPPXQstlK5Tbka1gUjlC1q0vVLkeb6r+O3Tx9xcY1nt8c0NrZCyiOE1108NYjGv1joo7Js1jzKyScYLIvkzL6LDwHXVJksH9Sb49dKNq0tj1jA6uriOCL+02FWX7iVtZX1/AzaHTyeoauKn2MX9W79zebiZCuR5MjSrhfXuEtwTrUeZH+yNfdrRNcxI6IzhXlJEak6WIGJ2Rw4ChWnChndtlVBLMdQA0k1gbXNMzzDfDLs6mjaPKppJbWwJ1bOwwxw43OnHh71YT3DpfWUJmFlb5jHHDdeXBHIsrRea5TSqvxqG04cNN62vetoCS4tre5mgnkGE9q+3DKOkuI2WX6LDQRRHWDh1UCtwj7QRg2wdl8Djgw1qe7XvW0BQ3kfZ7mSLgU+T9E6RVbnuVrnWVSWqj+Lt8ZbRuHEdKPkYVcZ2MJY5fSGyeVar45+rkWQHAqccalPE5km1htWK5nK4Wnt5FuUBUwOMG4nGkA/BXUrW4S6torlOjMgcd/xVn7rLo7zKs0uEjCNeSvdwoBhgsZxX1l2j36k3Lu+uyprdj5Vs5A+i/lD48a0aaVJOPi7jB6lbzWozpjB48pf1NDXNN4vfl7+Z4BXS65pvF78vfzPAK71XTHmZ/S/yT+jvJ7L3fHytz1E+upbL+Qj5W56jfXWRnsIYKLtekKEFGWvSFQgyjk9o/Keet3YthlMP/5x9msJJ7R+U89biyb/AMXEv7gD6tadL1T+kwepRrC39ZkLDMbiwMvUHRPG0bjlGg8ore/23sxBldxfMPLupNhT8yL/AORNZbdzJ484scytxgLqJY5LZj6Q2sV5G1Vud1mjjyG0ij0NEGSZToKyhjtqw4waztuiXA3qKTbSxltfGhbZlE95ZtZqxVbgiOZhrER9ph3Svk9+pJILZ4Y4DGBFCUMKjRsGPobPFhUfW0NJmljE2xJcIrcI2vFUEln1lRXd6lrazXT9GCNpD+yNqoI7mOVduNw6nzlOIoPOUa6yye1XXcbMR5GdQ3xY0BSbj31/FcTQZirJ+q431q7anbHCTZ72Bw7lbPrKBMcBWNNgbMBBh+bsjBdni0VJ1lARZs6yWiupxCuMDy6KpS2IwOo6DTr3Mre3e5tZZVUM4ZBjqOOJoWO4jkXajcOOMHGgDISvWIrdAkKR80+TzVl908bPPL3LzxOuHdifxVfiTAg92qI/w+/8gGgSyN/mR7XPVlp0lF/3L3mbVKtu5Hjbk/8AHE2Fc03i9+Xv5ngFdKNc13i9+Xv5ngFaNV0x5nn+l/kn9HeEWXu+PlbnqJ9dS2Xu9OVueon11kZ7CGCjLXpCgxRlr0hUIPYUcntH5Tz1s8vb+Bt1/dqPirGSe0flPPWusG/g4Py15q06XqlyMWvVYQ+ruI9xJOqzO9hOto/sP8tbGOFIrmWeM7IuMDMnAXXQJOUjQeOsJk0nY96ip0CYunrjaHx1t+srPJUbXBm2LrFPikwTOb+T+VhbZxGMrDXp83x1QSy2tucJpUjPETp+Cn5/ftaRvKvtp3Kx48HG3erHMzOxZiWZtLMdJNQSbbL71Vk6yynViOkqnEEfOWtPbXi3EQkGg6mXiNckjeSJxJGxR10qw0GtxuxmvbImD4CZMFlA4fRfv0BqesqqzTMZNMEDbIHtHH2QeCiZJSqMQdOGiue53mz3czQwsRbIcNHnkec3c4qAMuriz68gTIToxwOOnlp0MjxMJYW741Gs3RVldtbygE/dMcHX/moDaxTiWNZB53B3arb8/wC+4SOF4sf/AKxU9kcBsfOGHfoUHtG/RbzY5Die5HHhXdvavqiZ9Q8Jdlq4/gbKua7xe/L38zwCuhpf2Uk/Zo50kmwJKIdogDjw1VzzeL35e/meAVp1LTgqY4nn+mRauzqmqwrjzCLL3fHytz1E+upLL+Qj5W56jfXWRnroYKLtekKEFF2vSFQg9hSSe0flPPWosm/hIfoLzVl5PaPynnrRWb/w0X0F5q06XqlyM2sVYx5gmbFre/t71NY2T+0h8VbSO5SWNJUOKSAMp7jDGspmMPaLRlXS6eWve1/FRO7WYdbZm1Y/eW/R7qHxHRXGojlm3ulid6aVbaW+OALvgCLq2Hm9WxHKWqjhj6xsK1e8dm15l4niG1LZkswGsxtrPeOmsvayBJA1VItlWjptLuTdPMo7LtjRDq9naK4+WF9IrUW7BaHOljGqVHB7w2hzVoZt87d8vaNYSLl02CcRsDEbJbj71Uu7UBkvJ7/D7q2QoDxySaAO8MTXdxRVMpRp5XZOWdF/ms7R5XdyKfKWJsO/5PhrG5XlNxmEywW6bTnTxAAcJNbGSMXkM1pjgbiNo1PziPJ+Os7u7m/6ReM00ZOgxSpqYYHT3wRXMKN4ll9zUG4bQfNshu8sZVuEA2hirA4qe/VOwwrVbzbww5mI44UKRRYkbWG0S3JWctbd7u5WFfOOLHiUdJqmaipfLsIsObhWe001lMkMVvJNjhghIALMcBxCs7fxXQmkupx1bXDswGPlaTidVaEyKNXkoo4eBV+Sq7L7Vs9zcBgeyQ4GQ/MB1crmoim2orezqcowTuSeEY48jQ7oZX2PLzdyLhNd6RjrEY6I7+uspvH78vfzPAK6UAAAFGAGgAcArmu8Xvy9/M8ArTfio24RW5nnaG67uou3H/KPuqT2X8hHytz1G+upLL3enK3PUb66ys9RDBRdr0hQgou06QqEGUkntH5Tz1e238vF9BeaqKT2j8p56vbb+Xi+gvNWjTdUuRn1XTHmTh8KrJTJlt8t1CPIY44cGnpJVjTJYkmjaN9Ib4u7V923njTethRauZJV3PaW1rfLIiXEDYg6R4VYc9CXW7thfOZbKdbGZtLW8uPVY/u3GrkNUkM9zlcxUjbhfWOA90cRq4gv4LhdqN+VToNYWmnRm9NNVWNTyHc6VWBv8wt4YeHqm6xyPmroq1Z7WGFLSxTq7WLSuPSdjrkfumq5yHXDUeA92oO2SKpVumNAaoJLMXH3myp0rpJ4uKhc3tbDM5BMri1zAj79j7KTiY8TcdBpcsith0286o+sPCagEX9Pzg4zXUCp6QYse8oouCG3tk6m1BYv05W6T+IdyolxbHDAAa2OgDlNCz3ryN2WxBd5PJMg1t81eId2ukqnLlTBbfcuY+9uJLiRcvtPvHdsHK+cfRHcHDWsyawjyy0WBcDI3lTP6TeIcFV+S5OmXx9bJg1048o8Cj0V8Jq2DVu09nL80up7OxHi+oal3P8AXB/IsZS8T/YOV65zvCcc7vfzPAK3ivWCz445zeH954BXOr6I8yfSfyz+jvCLP3fHytz1G+upLP3fHytz1E+usbPaQ0UXadIUIKLtekKhB7Ckk9o/Keer22/l4/oLzVRSe0flPPV7b/y8X0F5q0abqlyM+q6Y8yQsBTDMor1o8aiaE1pbluMqS3sbLLHIhSRQyngqukhaJ9uBjo+H5aOa3ao2t34qouRlLajTalGP8v0IY8ylXQ+PKPFU/bYXOLPge6CKia0LaxTOxHu1Q7cuBd9yPEJ7TbjXKO8CajbMIF6CNIeNvJHjqIWJ7tSpYkalqVblwIdyG+RGXur0hXYJFxal+Dhq5y3slkv3Y2pD0pTr+QUClpJRUdo9XW4OLrTHtM16cZLLWkeC7y4jvlNEpcRtw1Ux27Ci448NZrTFy3nn3IQWxlgGrDZ3pza7/M8ArZo+ArF5171uvp+CqdV0R5l/psUrs2vB3hdl7vTlbnqJ9dS2Xu+PlbnqJ9dY2eshooq16QoQUXa9IVCD2FLJ7RuU89WNtmUSQqkgYMgw0accKrpPaPynnrZWG4Vi+VWmY5tnMWXG+XrIYnA0rhj0mdcTgdNdwnKDqjmduM1SRR/qlr8/4KX6pa8T/BVzDuLZXudRZblmbxXcPUNPc3KqCIwrbOzgrHEnHjoyD+3eSXkht7DeKG4umDGOJVUklfouThXfmbnZ7Cvy1vt9pmv1W1+d8FL9VteJvgq5yrcOGfLmzHN80iyyETPbptAEFo2ZG8pmUa1OFNn3Ky6W/sbDKM5hv5bx2WTZA+7RF2y52WOPJTzE+z2Dy1vt9pT/AKpacTerS/U7Tib1a04/t7kDXPY03jhN0W6sQ7K7W3q2dnrMccaDy/8At80kuZfqWYxWNtlcvUPPhiGYhWDeUy7IwYU8xPs9g8tb7faUn6pacTerTxm9oOBvVq3v9z927aynuId44LiWKNnjhAXF2UYhRg516qpsryjLr21665zFLSTaK9U2GOA87SwqY37knRU+BzOzags0s1Oyr+BKM6sxwP6tSDPLMen6vy0rvdm3Sxlu7K/S7WDDrFUDUTxgnTU826eXW7KlxmqQuwDBXUKcD+1Xee/wXuKX5XDGWLapSVcOyhEM/seJ/V+WnjeGx4pPV+Wkm6kKZlFay3Jlt7iFpYZY8ASVK6DjtDDA0f8A0Tl340/1f8Ndx8xJVWXB0KbktFFpNzdVXAC/qOwA0CQni2flrO3Vwbm5lnI2TKxbDirX/wBE5d+NcfV/wVR7xZPa5U9utvI8nWhmbbw0YEAYYAVxfhfy5rlKR4Fulu6X7mW1mzT8S4Yis/5CPlbnqJ9dSWfu9OVueon11mZvQ2i7XpChKKtekKhBlNJ7R+U89bDfGTb3a3ZX0Lcj6kdY+T2j8p560288m1kWQr6MJ+ylSAr+2cnV5renjs3H1loX+3j9XvbbtxLN9lqW4UnV5jdnjtXHxihtyZNjeSBu5J9k1BJe7xy7W5CJ/wCzuD/mTVTf2+fq97LJuLrPsNRueS7W6aJ/38x+vLVXuY+xvHaNxbf2GoCezf8A36j/APsSf8w1sLnqczTefJluYoLm5uo5F61sBshItP1cNFYe1f8A3ir/APfE/wCZUe9bB94r5jwuPsrQFhmG4l/Z2M17HdW90tuu3IkTHaCjWdIw0VVZdks9/C06yJFEp2dp+E1bbqybGTZ8vpQD7L1XRv8A7blT96Oda7tpNuuNE37Cq9KSisjyuUoxrStKllHbLlWTXsMs8chuSuwEPDqwoLe5y+YRE/gLzmqRekvKKtd4327yM/ulHxmrHJStySWVRyrjxKI2XC/CTlnlPPKTpTdFbP0L1bgrf5Lp0G3dPhQHwV0S1lzBsns3sESR8Crh9WAJGjSOKuU3E+zdZQ3oJh8IArdZXFDmOTpHa3i2+YrI2KtKy4ricBsBuHHgFXSo440+Wa2qqxjvM9uMoy+WvzWpLCWWWE28HxL6e43ojgkeSCBY1Ri5BGIUDT51cl3vm276BBqSEH4WbxV0tlkyXJcxTMb+OW6uY9mGHrCzDQwwAbTp2uKuTZ9N1uYsfRRR8WPhrm419mSSjRyiqxVK7y23B/ftuTm2oSdJyzNVw3BFn7vTlbnqF9dS2fu9OVueon11lZuQ2iLdsGFD05H2dNQGV0ntG5Tz1dWm9N1b2kVq8EVwsI2UaQaQOKhmitZGLOmk68DhSFvY+gfWNSAg7z3Qvo7yKCKIohiaNR5LKxx8qpxvjcqS0VpbxvwOAcRQPZ7D0G9Y0uz2HoH1jUCpLY7zXlpbm3eKO5QuzjrBqZji3x17PvNcyT288VvDBJbMWUovS2hslW7mFQ9nsPQPrGl2ew9A+saCod/WNxtbYsrfb17WBxx5ddD2281xC88klvDcSXEnWuzrqOGGC9zRUPZ7D0G9Y0uzWHoH1jQVCLreq6ntZbaO3it1mGy7RjTs1X2mYy20ZiCq8ZOODcdEdmsPQb1jS7PYegfWNdJuLqnQiSUlRqpFLmryxtH1Ma7Qw2gNNPOdSt0oI27p007s9h6B9Y0uz2HoH1jXX3Z+I4+1b8IJdX89xLHKQFMXQUahpxoiPN5P+onfU+A0/s9h6DesaXZ7D0D6xpG7OLbUtu0StW5JJx2bBsmbtiSiEk+cxoCWWSaVpZOk2vDVo0VYdnsPQb1jSNvZcCH1jSd2c+p1XAmFqEOmOPEfaH+BQd1ueo211IzrgFUYKNAAqI1WztCpUqVCRUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoBUqVKgFSpUqAVKlSoD/9k=",cc.loader.loadBinary=function(a,b){var c=this,d=this.getXMLHttpRequest(),e="load "+a+" failed!";d.open("GET",a,!0),cc.loader.loadBinary._IEFilter?(d.setRequestHeader("Accept-Charset","x-user-defined"),d.onreadystatechange=function(){if(4===d.readyState&&200===d.status){var a=cc._convertResponseBodyToText(d.responseBody);b(null,c._str2Uint8Array(a))}else b(e)}):(d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined"),d.onload=function(){4===d.readyState&&200===d.status?b(null,c._str2Uint8Array(d.responseText)):b(e)}),d.send(null)},cc.loader.loadBinary._IEFilter=/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent)&&window.IEBinaryToArray_ByteStr&&window.IEBinaryToArray_ByteStr_Last,cc.loader._str2Uint8Array=function(a){if(!a)return null;for(var b=new Uint8Array(a.length),c=0;cc;c++)for(var d=0;256>d;d++)b[String.fromCharCode(c+256*d)]=String.fromCharCode(c)+String.fromCharCode(d);var e=IEBinaryToArray_ByteStr(a),f=IEBinaryToArray_ByteStr_Last(a);return e.replace(/[\s\S]/g,function(a){return b[a]})+f}}var cc=cc||{},ClassManager={id:0|998*Math.random(),instanceId:0|998*Math.random(),getNewID:function(){return this.id++},getNewInstanceId:function(){return this.instanceId++}};switch(function(){var a=/\b_super\b/;cc.Class=function(){},cc.Class.extend=function(b){function c(){this.__instanceId=ClassManager.getNewInstanceId(),this.ctor&&this.ctor.apply(this,arguments)}var d=this.prototype,e=Object.create(d),f=ClassManager.getNewID();ClassManager[f]=d;var g={writable:!0,enumerable:!1,configurable:!0};e.__instanceId=null,c.id=f,g.value=f,Object.defineProperty(e,"__pid",g),c.prototype=e,g.value=c,Object.defineProperty(c.prototype,"constructor",g),this.__getters__&&(c.__getters__=cc.clone(this.__getters__)),this.__setters__&&(c.__setters__=cc.clone(this.__setters__));for(var h=0,i=arguments.length;i>h;++h){var j=arguments[h];for(var k in j){var l="function"==typeof j[k],m="function"==typeof d[k],n=a.test(j[k]);if(l&&m&&n?(g.value=function(a,b){return function(){var c=this._super;this._super=d[a];var e=b.apply(this,arguments);return this._super=c,e}}(k,j[k]),Object.defineProperty(e,k,g)):l?(g.value=j[k],Object.defineProperty(e,k,g)):e[k]=j[k],l){var o,p,q;if(this.__getters__&&this.__getters__[k]){q=this.__getters__[k];for(var r in this.__setters__)if(this.__setters__[r]===q){p=r;break}cc.defineGetterSetter(e,q,j[k],j[p]?j[p]:e[p],k,p)}if(this.__setters__&&this.__setters__[k]){q=this.__setters__[k];for(var r in this.__getters__)if(this.__getters__[r]===q){o=r;break}cc.defineGetterSetter(e,q,j[o]?j[o]:e[o],j[k],o,k)}}}}return c.extend=cc.Class.extend,c.implement=function(a){for(var b in a)e[b]=a[b]},c}}(),cc.defineGetterSetter=function(a,b,c,d,e,f){if(a.__defineGetter__)c&&a.__defineGetter__(b,c),d&&a.__defineSetter__(b,d);else{if(!Object.defineProperty)throw new Error("browser does not support getters");var g={enumerable:!1,configurable:!0};c&&(g.get=c),d&&(g.set=d),Object.defineProperty(a,b,g)}if(!e&&!f)for(var h=null!=c,i=void 0!=d,j=Object.getOwnPropertyNames(a),k=0;k=b.x||a.y>=b.y||a.x+a.width<=b.x+b.width||a.y+a.height<=b.y+b.height):!1},cc.rectGetMaxX=function(a){return a.x+a.width},cc.rectGetMidX=function(a){return a.x+a.width/2},cc.rectGetMinX=function(a){return a.x},cc.rectGetMaxY=function(a){return a.y+a.height},cc.rectGetMidY=function(a){return a.y+a.height/2},cc.rectGetMinY=function(a){return a.y},cc.rectContainsPoint=function(a,b){return b.x>=cc.rectGetMinX(a)&&b.x<=cc.rectGetMaxX(a)&&b.y>=cc.rectGetMinY(a)&&b.y<=cc.rectGetMaxY(a)},cc.rectIntersectsRect=function(a,b){var c=a.x+a.width,d=a.y+a.height,e=b.x+b.width,f=b.y+b.height;return!(ce&&(d=c.childNodes[e],1!==d.nodeType);e++);return b=null,this._parseNode(d)},_parseNode:function(a){var b=null,c=a.tagName;if("dict"===c)b=this._parseDict(a);else if("array"===c)b=this._parseArray(a);else if("string"===c)if(1===a.childNodes.length)b=a.firstChild.nodeValue;else{b="";for(var d=0;dc;c++){var e=a.childNodes[c];1===e.nodeType&&b.push(this._parseNode(e))}return b},_parseDict:function(a){for(var b={},c=null,d=0,e=a.childNodes.length;e>d;d++){var f=a.childNodes[d];1===f.nodeType&&("key"===f.tagName?c=f.firstChild.nodeValue:b[c]=this._parseNode(f))}return b}}),cc.saxParser=new cc.SAXParser,cc.plistParser=new cc.PlistParser,cc._txtLoader={load:function(a,b,c,d){cc.loader.loadTxt(a,d)}},cc.loader.register(["txt","xml","vsh","fsh","atlas"],cc._txtLoader),cc._jsonLoader={load:function(a,b,c,d){cc.loader.loadJson(a,d)}},cc.loader.register(["json","ExportJson"],cc._jsonLoader),cc._jsLoader={load:function(a,b,c,d){cc.loader.loadJs(a,d)}},cc.loader.register(["js"],cc._jsLoader),cc._imgLoader={load:function(a,b,c,d){cc.loader.cache[b]=cc.loader.loadImg(a,function(a,c){return a?d(a):(cc.textureCache.handleLoadedTexture(b),void d(null,c))})}},cc.loader.register(["png","jpg","bmp","jpeg","gif","ico","tiff","webp"],cc._imgLoader),cc._serverImgLoader={load:function(a,b,c,d){cc.loader.cache[b]=cc.loader.loadImg(c.src,function(a,c){return a?d(a):(cc.textureCache.handleLoadedTexture(b),void d(null,c))})}},cc.loader.register(["serverImg"],cc._serverImgLoader),cc._plistLoader={load:function(a,b,c,d){cc.loader.loadTxt(a,function(a,b){return a?d(a):void d(null,cc.plistParser.parse(b))})}},cc.loader.register(["plist"],cc._plistLoader),cc._fontLoader={TYPE:{".eot":"embedded-opentype",".ttf":"truetype",".ttc":"truetype",".woff":"woff",".svg":"svg"},_loadFont:function(a,b,c){var d=document,e=cc.path,f=this.TYPE,g=document.createElement("style");g.type="text/css",d.body.appendChild(g);var h="";if(h+=isNaN(a-0)?"@font-face { font-family:"+a+"; src:":"@font-face { font-family:'"+a+"'; src:",b instanceof Array)for(var i=0,j=b.length;j>i;i++){var k=b[i];c=e.extname(k).toLowerCase(),h+="url('"+b[i]+"') format('"+f[c]+"')",h+=i===j-1?";":","}else c=c.toLowerCase(),h+="url('"+b+"') format('"+f[c]+"');";g.textContent+=h+"}";var l=document.createElement("div"),m=l.style;m.fontFamily=a,l.innerHTML=".",m.position="absolute",m.left="-100px",m.top="-100px",d.body.appendChild(l)},load:function(a,b,c,d){var e=this,f=c.type,g=c.name,h=c.srcs;cc.isString(c)?(f=cc.path.extname(c),g=cc.path.basename(c,f),e._loadFont(g,c,f)):e._loadFont(g,h),document.fonts?document.fonts.load("1em "+g).then(function(){d(null,!0)},function(a){d(a)}):d(null,!0)}},cc.loader.register(["font","eot","ttf","woff","svg","ttc"],cc._fontLoader),cc._binaryLoader={load:function(a,b,c,d){cc.loader.loadBinary(a,d)}},cc._csbLoader={load:function(a,b,c,d){cc.loader.loadCsb(a,d)}},cc.loader.register(["csb"],cc._csbLoader),window.CocosEngine=cc.ENGINE_VERSION="Cocos2d-JS v3.10",cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL=0,cc.DIRECTOR_STATS_POSITION=cc.p(0,0),cc.DIRECTOR_FPS_INTERVAL=.5,cc.COCOSNODE_RENDER_SUBPIXEL=1,cc.SPRITEBATCHNODE_RENDER_SUBPIXEL=1,cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA=1,cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP=0,cc.TEXTURE_ATLAS_USE_VAO=0,cc.TEXTURE_NPOT_SUPPORT=0,cc.RETINA_DISPLAY_SUPPORT=1,cc.RETINA_DISPLAY_FILENAME_SUFFIX="-hd",cc.USE_LA88_LABELS=1,cc.SPRITE_DEBUG_DRAW=0,cc.SPRITEBATCHNODE_DEBUG_DRAW=0,cc.LABELBMFONT_DEBUG_DRAW=0,cc.LABELATLAS_DEBUG_DRAW=0,cc.IS_RETINA_DISPLAY_SUPPORTED=1,cc.DEFAULT_ENGINE=cc.ENGINE_VERSION+"-canvas",cc.ENABLE_STACKABLE_ACTIONS=1,cc.ENABLE_GL_STATE_CACHE=1,cc.$=function(a){var b=this===cc?document:this,c=a instanceof HTMLElement?a:b.querySelector(a);return c&&(c.find=c.find||cc.$,c.hasClass=c.hasClass||function(a){return this.className.match(new RegExp("(\\s|^)"+a+"(\\s|$)"))},c.addClass=c.addClass||function(a){return this.hasClass(a)||(this.className&&(this.className+=" "),this.className+=a),this},c.removeClass=c.removeClass||function(a){return this.hasClass(a)&&(this.className=this.className.replace(a,"")),this},c.remove=c.remove||function(){return this.parentNode&&this.parentNode.removeChild(this),this},c.appendTo=c.appendTo||function(a){return a.appendChild(this),this},c.prependTo=c.prependTo||function(a){return a.childNodes[0]?a.insertBefore(this,a.childNodes[0]):a.appendChild(this),this},c.transforms=c.transforms||function(){return this.style[cc.$.trans]=cc.$.translate(this.position)+cc.$.rotate(this.rotation)+cc.$.scale(this.scale)+cc.$.skew(this.skew),this},c.position=c.position||{x:0,y:0},c.rotation=c.rotation||0,c.scale=c.scale||{x:1,y:1},c.skew=c.skew||{x:0,y:0},c.translates=function(a,b){return this.position.x=a,this.position.y=b,this.transforms(),this},c.rotate=function(a){return this.rotation=a,this.transforms(),this},c.resize=function(a,b){return this.scale.x=a,this.scale.y=b,this.transforms(),this},c.setSkew=function(a,b){return this.skew.x=a,this.skew.y=b,this.transforms(),this}),c},cc.sys.browserType){case cc.sys.BROWSER_TYPE_FIREFOX:cc.$.pfx="Moz",cc.$.hd=!0;break;case cc.sys.BROWSER_TYPE_CHROME:case cc.sys.BROWSER_TYPE_SAFARI:cc.$.pfx="webkit",cc.$.hd=!0;break;case cc.sys.BROWSER_TYPE_OPERA:cc.$.pfx="O",cc.$.hd=!1;break;case cc.sys.BROWSER_TYPE_IE:cc.$.pfx="ms",cc.$.hd=!1;break;default:cc.$.pfx="webkit",cc.$.hd=!0}cc.$.trans=cc.$.pfx+"Transform",cc.$.translate=cc.$.hd?function(a){return"translate3d("+a.x+"px, "+a.y+"px, 0) "}:function(a){return"translate("+a.x+"px, "+a.y+"px) "},cc.$.rotate=cc.$.hd?function(a){return"rotateZ("+a+"deg) "}:function(a){return"rotate("+a+"deg) "},cc.$.scale=function(a){return"scale("+a.x+", "+a.y+") "},cc.$.skew=function(a){return"skewX("+-a.x+"deg) skewY("+a.y+"deg)"},cc.$new=function(a){return cc.$(document.createElement(a))},cc.$.findpos=function(a){var b=0,c=0;do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent);return{x:b,y:c}},cc.INVALID_INDEX=-1,cc.PI=Math.PI,cc.FLT_MAX=parseFloat("3.402823466e+38F"),cc.FLT_MIN=parseFloat("1.175494351e-38F"),cc.RAD=cc.PI/180,cc.DEG=180/cc.PI,cc.UINT_MAX=4294967295,cc.swap=function(a,b,c){if(!cc.isObject(c)||cc.isUndefined(c.x)||cc.isUndefined(c.y))cc.log(cc._LogInfos.swap);else{var d=c[a];c[a]=c[b],c[b]=d}},cc.lerp=function(a,b,c){return a+(b-a)*c},cc.rand=function(){return 16777215*Math.random()},cc.randomMinus1To1=function(){return 2*(Math.random()-.5)},cc.random0To1=Math.random,cc.degreesToRadians=function(a){return a*cc.RAD},cc.radiansToDegrees=function(a){return a*cc.DEG},cc.radiansToDegress=function(a){return cc.log(cc._LogInfos.radiansToDegress),a*cc.DEG},cc.REPEAT_FOREVER=Number.MAX_VALUE-1,cc.nodeDrawSetup=function(a){a._shaderProgram&&(a._shaderProgram.use(),a._shaderProgram.setUniformForModelViewAndProjectionMatrixWithMat4())},cc.enableDefaultGLStates=function(){},cc.disableDefaultGLStates=function(){},cc.incrementGLDraws=function(a){cc.g_NumberOfDraws+=a},cc.FLT_EPSILON=1.192092896e-7,cc.contentScaleFactor=cc.IS_RETINA_DISPLAY_SUPPORTED?function(){return cc.director.getContentScaleFactor()}:function(){return 1},cc.pointPointsToPixels=function(a){var b=cc.contentScaleFactor();return cc.p(a.x*b,a.y*b)},cc.pointPixelsToPoints=function(a){var b=cc.contentScaleFactor();return cc.p(a.x/b,a.y/b)},cc._pointPixelsToPointsOut=function(a,b){var c=cc.contentScaleFactor();b.x=a.x/c,b.y=a.y/c},cc.sizePointsToPixels=function(a){var b=cc.contentScaleFactor();return cc.size(a.width*b,a.height*b)},cc.sizePixelsToPoints=function(a){var b=cc.contentScaleFactor();return cc.size(a.width/b,a.height/b)},cc._sizePixelsToPointsOut=function(a,b){var c=cc.contentScaleFactor();b.width=a.width/c,b.height=a.height/c},cc.rectPixelsToPoints=cc.IS_RETINA_DISPLAY_SUPPORTED?function(a){var b=cc.contentScaleFactor();return cc.rect(a.x/b,a.y/b,a.width/b,a.height/b)}:function(a){return a},cc.rectPointsToPixels=cc.IS_RETINA_DISPLAY_SUPPORTED?function(a){var b=cc.contentScaleFactor();return cc.rect(a.x*b,a.y*b,a.width*b,a.height*b)}:function(a){return a},cc.ONE=1,cc.ZERO=0,cc.SRC_ALPHA=770,cc.SRC_ALPHA_SATURATE=776,cc.SRC_COLOR=768,cc.DST_ALPHA=772,cc.DST_COLOR=774,cc.ONE_MINUS_SRC_ALPHA=771,cc.ONE_MINUS_SRC_COLOR=769,cc.ONE_MINUS_DST_ALPHA=773,cc.ONE_MINUS_DST_COLOR=775,cc.ONE_MINUS_CONSTANT_ALPHA=32772,cc.ONE_MINUS_CONSTANT_COLOR=32770,cc.LINEAR=9729,cc.REPEAT=10497,cc.CLAMP_TO_EDGE=33071,cc.MIRRORED_REPEAT=33648,cc.BLEND_SRC=cc.SRC_ALPHA,cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA&&(cc.BLEND_SRC=cc.ONE)}),cc.BLEND_DST=cc.ONE_MINUS_SRC_ALPHA,cc.checkGLErrorDebug=function(){if(cc.renderMode===cc.game.RENDER_TYPE_WEBGL){var a=cc._renderContext.getError();a&&cc.log(cc._LogInfos.checkGLErrorDebug,a)}},cc.DEVICE_ORIENTATION_PORTRAIT=0,cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT=1,cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN=2,cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT=3,cc.DEVICE_MAX_ORIENTATIONS=2,cc.VERTEX_ATTRIB_FLAG_NONE=0,cc.VERTEX_ATTRIB_FLAG_POSITION=1,cc.VERTEX_ATTRIB_FLAG_COLOR=2,cc.VERTEX_ATTRIB_FLAG_TEX_COORDS=4,cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX=cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS,cc.GL_ALL=0,cc.VERTEX_ATTRIB_POSITION=0,cc.VERTEX_ATTRIB_COLOR=1,cc.VERTEX_ATTRIB_TEX_COORDS=2,cc.VERTEX_ATTRIB_MAX=3,cc.UNIFORM_PMATRIX=0,cc.UNIFORM_MVMATRIX=1,cc.UNIFORM_MVPMATRIX=2,cc.UNIFORM_TIME=3,cc.UNIFORM_SINTIME=4,cc.UNIFORM_COSTIME=5,cc.UNIFORM_RANDOM01=6,cc.UNIFORM_SAMPLER=7,cc.UNIFORM_MAX=8,cc.SHADER_POSITION_TEXTURECOLOR="ShaderPositionTextureColor",cc.SHADER_POSITION_TEXTURECOLORALPHATEST="ShaderPositionTextureColorAlphaTest",cc.SHADER_POSITION_COLOR="ShaderPositionColor",cc.SHADER_POSITION_TEXTURE="ShaderPositionTexture",cc.SHADER_POSITION_TEXTURE_UCOLOR="ShaderPositionTexture_uColor",cc.SHADER_POSITION_TEXTUREA8COLOR="ShaderPositionTextureA8Color",cc.SHADER_POSITION_UCOLOR="ShaderPosition_uColor",cc.SHADER_POSITION_LENGTHTEXTURECOLOR="ShaderPositionLengthTextureColor",cc.UNIFORM_PMATRIX_S="CC_PMatrix",cc.UNIFORM_MVMATRIX_S="CC_MVMatrix",cc.UNIFORM_MVPMATRIX_S="CC_MVPMatrix",cc.UNIFORM_TIME_S="CC_Time",cc.UNIFORM_SINTIME_S="CC_SinTime",cc.UNIFORM_COSTIME_S="CC_CosTime",cc.UNIFORM_RANDOM01_S="CC_Random01",cc.UNIFORM_SAMPLER_S="CC_Texture0",cc.UNIFORM_ALPHA_TEST_VALUE_S="CC_alpha_value",cc.ATTRIBUTE_NAME_COLOR="a_color",cc.ATTRIBUTE_NAME_POSITION="a_position",cc.ATTRIBUTE_NAME_TEX_COORD="a_texCoord",cc.ITEM_SIZE=32,cc.CURRENT_ITEM=3233828865,cc.ZOOM_ACTION_TAG=3233828866,cc.NORMAL_TAG=8801,cc.SELECTED_TAG=8802,cc.DISABLE_TAG=8803,cc.arrayVerifyType=function(a,b){if(a&&a.length>0)for(var c=0;cc;c++)if(a[c]===b){a.splice(c,1);break}},cc.arrayRemoveArray=function(a,b){for(var c=0,d=b.length;d>c;c++)cc.arrayRemoveObject(a,b[c])},cc.arrayAppendObjectsToIndex=function(a,b,c){return a.splice.apply(a,[c,0].concat(b)),a},cc.copyArray=function(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b+=1)d[b]=a[b];return d},cc._tmp.PrototypeColor=function(){var a=cc.color;a._getWhite=function(){return a(255,255,255)},a._getYellow=function(){return a(255,255,0)},a._getBlue=function(){return a(0,0,255)},a._getGreen=function(){return a(0,255,0)},a._getRed=function(){return a(255,0,0)},a._getMagenta=function(){return a(255,0,255)},a._getBlack=function(){return a(0,0,0)},a._getOrange=function(){return a(255,127,0)},a._getGray=function(){return a(166,166,166)},a.WHITE,cc.defineGetterSetter(a,"WHITE",a._getWhite),a.YELLOW,cc.defineGetterSetter(a,"YELLOW",a._getYellow),a.BLUE,cc.defineGetterSetter(a,"BLUE",a._getBlue),a.GREEN,cc.defineGetterSetter(a,"GREEN",a._getGreen),a.RED,cc.defineGetterSetter(a,"RED",a._getRed),a.MAGENTA,cc.defineGetterSetter(a,"MAGENTA",a._getMagenta),a.BLACK,cc.defineGetterSetter(a,"BLACK",a._getBlack),a.ORANGE,cc.defineGetterSetter(a,"ORANGE",a._getOrange),a.GRAY,cc.defineGetterSetter(a,"GRAY",a._getGray),cc.BlendFunc._disable=function(){return new cc.BlendFunc(cc.ONE,cc.ZERO)},cc.BlendFunc._alphaPremultiplied=function(){return new cc.BlendFunc(cc.ONE,cc.ONE_MINUS_SRC_ALPHA)},cc.BlendFunc._alphaNonPremultiplied=function(){return new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA)},cc.BlendFunc._additive=function(){return new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE)},cc.BlendFunc.DISABLE,cc.defineGetterSetter(cc.BlendFunc,"DISABLE",cc.BlendFunc._disable),cc.BlendFunc.ALPHA_PREMULTIPLIED,cc.defineGetterSetter(cc.BlendFunc,"ALPHA_PREMULTIPLIED",cc.BlendFunc._alphaPremultiplied),cc.BlendFunc.ALPHA_NON_PREMULTIPLIED,cc.defineGetterSetter(cc.BlendFunc,"ALPHA_NON_PREMULTIPLIED",cc.BlendFunc._alphaNonPremultiplied),cc.BlendFunc.ADDITIVE,cc.defineGetterSetter(cc.BlendFunc,"ADDITIVE",cc.BlendFunc._additive)};var cc=cc||{};switch(cc._tmp=cc._tmp||{},cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.color=function(a,b,c,d,e,f){if(void 0===a)return new cc.Color(0,0,0,255,e,f);if(cc.isString(a)){var g=cc.hexToColor(a);return new cc.Color(g.r,g.g,g.b,g.a)}return cc.isObject(a)?new cc.Color(a.r,a.g,a.b,a.a,a.arrayBuffer,a.offset):new cc.Color(a,b,c,d,e,f)},cc.Color=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Color.BYTES_PER_ELEMENT),this._offset=f||0;var g=this._arrayBuffer,h=this._offset,i=Uint8Array.BYTES_PER_ELEMENT;this._rU8=new Uint8Array(g,h,1),this._gU8=new Uint8Array(g,h+i,1),this._bU8=new Uint8Array(g,h+2*i,1),this._aU8=new Uint8Array(g,h+3*i,1),this._rU8[0]=a||0,this._gU8[0]=b||0,this._bU8[0]=c||0,this._aU8[0]=null==d?255:d,void 0===d&&(this.a_undefined=!0)},cc.Color.BYTES_PER_ELEMENT=4;var a=cc.Color.prototype;a._getR=function(){return this._rU8[0]},a._setR=function(a){this._rU8[0]=0>a?0:a},a._getG=function(){return this._gU8[0]},a._setG=function(a){this._gU8[0]=0>a?0:a},a._getB=function(){return this._bU8[0]},a._setB=function(a){this._bU8[0]=0>a?0:a},a._getA=function(){return this._aU8[0]},a._setA=function(a){this._aU8[0]=0>a?0:a},a.r,cc.defineGetterSetter(a,"r",a._getR,a._setR),a.g,cc.defineGetterSetter(a,"g",a._getG,a._setG),a.b,cc.defineGetterSetter(a,"b",a._getB,a._setB),a.a,cc.defineGetterSetter(a,"a",a._getA,a._setA),cc.assert(cc.isFunction(cc._tmp.PrototypeColor),cc._LogInfos.MissingFile,"CCTypesPropertyDefine.js"),cc._tmp.PrototypeColor(),delete cc._tmp.PrototypeColor,cc.Vertex2F=function(a,b,c,d){this._arrayBuffer=c||new ArrayBuffer(cc.Vertex2F.BYTES_PER_ELEMENT),this._offset=d||0,this._xF32=new Float32Array(this._arrayBuffer,this._offset,1),this._yF32=new Float32Array(this._arrayBuffer,this._offset+4,1),this._xF32[0]=a||0,this._yF32[0]=b||0},cc.Vertex2F.BYTES_PER_ELEMENT=8,a=cc.Vertex2F.prototype,a._getX=function(){return this._xF32[0]; +},a._setX=function(a){this._xF32[0]=a},a._getY=function(){return this._yF32[0]},a._setY=function(a){this._yF32[0]=a},a.x,cc.defineGetterSetter(a,"x",a._getX,a._setX),a.y,cc.defineGetterSetter(a,"y",a._getY,a._setY),cc.Vertex3F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.Vertex3F.BYTES_PER_ELEMENT),this._offset=e||0;var f=this._arrayBuffer,g=this._offset;this._xF32=new Float32Array(f,g,1),this._xF32[0]=a||0,this._yF32=new Float32Array(f,g+Float32Array.BYTES_PER_ELEMENT,1),this._yF32[0]=b||0,this._zF32=new Float32Array(f,g+2*Float32Array.BYTES_PER_ELEMENT,1),this._zF32[0]=c||0},cc.Vertex3F.BYTES_PER_ELEMENT=12,a=cc.Vertex3F.prototype,a._getX=function(){return this._xF32[0]},a._setX=function(a){this._xF32[0]=a},a._getY=function(){return this._yF32[0]},a._setY=function(a){this._yF32[0]=a},a._getZ=function(){return this._zF32[0]},a._setZ=function(a){this._zF32[0]=a},a.x,cc.defineGetterSetter(a,"x",a._getX,a._setX),a.y,cc.defineGetterSetter(a,"y",a._getY,a._setY),a.z,cc.defineGetterSetter(a,"z",a._getZ,a._setZ),cc.Tex2F=function(a,b,c,d){this._arrayBuffer=c||new ArrayBuffer(cc.Tex2F.BYTES_PER_ELEMENT),this._offset=d||0,this._uF32=new Float32Array(this._arrayBuffer,this._offset,1),this._vF32=new Float32Array(this._arrayBuffer,this._offset+4,1),this._uF32[0]=a||0,this._vF32[0]=b||0},cc.Tex2F.BYTES_PER_ELEMENT=8,a=cc.Tex2F.prototype,a._getU=function(){return this._uF32[0]},a._setU=function(a){this._uF32[0]=a},a._getV=function(){return this._vF32[0]},a._setV=function(a){this._vF32[0]=a},a.u,cc.defineGetterSetter(a,"u",a._getU,a._setU),a.v,cc.defineGetterSetter(a,"v",a._getV,a._setV),cc.Quad2=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.Quad2.BYTES_PER_ELEMENT),this._offset=f||0;var g=this._arrayBuffer,h=cc.Vertex2F.BYTES_PER_ELEMENT;this._tl=a?new cc.Vertex2F(a.x,a.y,g,0):new cc.Vertex2F(0,0,g,0),this._tr=b?new cc.Vertex2F(b.x,b.y,g,h):new cc.Vertex2F(0,0,g,h),this._bl=c?new cc.Vertex2F(c.x,c.y,g,2*h):new cc.Vertex2F(0,0,g,2*h),this._br=d?new cc.Vertex2F(d.x,d.y,g,3*h):new cc.Vertex2F(0,0,g,3*h)},cc.Quad2.BYTES_PER_ELEMENT=32,a=cc.Quad2.prototype,a._getTL=function(){return this._tl},a._setTL=function(a){this._tl.x=a.x,this._tl.y=a.y},a._getTR=function(){return this._tr},a._setTR=function(a){this._tr.x=a.x,this._tr.y=a.y},a._getBL=function(){return this._bl},a._setBL=function(a){this._bl.x=a.x,this._bl.y=a.y},a._getBR=function(){return this._br},a._setBR=function(a){this._br.x=a.x,this._br.y=a.y},a.tl,cc.defineGetterSetter(a,"tl",a._getTL,a._setTL),a.tr,cc.defineGetterSetter(a,"tr",a._getTR,a._setTR),a.bl,cc.defineGetterSetter(a,"bl",a._getBL,a._setBL),a.br,cc.defineGetterSetter(a,"br",a._getBR,a._setBR),cc.Quad3=function(a,b,c,d){this.bl=a||new cc.Vertex3F(0,0,0),this.br=b||new cc.Vertex3F(0,0,0),this.tl=c||new cc.Vertex3F(0,0,0),this.tr=d||new cc.Vertex3F(0,0,0)},cc.V3F_C4B_T2F=function(a,b,c,d,e){this._arrayBuffer=d||new ArrayBuffer(cc.V3F_C4B_T2F.BYTES_PER_ELEMENT),this._offset=e||0;var f=this._arrayBuffer,g=this._offset,h=cc.Vertex3F.BYTES_PER_ELEMENT;this._vertices=a?new cc.Vertex3F(a.x,a.y,a.z,f,g):new cc.Vertex3F(0,0,0,f,g),this._colors=b?cc.color(b.r,b.g,b.b,b.a,f,g+h):cc.color(0,0,0,0,f,g+h),this._texCoords=c?new cc.Tex2F(c.u,c.v,f,g+h+cc.Color.BYTES_PER_ELEMENT):new cc.Tex2F(0,0,f,g+h+cc.Color.BYTES_PER_ELEMENT)},cc.V3F_C4B_T2F.BYTES_PER_ELEMENT=24,a=cc.V3F_C4B_T2F.prototype,a._getVertices=function(){return this._vertices},a._setVertices=function(a){var b=this._vertices;b.x=a.x,b.y=a.y,b.z=a.z},a._getColor=function(){return this._colors},a._setColor=function(a){var b=this._colors;b.r=a.r,b.g=a.g,b.b=a.b,b.a=a.a},a._getTexCoords=function(){return this._texCoords},a._setTexCoords=function(a){this._texCoords.u=a.u,this._texCoords.v=a.v},a.vertices,cc.defineGetterSetter(a,"vertices",a._getVertices,a._setVertices),a.colors,cc.defineGetterSetter(a,"colors",a._getColor,a._setColor),a.texCoords,cc.defineGetterSetter(a,"texCoords",a._getTexCoords,a._setTexCoords),cc.V3F_C4B_T2F_Quad=function(a,b,c,d,e,f){this._arrayBuffer=e||new ArrayBuffer(cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT),this._offset=f||0;var g=this._arrayBuffer,h=this._offset,i=cc.V3F_C4B_T2F.BYTES_PER_ELEMENT;this._tl=a?new cc.V3F_C4B_T2F(a.vertices,a.colors,a.texCoords,g,h):new cc.V3F_C4B_T2F(null,null,null,g,h),this._bl=b?new cc.V3F_C4B_T2F(b.vertices,b.colors,b.texCoords,g,h+i):new cc.V3F_C4B_T2F(null,null,null,g,h+i),this._tr=c?new cc.V3F_C4B_T2F(c.vertices,c.colors,c.texCoords,g,h+2*i):new cc.V3F_C4B_T2F(null,null,null,g,h+2*i),this._br=d?new cc.V3F_C4B_T2F(d.vertices,d.colors,d.texCoords,g,h+3*i):new cc.V3F_C4B_T2F(null,null,null,g,h+3*i)},cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT=96,a=cc.V3F_C4B_T2F_Quad.prototype,a._getTL=function(){return this._tl},a._setTL=function(a){var b=this._tl;b.vertices=a.vertices,b.colors=a.colors,b.texCoords=a.texCoords},a._getBL=function(){return this._bl},a._setBL=function(a){var b=this._bl;b.vertices=a.vertices,b.colors=a.colors,b.texCoords=a.texCoords},a._getTR=function(){return this._tr},a._setTR=function(a){var b=this._tr;b.vertices=a.vertices,b.colors=a.colors,b.texCoords=a.texCoords},a._getBR=function(){return this._br},a._setBR=function(a){var b=this._br;b.vertices=a.vertices,b.colors=a.colors,b.texCoords=a.texCoords},a._getArrayBuffer=function(){return this._arrayBuffer},a.tl,cc.defineGetterSetter(a,"tl",a._getTL,a._setTL),a.tr,cc.defineGetterSetter(a,"tr",a._getTR,a._setTR),a.bl,cc.defineGetterSetter(a,"bl",a._getBL,a._setBL),a.br,cc.defineGetterSetter(a,"br",a._getBR,a._setBR),a.arrayBuffer,cc.defineGetterSetter(a,"arrayBuffer",a._getArrayBuffer,null),cc.V3F_C4B_T2F_QuadZero=function(){return new cc.V3F_C4B_T2F_Quad},cc.V3F_C4B_T2F_QuadCopy=function(a){if(!a)return cc.V3F_C4B_T2F_QuadZero();var b=a.tl,c=a.bl,d=a.tr,e=a.br;return{tl:{vertices:{x:b.vertices.x,y:b.vertices.y,z:b.vertices.z},colors:{r:b.colors.r,g:b.colors.g,b:b.colors.b,a:b.colors.a},texCoords:{u:b.texCoords.u,v:b.texCoords.v}},bl:{vertices:{x:c.vertices.x,y:c.vertices.y,z:c.vertices.z},colors:{r:c.colors.r,g:c.colors.g,b:c.colors.b,a:c.colors.a},texCoords:{u:c.texCoords.u,v:c.texCoords.v}},tr:{vertices:{x:d.vertices.x,y:d.vertices.y,z:d.vertices.z},colors:{r:d.colors.r,g:d.colors.g,b:d.colors.b,a:d.colors.a},texCoords:{u:d.texCoords.u,v:d.texCoords.v}},br:{vertices:{x:e.vertices.x,y:e.vertices.y,z:e.vertices.z},colors:{r:e.colors.r,g:e.colors.g,b:e.colors.b,a:e.colors.a},texCoords:{u:e.texCoords.u,v:e.texCoords.v}}}},cc.V3F_C4B_T2F_QuadsCopy=function(a){if(!a)return[];for(var b=[],c=0;c>16,d=(b>>8)%256,e=b%256;return cc.color(c,d,e)},cc.colorToHex=function(a){var b=a.r.toString(16),c=a.g.toString(16),d=a.b.toString(16);return"#"+(a.r<16?"0"+b:b)+(a.g<16?"0"+c:c)+(a.b<16?"0"+d:d)},cc.TEXT_ALIGNMENT_LEFT=0,cc.TEXT_ALIGNMENT_CENTER=1,cc.TEXT_ALIGNMENT_RIGHT=2,cc.VERTICAL_TEXT_ALIGNMENT_TOP=0,cc.VERTICAL_TEXT_ALIGNMENT_CENTER=1,cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM=2,cc._Dictionary=cc.Class.extend({_keyMapTb:null,_valueMapTb:null,__currId:0,ctor:function(){this._keyMapTb={},this._valueMapTb={},this.__currId=2<<(0|10*Math.random())},__getKey:function(){return this.__currId++,"key_"+this.__currId},setObject:function(a,b){if(null!=b){var c=this.__getKey();this._keyMapTb[c]=b,this._valueMapTb[c]=a}},objectForKey:function(a){if(null==a)return null;var b=this._keyMapTb;for(var c in b)if(b[c]===a)return this._valueMapTb[c];return null},valueForKey:function(a){return this.objectForKey(a)},removeObjectForKey:function(a){if(null!=a){var b=this._keyMapTb;for(var c in b)if(b[c]===a)return delete this._valueMapTb[c],void delete b[c]}},removeObjectsForKeys:function(a){if(null!=a)for(var b=0;b-1&&(cc.__BrowserGetter.adaptationType=cc.sys.BROWSER_TYPE_MIUI),cc.sys.os===cc.sys.OS_IOS&&(cc.__BrowserGetter.adaptationType=cc.sys.BROWSER_TYPE_SAFARI),cc.__BrowserGetter.adaptationType){case cc.sys.BROWSER_TYPE_SAFARI:cc.__BrowserGetter.meta["minimal-ui"]="true",cc.__BrowserGetter.availWidth=function(a){return a.clientWidth},cc.__BrowserGetter.availHeight=function(a){return a.clientHeight};break;case cc.sys.BROWSER_TYPE_CHROME:cc.__BrowserGetter.__defineGetter__("target-densitydpi",function(){return cc.view._targetDensityDPI});case cc.sys.BROWSER_TYPE_SOUGOU:case cc.sys.BROWSER_TYPE_UC:cc.__BrowserGetter.availWidth=function(a){return a.clientWidth},cc.__BrowserGetter.availHeight=function(a){return a.clientHeight};break;case cc.sys.BROWSER_TYPE_MIUI:cc.__BrowserGetter.init=function(a){if(!a.__resizeWithBrowserSize){var b=function(){a.setDesignResolutionSize(a._designResolutionSize.width,a._designResolutionSize.height,a._resolutionPolicy),window.removeEventListener("resize",b,!1)};window.addEventListener("resize",b,!1)}}}cc.EGLView=cc.Class.extend({_delegate:null,_frameSize:null,_designResolutionSize:null,_originalDesignResolutionSize:null,_viewPortRect:null,_visibleRect:null,_retinaEnabled:!1,_autoFullScreen:!0,_devicePixelRatio:1,_viewName:"",_resizeCallback:null,_scaleX:1,_originalScaleX:1,_scaleY:1,_originalScaleY:1,_indexBitsUsed:0,_maxTouches:5,_resolutionPolicy:null,_rpExactFit:null,_rpShowAll:null,_rpNoBorder:null,_rpFixedHeight:null,_rpFixedWidth:null,_initialized:!1,_captured:!1,_wnd:null,_hDC:null,_hRC:null,_supportTouch:!1,_contentTranslateLeftTop:null,_frame:null,_frameZoomFactor:1,__resizeWithBrowserSize:!1,_isAdjustViewPort:!0,_targetDensityDPI:null,ctor:function(){var a=this,b=document,c=cc.ContainerStrategy,d=cc.ContentStrategy;cc.__BrowserGetter.init(this),a._frame=cc.container.parentNode===b.body?b.documentElement:cc.container.parentNode,a._frameSize=cc.size(0,0),a._initFrameSize();var e=cc._canvas.width,f=cc._canvas.height;a._designResolutionSize=cc.size(e,f),a._originalDesignResolutionSize=cc.size(e,f),a._viewPortRect=cc.rect(0,0,e,f),a._visibleRect=cc.rect(0,0,e,f),a._contentTranslateLeftTop={left:0,top:0},a._viewName="Cocos2dHTML5";var g=cc.sys;a.enableRetina(g.os===g.OS_IOS||g.os===g.OS_OSX),cc.visibleRect&&cc.visibleRect.init(a._visibleRect),a._rpExactFit=new cc.ResolutionPolicy(c.EQUAL_TO_FRAME,d.EXACT_FIT),a._rpShowAll=new cc.ResolutionPolicy(c.PROPORTION_TO_FRAME,d.SHOW_ALL),a._rpNoBorder=new cc.ResolutionPolicy(c.EQUAL_TO_FRAME,d.NO_BORDER),a._rpFixedHeight=new cc.ResolutionPolicy(c.EQUAL_TO_FRAME,d.FIXED_HEIGHT),a._rpFixedWidth=new cc.ResolutionPolicy(c.EQUAL_TO_FRAME,d.FIXED_WIDTH),a._hDC=cc._canvas,a._hRC=cc._renderContext,a._targetDensityDPI=cc.DENSITYDPI_HIGH},_resizeEvent:function(){var a;a=this.setDesignResolutionSize?this:cc.view;var b=a._frameSize.width,c=a._frameSize.height;if(a._initFrameSize(),a._frameSize.width!==b||a._frameSize.height!==c){a._resizeCallback&&a._resizeCallback.call();var d=a._originalDesignResolutionSize.width,e=a._originalDesignResolutionSize.height;d>0&&a.setDesignResolutionSize(d,e,a._resolutionPolicy)}},setTargetDensityDPI:function(a){this._targetDensityDPI=a,this._adjustViewportMeta()},getTargetDensityDPI:function(){return this._targetDensityDPI},resizeWithBrowserSize:function(a){a?this.__resizeWithBrowserSize||(this.__resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent),window.addEventListener("orientationchange",this._resizeEvent)):this.__resizeWithBrowserSize&&(this.__resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._resizeEvent))},setResizeCallback:function(a){(cc.isFunction(a)||null==a)&&(this._resizeCallback=a)},_initFrameSize:function(){var a=this._frameSize;a.width=cc.__BrowserGetter.availWidth(this._frame),a.height=cc.__BrowserGetter.availHeight(this._frame)},_adjustSizeKeepCanvasSize:function(){var a=this._originalDesignResolutionSize.width,b=this._originalDesignResolutionSize.height;a>0&&this.setDesignResolutionSize(a,b,this._resolutionPolicy)},_setViewportMeta:function(a,b){var c=document.getElementById("cocosMetaElement");c&&b&&document.head.removeChild(c);var d,e,f,g=document.getElementsByName("viewport"),h=g?g[0]:null;d=h?h.content:"",c=c||document.createElement("meta"),c.id="cocosMetaElement",c.name="viewport",c.content="";for(e in a)-1==d.indexOf(e)?d+=","+e+"="+a[e]:b&&(f=new RegExp(e+"s*=s*[^,]+"),d.replace(f,e+"="+a[e]));/^,/.test(d)&&(d=d.substr(1)),c.content=d,h&&(h.content=d),document.head.appendChild(c)},_adjustViewportMeta:function(){this._isAdjustViewPort&&this._setViewportMeta(cc.__BrowserGetter.meta,!1)},_setScaleXYForRenderTexture:function(){var a=cc.contentScaleFactor();this._scaleX=a,this._scaleY=a},_resetScale:function(){this._scaleX=this._originalScaleX,this._scaleY=this._originalScaleY},_adjustSizeToBrowser:function(){},initialize:function(){this._initialized=!0},adjustViewPort:function(a){this._isAdjustViewPort=a},enableRetina:function(a){this._retinaEnabled=a?!0:!1},isRetinaEnabled:function(){return this._retinaEnabled},enableAutoFullScreen:function(a){this._autoFullScreen=a?!0:!1},isAutoFullScreenEnabled:function(){return this._autoFullScreen},end:function(){},isOpenGLReady:function(){return null!==this._hDC&&null!==this._hRC},setFrameZoomFactor:function(a){this._frameZoomFactor=a,this.centerWindow(),cc.director.setProjection(cc.director.getProjection())},swapBuffers:function(){},setIMEKeyboardState:function(a){},setContentTranslateLeftTop:function(a,b){this._contentTranslateLeftTop={left:a,top:b}},getContentTranslateLeftTop:function(){return this._contentTranslateLeftTop},getCanvasSize:function(){return cc.size(cc._canvas.width,cc._canvas.height)},getFrameSize:function(){return cc.size(this._frameSize.width,this._frameSize.height)},setFrameSize:function(a,b){this._frameSize.width=a,this._frameSize.height=b,this._frame.style.width=a+"px",this._frame.style.height=b+"px",this._resizeEvent(),cc.director.setProjection(cc.director.getProjection())},centerWindow:function(){},getVisibleSize:function(){return cc.size(this._visibleRect.width,this._visibleRect.height)},getVisibleSizeInPixel:function(){return cc.size(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},getVisibleOrigin:function(){return cc.p(this._visibleRect.x,this._visibleRect.y)},getVisibleOriginInPixel:function(){return cc.p(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},canSetContentScaleFactor:function(){return!0},getResolutionPolicy:function(){return this._resolutionPolicy},setResolutionPolicy:function(a){var b=this;if(a instanceof cc.ResolutionPolicy)b._resolutionPolicy=a;else{var c=cc.ResolutionPolicy;a===c.EXACT_FIT&&(b._resolutionPolicy=b._rpExactFit),a===c.SHOW_ALL&&(b._resolutionPolicy=b._rpShowAll),a===c.NO_BORDER&&(b._resolutionPolicy=b._rpNoBorder),a===c.FIXED_HEIGHT&&(b._resolutionPolicy=b._rpFixedHeight),a===c.FIXED_WIDTH&&(b._resolutionPolicy=b._rpFixedWidth)}},setDesignResolutionSize:function(a,b,c){if(!(a>0||b>0))return void cc.log(cc._LogInfos.EGLView_setDesignResolutionSize);this.setResolutionPolicy(c);var d=this._resolutionPolicy;if(!d)return void cc.log(cc._LogInfos.EGLView_setDesignResolutionSize_2);d.preApply(this),cc.sys.isMobile&&this._adjustViewportMeta(),this._initFrameSize(),this._originalDesignResolutionSize.width=this._designResolutionSize.width=a,this._originalDesignResolutionSize.height=this._designResolutionSize.height=b;var e=d.apply(this,this._designResolutionSize);if(e.scale&&2===e.scale.length&&(this._scaleX=e.scale[0],this._scaleY=e.scale[1]),e.viewport){var f=this._viewPortRect,g=this._visibleRect,h=e.viewport;f.x=h.x,f.y=h.y,f.width=h.width,f.height=h.height,g.x=-f.x/this._scaleX,g.y=-f.y/this._scaleY,g.width=cc._canvas.width/this._scaleX,g.height=cc._canvas.height/this._scaleY,cc._renderContext.setOffset&&cc._renderContext.setOffset(f.x,-f.y)}var i=cc.director;i._winSizeInPoints.width=this._designResolutionSize.width,i._winSizeInPoints.height=this._designResolutionSize.height,d.postApply(this),cc.winSize.width=i._winSizeInPoints.width,cc.winSize.height=i._winSizeInPoints.height,cc._renderType===cc.game.RENDER_TYPE_WEBGL&&i.setGLDefaultValues(),this._originalScaleX=this._scaleX,this._originalScaleY=this._scaleY,cc.DOM&&cc.DOM._resetEGLViewDiv(),cc.visibleRect&&cc.visibleRect.init(this._visibleRect)},getDesignResolutionSize:function(){return cc.size(this._designResolutionSize.width,this._designResolutionSize.height)},setRealPixelResolution:function(a,b,c){this._setViewportMeta({width:a,"target-densitydpi":cc.DENSITYDPI_DEVICE},!0),document.body.style.width=a+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(a,b,c)},setViewPortInPoints:function(a,b,c,d){var e=this._frameZoomFactor,f=this._scaleX,g=this._scaleY;cc._renderContext.viewport(a*f*e+this._viewPortRect.x*e,b*g*e+this._viewPortRect.y*e,c*f*e,d*g*e)},setScissorInPoints:function(a,b,c,d){var e=this._frameZoomFactor,f=this._scaleX,g=this._scaleY;cc._renderContext.scissor(a*f*e+this._viewPortRect.x*e,b*g*e+this._viewPortRect.y*e,c*f*e,d*g*e)},isScissorEnabled:function(){var a=cc._renderContext;return a.isEnabled(a.SCISSOR_TEST)},getScissorRect:function(){var a=cc._renderContext,b=this._scaleX,c=this._scaleY,d=a.getParameter(a.SCISSOR_BOX);return cc.rect((d[0]-this._viewPortRect.x)/b,(d[1]-this._viewPortRect.y)/c,d[2]/b,d[3]/c)},setViewName:function(a){null!=a&&a.length>0&&(this._viewName=a)},getViewName:function(){return this._viewName},getViewPortRect:function(){return this._viewPortRect},getScaleX:function(){return this._scaleX},getScaleY:function(){return this._scaleY},getDevicePixelRatio:function(){return this._devicePixelRatio},convertToLocationInView:function(a,b,c){return{x:this._devicePixelRatio*(a-c.left),y:this._devicePixelRatio*(c.top+c.height-b)}},_convertMouseToLocationInView:function(a,b){var c=this._viewPortRect,d=this;a.x=(d._devicePixelRatio*(a.x-b.left)-c.x)/d._scaleX,a.y=(d._devicePixelRatio*(b.top+b.height-a.y)-c.y)/d._scaleY},_convertTouchesWithScale:function(a){for(var b,c,d,e=this._viewPortRect,f=this._scaleX,g=this._scaleY,h=0;hj?(c=e,d=i*j):(c=h*k,d=f);var l=Math.round((e-c)/2),m=Math.round((f-d)/2);c=e-2*l,d=f-2*m,this._setupContainer(a,c,d),g.marginLeft=l+"px",g.marginRight=l+"px",g.marginTop=m+"px",g.marginBottom=m+"px"}}),c=(a.extend({preApply:function(a){this._super(a),a._frame=document.documentElement},apply:function(a){this._super(a),this._fixContainer()}}),b.extend({preApply:function(a){this._super(a),a._frame=document.documentElement},apply:function(a,b){this._super(a,b),this._fixContainer()}}),cc.ContainerStrategy.extend({apply:function(a){this._setupContainer(a,cc._canvas.width,cc._canvas.height)}}));cc.ContainerStrategy.EQUAL_TO_FRAME=new a,cc.ContainerStrategy.PROPORTION_TO_FRAME=new b,cc.ContainerStrategy.ORIGINAL_CONTAINER=new c;var d=cc.ContentStrategy.extend({apply:function(a,b){var c=cc._canvas.width,d=cc._canvas.height,e=c/b.width,f=d/b.height;return this._buildResult(c,d,c,d,e,f)}}),e=cc.ContentStrategy.extend({apply:function(a,b){var c,d,e=cc._canvas.width,f=cc._canvas.height,g=b.width,h=b.height,i=e/g,j=f/h,k=0;return j>i?(k=i,c=e,d=h*k):(k=j,c=g*k,d=f),this._buildResult(e,f,c,d,k,k)}}),f=cc.ContentStrategy.extend({apply:function(a,b){var c,d,e,f=cc._canvas.width,g=cc._canvas.height,h=b.width,i=b.height,j=f/h,k=g/i;return k>j?(c=k,d=h*c,e=g):(c=j,d=f,e=i*c),this._buildResult(f,g,d,e,c,c)}}),g=cc.ContentStrategy.extend({apply:function(a,b){var c=cc._canvas.width,d=cc._canvas.height,e=b.height,f=d/e,g=c,h=d;return this._buildResult(c,d,g,h,f,f)},postApply:function(a){cc.director._winSizeInPoints=a.getVisibleSize()}}),h=cc.ContentStrategy.extend({apply:function(a,b){var c=cc._canvas.width,d=cc._canvas.height,e=b.width,f=c/e,g=c,h=d;return this._buildResult(c,d,g,h,f,f)},postApply:function(a){cc.director._winSizeInPoints=a.getVisibleSize()}});cc.ContentStrategy.EXACT_FIT=new d,cc.ContentStrategy.SHOW_ALL=new e,cc.ContentStrategy.NO_BORDER=new f,cc.ContentStrategy.FIXED_HEIGHT=new g,cc.ContentStrategy.FIXED_WIDTH=new h}(),cc.ResolutionPolicy=cc.Class.extend({_containerStrategy:null,_contentStrategy:null,ctor:function(a,b){this.setContainerStrategy(a),this.setContentStrategy(b)},preApply:function(a){this._containerStrategy.preApply(a),this._contentStrategy.preApply(a)},apply:function(a,b){return this._containerStrategy.apply(a,b),this._contentStrategy.apply(a,b)},postApply:function(a){this._containerStrategy.postApply(a),this._contentStrategy.postApply(a)},setContainerStrategy:function(a){a instanceof cc.ContainerStrategy&&(this._containerStrategy=a)},setContentStrategy:function(a){a instanceof cc.ContentStrategy&&(this._contentStrategy=a)}}),cc.ResolutionPolicy.EXACT_FIT=0,cc.ResolutionPolicy.NO_BORDER=1,cc.ResolutionPolicy.SHOW_ALL=2,cc.ResolutionPolicy.FIXED_HEIGHT=3,cc.ResolutionPolicy.FIXED_WIDTH=4,cc.ResolutionPolicy.UNKNOWN=5,cc.screen={_supportsFullScreen:!1,_preOnFullScreenChange:null,_touchEvent:"",_fn:null,_fnMap:[["requestFullscreen","exitFullscreen","fullscreenchange","fullscreenEnabled","fullscreenElement"],["requestFullScreen","exitFullScreen","fullScreenchange","fullScreenEnabled","fullScreenElement"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange","webkitIsFullScreen","webkitCurrentFullScreenElement"],["mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozFullScreen","mozFullScreenElement"],["msRequestFullscreen","msExitFullscreen","MSFullscreenChange","msFullscreenEnabled","msFullscreenElement"]],init:function(){this._fn={};var a,b,c,d=this._fnMap;for(a=0,l=d.length;aa;a++)this._fn[d[0][a]]=b[a];break}this._supportsFullScreen="undefined"!=typeof this._fn.requestFullscreen,this._touchEvent="ontouchstart"in window?"touchstart":"mousedown"},fullScreen:function(){return this._supportsFullScreen?void 0===document[this._fn.fullscreenElement]||null===document[this._fn.fullscreenElement]?!1:!0:!1},requestFullScreen:function(a,b){if(this._supportsFullScreen){if(a=a||document.documentElement,b){var c=this._fn.fullscreenchange;this._preOnFullScreenChange&&document.removeEventListener(c,this._preOnFullScreenChange),this._preOnFullScreenChange=b,document.addEventListener(c,b,!1)}return a[this._fn.requestFullscreen]()}},exitFullScreen:function(){return this._supportsFullScreen?document[this._fn.exitFullscreen]():!0},autoFullScreen:function(a,b){function c(){e.requestFullScreen(a,b),d.removeEventListener(e._touchEvent,c)}a=a||document.body;var d=cc._canvas||a,e=this;this.requestFullScreen(a,b),d.addEventListener(this._touchEvent,c)}},cc.screen.init(),cc.visibleRect={topLeft:cc.p(0,0),topRight:cc.p(0,0),top:cc.p(0,0),bottomLeft:cc.p(0,0),bottomRight:cc.p(0,0),bottom:cc.p(0,0),center:cc.p(0,0),left:cc.p(0,0),right:cc.p(0,0),width:0,height:0,init:function(a){var b=this.width=a.width,c=this.height=a.height,d=a.x,e=a.y,f=e+c,g=d+b;this.topLeft.x=d,this.topLeft.y=f,this.topRight.x=g,this.topRight.y=f,this.top.x=d+b/2,this.top.y=f,this.bottomLeft.x=d,this.bottomLeft.y=e,this.bottomRight.x=g,this.bottomRight.y=e,this.bottom.x=d+b/2,this.bottom.y=e,this.center.x=d+b/2,this.center.y=e+c/2,this.left.x=d,this.left.y=e+c/2,this.right.x=g,this.right.y=e+c/2}},cc.UIInterfaceOrientationLandscapeLeft=-90,cc.UIInterfaceOrientationLandscapeRight=90,cc.UIInterfaceOrientationPortraitUpsideDown=180,cc.UIInterfaceOrientationPortrait=0,cc.inputManager={_mousePressed:!1,_isRegisterEvent:!1,_preTouchPoint:cc.p(0,0),_prevMousePoint:cc.p(0,0),_preTouchPool:[],_preTouchPoolPointer:0,_touches:[],_touchesIntegerDict:{},_indexBitsUsed:0,_maxTouches:5,_accelEnabled:!1,_accelInterval:1/30,_accelMinus:1,_accelCurTime:0,_acceleration:null,_accelDeviceEvent:null,_getUnUsedIndex:function(){for(var a=this._indexBitsUsed,b=0;b>=1}return-1},_removeUsedIndexBit:function(a){if(!(0>a||a>=this._maxTouches)){var b=1<h;h++)if(b=a[h],e=b.getID(),c=g[e],null==c){var j=this._getUnUsedIndex();if(-1===j){cc.log(cc._LogInfos.inputManager_handleTouchesBegin,j);continue}d=this._touches[j]=new cc.Touch(b._point.x,b._point.y,b.getID()),d._setPrevPoint(b._prevPoint),g[e]=j,f.push(d)}if(f.length>0){this._glView._convertTouchesWithScale(f);var k=new cc.EventTouch(f);k._eventCode=cc.EventTouch.EventCode.BEGAN,cc.eventManager.dispatchEvent(k)}},handleTouchesMove:function(a){for(var b,c,d,e=[],f=this._touches,g=0,h=a.length;h>g;g++)b=a[g],d=b.getID(),c=this._touchesIntegerDict[d],null!=c&&f[c]&&(f[c]._setPoint(b._point),f[c]._setPrevPoint(b._prevPoint),e.push(f[c]));if(e.length>0){this._glView._convertTouchesWithScale(e);var i=new cc.EventTouch(e);i._eventCode=cc.EventTouch.EventCode.MOVED,cc.eventManager.dispatchEvent(i)}},handleTouchesEnd:function(a){var b=this.getSetOfTouchesEndOrCancel(a); +if(b.length>0){this._glView._convertTouchesWithScale(b);var c=new cc.EventTouch(b);c._eventCode=cc.EventTouch.EventCode.ENDED,cc.eventManager.dispatchEvent(c)}},handleTouchesCancel:function(a){var b=this.getSetOfTouchesEndOrCancel(a);if(b.length>0){this._glView._convertTouchesWithScale(b);var c=new cc.EventTouch(b);c._eventCode=cc.EventTouch.EventCode.CANCELLED,cc.eventManager.dispatchEvent(c)}},getSetOfTouchesEndOrCancel:function(a){for(var b,c,d,e=[],f=this._touches,g=this._touchesIntegerDict,h=0,i=a.length;i>h;h++)b=a[h],d=b.getID(),c=g[d],null!=c&&f[c]&&(f[c]._setPoint(b._point),f[c]._setPrevPoint(b._prevPoint),e.push(f[c]),this._removeUsedIndexBit(c),delete g[d]);return e},getHTMLElementPosition:function(a){var b=document.documentElement,c=window,d=null;return d=cc.isFunction(a.getBoundingClientRect)?a.getBoundingClientRect():a instanceof HTMLCanvasElement?{left:0,top:0,width:a.width,height:a.height}:{left:0,top:0,width:parseInt(a.style.width),height:parseInt(a.style.height)},{left:d.left+c.pageXOffset-b.clientLeft,top:d.top+c.pageYOffset-b.clientTop,width:d.width,height:d.height}},getPreTouch:function(a){for(var b=null,c=this._preTouchPool,d=a.getID(),e=c.length-1;e>=0;e--)if(c[e].getID()===d){b=c[e];break}return b||(b=a),b},setPreTouch:function(a){for(var b=!1,c=this._preTouchPool,d=a.getID(),e=c.length-1;e>=0;e--)if(c[e].getID()===d){c[e]=a,b=!0;break}b||(c.length<=50?c.push(a):(c[this._preTouchPoolPointer]=a,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},getTouchByXY:function(a,b,c){var d=this._preTouchPoint,e=this._glView.convertToLocationInView(a,b,c),f=new cc.Touch(e.x,e.y);return f._setPrevPoint(d.x,d.y),d.x=e.x,d.y=e.y,f},getMouseEvent:function(a,b,c){var d=this._prevMousePoint;this._glView._convertMouseToLocationInView(a,b);var e=new cc.EventMouse(c);return e.setLocation(a.x,a.y),e._setPrevCursor(d.x,d.y),d.x=a.x,d.y=a.y,e},getPointByEvent:function(a,b){return null!=a.pageX?{x:a.pageX,y:a.pageY}:(b.left-=document.body.scrollLeft,b.top-=document.body.scrollTop,{x:a.clientX,y:a.clientY})},getTouchesByEvent:function(a,b){for(var c,d,e,f=[],g=this._glView,h=this._preTouchPoint,i=a.changedTouches.length,j=0;i>j;j++)if(c=a.changedTouches[j]){var k;k=cc.sys.BROWSER_TYPE_FIREFOX===cc.sys.browserType?g.convertToLocationInView(c.pageX,c.pageY,b):g.convertToLocationInView(c.clientX,c.clientY,b),null!=c.identifier?(d=new cc.Touch(k.x,k.y,c.identifier),e=this.getPreTouch(d).getLocation(),d._setPrevPoint(e.x,e.y),this.setPreTouch(d)):(d=new cc.Touch(k.x,k.y),d._setPrevPoint(h.x,h.y)),h.x=k.x,h.y=k.y,f.push(d)}return f},registerSystemEvent:function(a){if(!this._isRegisterEvent){var b=(this._glView=cc.view,this),c="mouse"in cc.sys.capabilities,d="touches"in cc.sys.capabilities,e=!1;if(cc.sys.isMobile&&(e=!0),c&&(window.addEventListener("mousedown",function(){b._mousePressed=!0},!1),window.addEventListener("mouseup",function(c){if(!e){var d=b._mousePressed;if(b._mousePressed=!1,d){var f=b.getHTMLElementPosition(a),g=b.getPointByEvent(c,f);if(!cc.rectContainsPoint(new cc.Rect(f.left,f.top,f.width,f.height),g)){b.handleTouchesEnd([b.getTouchByXY(g.x,g.y,f)]);var h=b.getMouseEvent(g,f,cc.EventMouse.UP);h.setButton(c.button),cc.eventManager.dispatchEvent(h)}}}},!1),a.addEventListener("mousedown",function(c){if(!e){b._mousePressed=!0;var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,d);b.handleTouchesBegin([b.getTouchByXY(f.x,f.y,d)]);var g=b.getMouseEvent(f,d,cc.EventMouse.DOWN);g.setButton(c.button),cc.eventManager.dispatchEvent(g),c.stopPropagation(),c.preventDefault(),a.focus()}},!1),a.addEventListener("mouseup",function(c){if(!e){b._mousePressed=!1;var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,d);b.handleTouchesEnd([b.getTouchByXY(f.x,f.y,d)]);var g=b.getMouseEvent(f,d,cc.EventMouse.UP);g.setButton(c.button),cc.eventManager.dispatchEvent(g),c.stopPropagation(),c.preventDefault()}},!1),a.addEventListener("mousemove",function(c){if(!e){var d=b.getHTMLElementPosition(a),f=b.getPointByEvent(c,d);b.handleTouchesMove([b.getTouchByXY(f.x,f.y,d)]);var g=b.getMouseEvent(f,d,cc.EventMouse.MOVE);b._mousePressed?g.setButton(c.button):g.setButton(null),cc.eventManager.dispatchEvent(g),c.stopPropagation(),c.preventDefault()}},!1),a.addEventListener("mousewheel",function(c){var d=b.getHTMLElementPosition(a),e=b.getPointByEvent(c,d),f=b.getMouseEvent(e,d,cc.EventMouse.SCROLL);f.setButton(c.button),f.setScrollData(0,c.wheelDelta),cc.eventManager.dispatchEvent(f),c.stopPropagation(),c.preventDefault()},!1),a.addEventListener("DOMMouseScroll",function(c){var d=b.getHTMLElementPosition(a),e=b.getPointByEvent(c,d),f=b.getMouseEvent(e,d,cc.EventMouse.SCROLL);f.setButton(c.button),f.setScrollData(0,-120*c.detail),cc.eventManager.dispatchEvent(f),c.stopPropagation(),c.preventDefault()},!1)),window.navigator.msPointerEnabled){var f={MSPointerDown:b.handleTouchesBegin,MSPointerMove:b.handleTouchesMove,MSPointerUp:b.handleTouchesEnd,MSPointerCancel:b.handleTouchesCancel};for(var g in f)!function(c,d){a.addEventListener(c,function(c){var e=b.getHTMLElementPosition(a);e.left-=document.documentElement.scrollLeft,e.top-=document.documentElement.scrollTop,d.call(b,[b.getTouchByXY(c.clientX,c.clientY,e)]),c.stopPropagation()},!1)}(g,f[g])}d&&(a.addEventListener("touchstart",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft,d.top-=document.body.scrollTop,b.handleTouchesBegin(b.getTouchesByEvent(c,d)),c.stopPropagation(),c.preventDefault(),a.focus()}},!1),a.addEventListener("touchmove",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft,d.top-=document.body.scrollTop,b.handleTouchesMove(b.getTouchesByEvent(c,d)),c.stopPropagation(),c.preventDefault()}},!1),a.addEventListener("touchend",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft,d.top-=document.body.scrollTop,b.handleTouchesEnd(b.getTouchesByEvent(c,d)),c.stopPropagation(),c.preventDefault()}},!1),a.addEventListener("touchcancel",function(c){if(c.changedTouches){var d=b.getHTMLElementPosition(a);d.left-=document.body.scrollLeft,d.top-=document.body.scrollTop,b.handleTouchesCancel(b.getTouchesByEvent(c,d)),c.stopPropagation(),c.preventDefault()}},!1)),this._registerKeyboardEvent(),this._registerAccelerometerEvent(),this._isRegisterEvent=!0}},_registerKeyboardEvent:function(){},_registerAccelerometerEvent:function(){},update:function(a){this._accelCurTime>this._accelInterval&&(this._accelCurTime-=this._accelInterval,cc.eventManager.dispatchEvent(new cc.EventAcceleration(this._acceleration))),this._accelCurTime+=a}},cc.AffineTransform=function(a,b,c,d,e,f){this.a=a,this.b=b,this.c=c,this.d=d,this.tx=e,this.ty=f},cc.affineTransformMake=function(a,b,c,d,e,f){return{a:a,b:b,c:c,d:d,tx:e,ty:f}},cc.pointApplyAffineTransform=function(a,b,c){var d,e;return void 0===c?(c=b,d=a.x,e=a.y):(d=a,e=b),{x:c.a*d+c.c*e+c.tx,y:c.b*d+c.d*e+c.ty}},cc._pointApplyAffineTransform=function(a,b,c){return cc.pointApplyAffineTransform(a,b,c)},cc.sizeApplyAffineTransform=function(a,b){return{width:b.a*a.width+b.c*a.height,height:b.b*a.width+b.d*a.height}},cc.affineTransformMakeIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},cc.affineTransformIdentity=function(){return{a:1,b:0,c:0,d:1,tx:0,ty:0}},cc.rectApplyAffineTransform=function(a,b){var c=cc.rectGetMinY(a),d=cc.rectGetMinX(a),e=cc.rectGetMaxX(a),f=cc.rectGetMaxY(a),g=cc.pointApplyAffineTransform(d,c,b),h=cc.pointApplyAffineTransform(e,c,b),i=cc.pointApplyAffineTransform(d,f,b),j=cc.pointApplyAffineTransform(e,f,b),k=Math.min(g.x,h.x,i.x,j.x),l=Math.max(g.x,h.x,i.x,j.x),m=Math.min(g.y,h.y,i.y,j.y),n=Math.max(g.y,h.y,i.y,j.y);return cc.rect(k,m,l-k,n-m)},cc._rectApplyAffineTransformIn=function(a,b){var c=cc.rectGetMinY(a),d=cc.rectGetMinX(a),e=cc.rectGetMaxX(a),f=cc.rectGetMaxY(a),g=cc.pointApplyAffineTransform(d,c,b),h=cc.pointApplyAffineTransform(e,c,b),i=cc.pointApplyAffineTransform(d,f,b),j=cc.pointApplyAffineTransform(e,f,b),k=Math.min(g.x,h.x,i.x,j.x),l=Math.max(g.x,h.x,i.x,j.x),m=Math.min(g.y,h.y,i.y,j.y),n=Math.max(g.y,h.y,i.y,j.y);return a.x=k,a.y=m,a.width=l-k,a.height=n-m,a},cc.affineTransformTranslate=function(a,b,c){return{a:a.a,b:a.b,c:a.c,d:a.d,tx:a.tx+a.a*b+a.c*c,ty:a.ty+a.b*b+a.d*c}},cc.affineTransformScale=function(a,b,c){return{a:a.a*b,b:a.b*b,c:a.c*c,d:a.d*c,tx:a.tx,ty:a.ty}},cc.affineTransformRotate=function(a,b){var c=Math.sin(b),d=Math.cos(b);return{a:a.a*d+a.c*c,b:a.b*d+a.d*c,c:a.c*d-a.a*c,d:a.d*d-a.b*c,tx:a.tx,ty:a.ty}},cc.affineTransformConcat=function(a,b){return{a:a.a*b.a+a.b*b.c,b:a.a*b.b+a.b*b.d,c:a.c*b.a+a.d*b.c,d:a.c*b.b+a.d*b.d,tx:a.tx*b.a+a.ty*b.c+b.tx,ty:a.tx*b.b+a.ty*b.d+b.ty}},cc.affineTransformConcatIn=function(a,b){var c=a.a,d=a.b,e=a.c,f=a.d,g=a.tx,h=a.ty;return a.a=c*b.a+d*b.c,a.b=c*b.b+d*b.d,a.c=e*b.a+f*b.c,a.d=e*b.b+f*b.d,a.tx=g*b.a+h*b.c+b.tx,a.ty=g*b.b+h*b.d+b.ty,a},cc.affineTransformEqualToTransform=function(a,b){return a.a===b.a&&a.b===b.b&&a.c===b.c&&a.d===b.d&&a.tx===b.tx&&a.ty===b.ty},cc.affineTransformInvert=function(a){var b=1/(a.a*a.d-a.b*a.c);return{a:b*a.d,b:-b*a.b,c:-b*a.c,d:b*a.a,tx:b*(a.c*a.ty-a.d*a.tx),ty:b*(a.b*a.tx-a.a*a.ty)}},cc.POINT_EPSILON=parseFloat("1.192092896e-07F"),cc.pNeg=function(a){return cc.p(-a.x,-a.y)},cc.pAdd=function(a,b){return cc.p(a.x+b.x,a.y+b.y)},cc.pSub=function(a,b){return cc.p(a.x-b.x,a.y-b.y)},cc.pMult=function(a,b){return cc.p(a.x*b,a.y*b)},cc.pMidpoint=function(a,b){return cc.pMult(cc.pAdd(a,b),.5)},cc.pDot=function(a,b){return a.x*b.x+a.y*b.y},cc.pCross=function(a,b){return a.x*b.y-a.y*b.x},cc.pPerp=function(a){return cc.p(-a.y,a.x)},cc.pRPerp=function(a){return cc.p(a.y,-a.x)},cc.pProject=function(a,b){return cc.pMult(b,cc.pDot(a,b)/cc.pDot(b,b))},cc.pRotate=function(a,b){return cc.p(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x)},cc.pUnrotate=function(a,b){return cc.p(a.x*b.x+a.y*b.y,a.y*b.x-a.x*b.y)},cc.pLengthSQ=function(a){return cc.pDot(a,a)},cc.pDistanceSQ=function(a,b){return cc.pLengthSQ(cc.pSub(a,b))},cc.pLength=function(a){return Math.sqrt(cc.pLengthSQ(a))},cc.pDistance=function(a,b){return cc.pLength(cc.pSub(a,b))},cc.pNormalize=function(a){var b=cc.pLength(a);return 0===b?cc.p(a):cc.pMult(a,1/b)},cc.pForAngle=function(a){return cc.p(Math.cos(a),Math.sin(a))},cc.pToAngle=function(a){return Math.atan2(a.y,a.x)},cc.clampf=function(a,b,c){if(b>c){var d=b;b=c,c=d}return b>a?b:c>a?a:c},cc.pClamp=function(a,b,c){return cc.p(cc.clampf(a.x,b.x,c.x),cc.clampf(a.y,b.y,c.y))},cc.pFromSize=function(a){return cc.p(a.width,a.height)},cc.pCompOp=function(a,b){return cc.p(b(a.x),b(a.y))},cc.pLerp=function(a,b,c){return cc.pAdd(cc.pMult(a,1-c),cc.pMult(b,c))},cc.pFuzzyEqual=function(a,b,c){return a.x-c<=b.x&&b.x<=a.x+c&&a.y-c<=b.y&&b.y<=a.y+c?!0:!1},cc.pCompMult=function(a,b){return cc.p(a.x*b.x,a.y*b.y)},cc.pAngleSigned=function(a,b){var c=cc.pNormalize(a),d=cc.pNormalize(b),e=Math.atan2(c.x*d.y-c.y*d.x,cc.pDot(c,d));return Math.abs(e)=0&&e.x<=1&&e.y>=0&&e.y<=1?!0:!1},cc.pIntersectPoint=function(a,b,c,d){var e=cc.p(0,0);if(cc.pLineIntersect(a,b,c,d,e)){var f=cc.p(0,0);return f.x=a.x+e.x*(b.x-a.x),f.y=a.y+e.x*(b.y-a.y),f}return cc.p(0,0)},cc.pSameAs=function(a,b){return null!=a&&null!=b?a.x===b.x&&a.y===b.y:!1},cc.pZeroIn=function(a){a.x=0,a.y=0},cc.pIn=function(a,b){a.x=b.x,a.y=b.y},cc.pMultIn=function(a,b){a.x*=b,a.y*=b},cc.pSubIn=function(a,b){a.x-=b.x,a.y-=b.y},cc.pAddIn=function(a,b){a.x+=b.x,a.y+=b.y},cc.pNormalizeIn=function(a){cc.pMultIn(a,1/Math.sqrt(a.x*a.x+a.y*a.y))},cc.Touch=cc.Class.extend({_point:null,_prevPoint:null,_id:0,_startPointCaptured:!1,_startPoint:null,ctor:function(a,b,c){this.setTouchInfo(c,a,b)},getLocation:function(){return{x:this._point.x,y:this._point.y}},getLocationX:function(){return this._point.x},getLocationY:function(){return this._point.y},getPreviousLocation:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocation:function(){return{x:this._startPoint.x,y:this._startPoint.y}},getDelta:function(){return cc.pSub(this._point,this._prevPoint)},getLocationInView:function(){return{x:this._point.x,y:this._point.y}},getPreviousLocationInView:function(){return{x:this._prevPoint.x,y:this._prevPoint.y}},getStartLocationInView:function(){return{x:this._startPoint.x,y:this._startPoint.y}},getID:function(){return this._id},getId:function(){return cc.log("getId is deprecated. Please use getID instead."),this._id},setTouchInfo:function(a,b,c){this._prevPoint=this._point,this._point=cc.p(b||0,c||0),this._id=a,this._startPointCaptured||(this._startPoint=cc.p(this._point),this._startPointCaptured=!0)},_setPoint:function(a,b){void 0===b?(this._point.x=a.x,this._point.y=a.y):(this._point.x=a,this._point.y=b)},_setPrevPoint:function(a,b){void 0===b?this._prevPoint=cc.p(a.x,a.y):this._prevPoint=cc.p(a||0,b||0)}}),cc.Event=cc.Class.extend({_type:0,_isStopped:!1,_currentTarget:null,_setCurrentTarget:function(a){this._currentTarget=a},ctor:function(a){this._type=a},getType:function(){return this._type},stopPropagation:function(){this._isStopped=!0},isStopped:function(){return this._isStopped},getCurrentTarget:function(){return this._currentTarget}}),cc.Event.TOUCH=0,cc.Event.KEYBOARD=1,cc.Event.ACCELERATION=2,cc.Event.MOUSE=3,cc.Event.FOCUS=4,cc.Event.CUSTOM=6,cc.EventCustom=cc.Event.extend({_eventName:null,_userData:null,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.CUSTOM),this._eventName=a},setUserData:function(a){this._userData=a},getUserData:function(){return this._userData},getEventName:function(){return this._eventName}}),cc.EventMouse=cc.Event.extend({_eventType:0,_button:0,_x:0,_y:0,_prevX:0,_prevY:0,_scrollX:0,_scrollY:0,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.MOUSE),this._eventType=a},setScrollData:function(a,b){this._scrollX=a,this._scrollY=b},getScrollX:function(){return this._scrollX},getScrollY:function(){return this._scrollY},setLocation:function(a,b){this._x=a,this._y=b},getLocation:function(){return{x:this._x,y:this._y}},getLocationInView:function(){return{x:this._x,y:cc.view._designResolutionSize.height-this._y}},_setPrevCursor:function(a,b){this._prevX=a,this._prevY=b},getDelta:function(){return{x:this._x-this._prevX,y:this._y-this._prevY}},getDeltaX:function(){return this._x-this._prevX},getDeltaY:function(){return this._y-this._prevY},setButton:function(a){this._button=a},getButton:function(){return this._button},getLocationX:function(){return this._x},getLocationY:function(){return this._y}}),cc.EventMouse.NONE=0,cc.EventMouse.DOWN=1,cc.EventMouse.UP=2,cc.EventMouse.MOVE=3,cc.EventMouse.SCROLL=4,cc.EventMouse.BUTTON_LEFT=0,cc.EventMouse.BUTTON_RIGHT=2,cc.EventMouse.BUTTON_MIDDLE=1,cc.EventMouse.BUTTON_4=3,cc.EventMouse.BUTTON_5=4,cc.EventMouse.BUTTON_6=5,cc.EventMouse.BUTTON_7=6,cc.EventMouse.BUTTON_8=7,cc.EventTouch=cc.Event.extend({_eventCode:0,_touches:null,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.TOUCH),this._touches=a||[]},getEventCode:function(){return this._eventCode},getTouches:function(){return this._touches},_setEventCode:function(a){this._eventCode=a},_setTouches:function(a){this._touches=a}}),cc.EventTouch.MAX_TOUCHES=5,cc.EventTouch.EventCode={BEGAN:0,MOVED:1,ENDED:2,CANCELLED:3},cc.EventFocus=cc.Event.extend({_widgetGetFocus:null,_widgetLoseFocus:null,ctor:function(a,b){cc.Event.prototype.ctor.call(this,cc.Event.FOCUS),this._widgetGetFocus=b,this._widgetLoseFocus=a}}),cc.EventListener=cc.Class.extend({_onEvent:null,_type:0,_listenerID:null,_registered:!1,_fixedPriority:0,_node:null,_paused:!0,_isEnabled:!0,ctor:function(a,b,c){this._onEvent=c,this._type=a||0,this._listenerID=b||""},_setPaused:function(a){this._paused=a},_isPaused:function(){return this._paused},_setRegistered:function(a){this._registered=a},_isRegistered:function(){return this._registered},_getType:function(){return this._type},_getListenerID:function(){return this._listenerID},_setFixedPriority:function(a){this._fixedPriority=a},_getFixedPriority:function(){return this._fixedPriority},_setSceneGraphPriority:function(a){this._node=a},_getSceneGraphPriority:function(){return this._node},checkAvailable:function(){return null!==this._onEvent},clone:function(){return null},setEnabled:function(a){this._isEnabled=a},isEnabled:function(){return this._isEnabled},retain:function(){},release:function(){}}),cc.EventListener.UNKNOWN=0,cc.EventListener.TOUCH_ONE_BY_ONE=1,cc.EventListener.TOUCH_ALL_AT_ONCE=2,cc.EventListener.KEYBOARD=3,cc.EventListener.MOUSE=4,cc.EventListener.ACCELERATION=5,cc.EventListener.ACCELERATION=6,cc.EventListener.CUSTOM=8,cc.EventListener.FOCUS=7,cc._EventListenerCustom=cc.EventListener.extend({_onCustomEvent:null,ctor:function(a,b){this._onCustomEvent=b;var c=this,d=function(a){null!==c._onCustomEvent&&c._onCustomEvent(a)};cc.EventListener.prototype.ctor.call(this,cc.EventListener.CUSTOM,a,d)},checkAvailable:function(){return cc.EventListener.prototype.checkAvailable.call(this)&&null!==this._onCustomEvent},clone:function(){return new cc._EventListenerCustom(this._listenerID,this._onCustomEvent)}}),cc._EventListenerCustom.create=function(a,b){return new cc._EventListenerCustom(a,b)},cc._EventListenerMouse=cc.EventListener.extend({onMouseDown:null,onMouseUp:null,onMouseMove:null,onMouseScroll:null,ctor:function(){var a=this,b=function(b){var c=cc.EventMouse;switch(b._eventType){case c.DOWN:a.onMouseDown&&a.onMouseDown(b);break;case c.UP:a.onMouseUp&&a.onMouseUp(b);break;case c.MOVE:a.onMouseMove&&a.onMouseMove(b);break;case c.SCROLL:a.onMouseScroll&&a.onMouseScroll(b)}};cc.EventListener.prototype.ctor.call(this,cc.EventListener.MOUSE,cc._EventListenerMouse.LISTENER_ID,b)},clone:function(){var a=new cc._EventListenerMouse;return a.onMouseDown=this.onMouseDown,a.onMouseUp=this.onMouseUp,a.onMouseMove=this.onMouseMove,a.onMouseScroll=this.onMouseScroll,a},checkAvailable:function(){return!0}}),cc._EventListenerMouse.LISTENER_ID="__cc_mouse",cc._EventListenerMouse.create=function(){return new cc._EventListenerMouse},cc._EventListenerTouchOneByOne=cc.EventListener.extend({_claimedTouches:null,swallowTouches:!1,onTouchBegan:null,onTouchMoved:null,onTouchEnded:null,onTouchCancelled:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.TOUCH_ONE_BY_ONE,cc._EventListenerTouchOneByOne.LISTENER_ID,null),this._claimedTouches=[]},setSwallowTouches:function(a){this.swallowTouches=a},isSwallowTouches:function(){return this.swallowTouches},clone:function(){var a=new cc._EventListenerTouchOneByOne;return a.onTouchBegan=this.onTouchBegan,a.onTouchMoved=this.onTouchMoved,a.onTouchEnded=this.onTouchEnded,a.onTouchCancelled=this.onTouchCancelled,a.swallowTouches=this.swallowTouches,a},checkAvailable:function(){return this.onTouchBegan?!0:(cc.log(cc._LogInfos._EventListenerTouchOneByOne_checkAvailable),!1)}}),cc._EventListenerTouchOneByOne.LISTENER_ID="__cc_touch_one_by_one",cc._EventListenerTouchOneByOne.create=function(){return new cc._EventListenerTouchOneByOne},cc._EventListenerTouchAllAtOnce=cc.EventListener.extend({onTouchesBegan:null,onTouchesMoved:null,onTouchesEnded:null,onTouchesCancelled:null,ctor:function(){cc.EventListener.prototype.ctor.call(this,cc.EventListener.TOUCH_ALL_AT_ONCE,cc._EventListenerTouchAllAtOnce.LISTENER_ID,null)},clone:function(){var a=new cc._EventListenerTouchAllAtOnce;return a.onTouchesBegan=this.onTouchesBegan,a.onTouchesMoved=this.onTouchesMoved,a.onTouchesEnded=this.onTouchesEnded,a.onTouchesCancelled=this.onTouchesCancelled,a},checkAvailable:function(){return null===this.onTouchesBegan&&null===this.onTouchesMoved&&null===this.onTouchesEnded&&null===this.onTouchesCancelled?(cc.log(cc._LogInfos._EventListenerTouchAllAtOnce_checkAvailable),!1):!0}}),cc._EventListenerTouchAllAtOnce.LISTENER_ID="__cc_touch_all_at_once",cc._EventListenerTouchAllAtOnce.create=function(){return new cc._EventListenerTouchAllAtOnce},cc.EventListener.create=function(a){cc.assert(a&&a.event,cc._LogInfos.EventListener_create);var b=a.event;delete a.event;var c=null;b===cc.EventListener.TOUCH_ONE_BY_ONE?c=new cc._EventListenerTouchOneByOne:b===cc.EventListener.TOUCH_ALL_AT_ONCE?c=new cc._EventListenerTouchAllAtOnce:b===cc.EventListener.MOUSE?c=new cc._EventListenerMouse:b===cc.EventListener.CUSTOM?(c=new cc._EventListenerCustom(a.eventName,a.callback),delete a.eventName,delete a.callback):b===cc.EventListener.KEYBOARD?c=new cc._EventListenerKeyboard:b===cc.EventListener.ACCELERATION?(c=new cc._EventListenerAcceleration(a.callback),delete a.callback):b===cc.EventListener.FOCUS&&(c=new cc._EventListenerFocus);for(var d in a)c[d]=a[d];return c},cc._EventListenerFocus=cc.EventListener.extend({clone:function(){var a=new cc._EventListenerFocus;return a.onFocusChanged=this.onFocusChanged,a},checkAvailable:function(){return this.onFocusChanged?!0:(cc.log("Invalid EventListenerFocus!"),!1)},onFocusChanged:null,ctor:function(){var a=function(a){this.onFocusChanged&&this.onFocusChanged(a._widgetLoseFocus,a._widgetGetFocus)};cc.EventListener.prototype.ctor.call(this,cc.EventListener.FOCUS,cc._EventListenerFocus.LISTENER_ID,a)}}),cc._EventListenerFocus.LISTENER_ID="__cc_focus_event",cc._EventListenerVector=cc.Class.extend({_fixedListeners:null,_sceneGraphListeners:null,gt0Index:0,ctor:function(){this._fixedListeners=[],this._sceneGraphListeners=[]},size:function(){return this._fixedListeners.length+this._sceneGraphListeners.length},empty:function(){return 0===this._fixedListeners.length&&0===this._sceneGraphListeners.length},push:function(a){0===a._getFixedPriority()?this._sceneGraphListeners.push(a):this._fixedListeners.push(a)},clearSceneGraphListeners:function(){this._sceneGraphListeners.length=0},clearFixedListeners:function(){this._fixedListeners.length=0},clear:function(){this._sceneGraphListeners.length=0,this._fixedListeners.length=0},getFixedPriorityListeners:function(){return this._fixedListeners},getSceneGraphPriorityListeners:function(){return this._sceneGraphListeners}}),cc.__getListenerID=function(a){var b=cc.Event,c=a.getType();return c===b.ACCELERATION?cc._EventListenerAcceleration.LISTENER_ID:c===b.CUSTOM?a.getEventName():c===b.KEYBOARD?cc._EventListenerKeyboard.LISTENER_ID:c===b.MOUSE?cc._EventListenerMouse.LISTENER_ID:c===b.FOCUS?cc._EventListenerFocus.LISTENER_ID:(c===b.TOUCH&&cc.log(cc._LogInfos.__getListenerID),"")},cc.eventManager={DIRTY_NONE:0,DIRTY_FIXED_PRIORITY:1,DIRTY_SCENE_GRAPH_PRIORITY:2,DIRTY_ALL:3,_listenersMap:{},_priorityDirtyFlagMap:{},_nodeListenersMap:{},_nodePriorityMap:{},_globalZOrderNodeMap:{},_toAddedListeners:[],_dirtyNodes:[],_inDispatch:0,_isEnabled:!1,_nodePriorityIndex:0,_internalCustomListenerIDs:[cc.game.EVENT_HIDE,cc.game.EVENT_SHOW],_setDirtyForNode:function(a){null!=this._nodeListenersMap[a.__instanceId]&&this._dirtyNodes.push(a);for(var b=a.getChildren(),c=0,d=b.length;d>c;c++)this._setDirtyForNode(b[c])},pauseTarget:function(a,b){var c,d,e=this._nodeListenersMap[a.__instanceId];if(e)for(c=0,d=e.length;d>c;c++)e[c]._setPaused(!0);if(b===!0){var f=a.getChildren();for(c=0,d=f.length;d>c;c++)this.pauseTarget(f[c],!0)}},resumeTarget:function(a,b){var c,d,e=this._nodeListenersMap[a.__instanceId];if(e)for(c=0,d=e.length;d>c;c++)e[c]._setPaused(!1);if(this._setDirtyForNode(a),b===!0){var f=a.getChildren();for(c=0,d=f.length;d>c;c++)this.resumeTarget(f[c],!0)}},_addListener:function(a){0===this._inDispatch?this._forceAddEventListener(a):this._toAddedListeners.push(a)},_forceAddEventListener:function(a){var b=a._getListenerID(),c=this._listenersMap[b];if(c||(c=new cc._EventListenerVector,this._listenersMap[b]=c),c.push(a),0===a._getFixedPriority()){this._setDirty(b,this.DIRTY_SCENE_GRAPH_PRIORITY);var d=a._getSceneGraphPriority();null===d&&cc.log(cc._LogInfos.eventManager__forceAddEventListener),this._associateNodeAndEventListener(d,a),d.isRunning()&&this.resumeTarget(d)}else this._setDirty(b,this.DIRTY_FIXED_PRIORITY)},_getListeners:function(a){return this._listenersMap[a]},_updateDirtyFlagForSceneGraph:function(){if(0!==this._dirtyNodes.length){for(var a,b,c=this._dirtyNodes,d=this._nodeListenersMap,e=0,f=c.length;f>e;e++)if(a=d[c[e].__instanceId])for(var g=0,h=a.length;h>g;g++)b=a[g],b&&this._setDirty(b._getListenerID(),this.DIRTY_SCENE_GRAPH_PRIORITY);this._dirtyNodes.length=0}},_removeAllListenersInVector:function(a){if(a)for(var b,c=0;cd&&!(c[d]._getFixedPriority()>=0);)++d;b.gt0Index=d}}},_sortListenersOfFixedPriorityAsc:function(a,b){return a._getFixedPriority()-b._getFixedPriority()},_onUpdateListeners:function(a){var b=this._listenersMap[a];if(b){var c,d,e=b.getFixedPriorityListeners(),f=b.getSceneGraphPriorityListeners();if(f)for(c=0;c0,cc._LogInfos.EventManager__updateListeners),!(b>1)){a.getType()===cc.Event.TOUCH?(this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID)):this._onUpdateListeners(cc.__getListenerID(a)),cc.assert(1===b,cc._LogInfos.EventManager__updateListeners_2);var c=this._listenersMap,d=this._priorityDirtyFlagMap;for(var e in c)c[e].empty()&&(delete d[e],delete c[e]);var f=this._toAddedListeners;if(0!==f.length){for(var g=0,h=f.length;h>g;g++)this._forceAddEventListener(f[g]);this._toAddedListeners.length=0}}},_onTouchEventCallback:function(a,b){if(!a._isRegistered)return!1;var c=b.event,d=b.selTouch;c._setCurrentTarget(a._node);var e,f=!1,g=c.getEventCode(),h=cc.EventTouch.EventCode;return g===h.BEGAN?a.onTouchBegan&&(f=a.onTouchBegan(d,c),f&&a._registered&&a._claimedTouches.push(d)):a._claimedTouches.length>0&&-1!==(e=a._claimedTouches.indexOf(d))&&(f=!0,g===h.MOVED&&a.onTouchMoved?a.onTouchMoved(d,c):g===h.ENDED?(a.onTouchEnded&&a.onTouchEnded(d,c),a._registered&&a._claimedTouches.splice(e,1)):g===h.CANCELLED&&(a.onTouchCancelled&&a.onTouchCancelled(d,c),a._registered&&a._claimedTouches.splice(e,1))),c.isStopped()?(cc.eventManager._updateListeners(c),!0):f&&a._registered&&a.swallowTouches?(b.needsMutableSet&&b.touches.splice(d,1),!0):!1},_dispatchTouchEvent:function(a){this._sortEventListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),this._sortEventListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);var b=this._getListeners(cc._EventListenerTouchOneByOne.LISTENER_ID),c=this._getListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID);if(null!==b||null!==c){var d=a.getTouches(),e=cc.copyArray(d),f={event:a,needsMutableSet:b&&c,touches:e,selTouch:null};if(b)for(var g=0;g0&&(this._dispatchEventToListeners(c,this._onTouchesEventCallback,{event:a,touches:e}),a.isStopped())||this._updateListeners(a)}},_onTouchesEventCallback:function(a,b){if(!a._registered)return!1;var c=cc.EventTouch.EventCode,d=b.event,e=b.touches,f=d.getEventCode();return d._setCurrentTarget(a._node),f===c.BEGAN&&a.onTouchesBegan?a.onTouchesBegan(e,d):f===c.MOVED&&a.onTouchesMoved?a.onTouchesMoved(e,d):f===c.ENDED&&a.onTouchesEnded?a.onTouchesEnded(e,d):f===c.CANCELLED&&a.onTouchesCancelled&&a.onTouchesCancelled(e,d),d.isStopped()?(cc.eventManager._updateListeners(d),!0):!1},_associateNodeAndEventListener:function(a,b){var c=this._nodeListenersMap[a.__instanceId];c||(c=[],this._nodeListenersMap[a.__instanceId]=c),c.push(b)},_dissociateNodeAndEventListener:function(a,b){var c=this._nodeListenersMap[a.__instanceId];c&&(cc.arrayRemoveObject(c,b),0===c.length&&delete this._nodeListenersMap[a.__instanceId])},_dispatchEventToListeners:function(a,b,c){var d,e,f=!1,g=a.getFixedPriorityListeners(),h=a.getSceneGraphPriorityListeners(),i=0;if(g&&0!==g.length)for(;i0){for(var h;e>d&&(h=c[d],h&&h.getLocalZOrder()<0);d++)this._visitTarget(h,!1);for(null!=g[a.__instanceId]&&(f[a.getGlobalZOrder()]||(f[a.getGlobalZOrder()]=[]),f[a.getGlobalZOrder()].push(a.__instanceId));e>d;d++)h=c[d],h&&this._visitTarget(h,!1)}else null!=g[a.__instanceId]&&(f[a.getGlobalZOrder()]||(f[a.getGlobalZOrder()]=[]),f[a.getGlobalZOrder()].push(a.__instanceId));if(b){var i=[];for(var j in f)i.push(j);i.sort(this._sortNumberAsc);var k,l,m=i.length,n=this._nodePriorityMap;for(d=0;m>d;d++)for(k=f[i[d]],l=0;li;i++){var k=h[i];if(k===a){cc.arrayRemoveObject(h,k),k._setRegistered(!1);break}}}},_removeListenerInCallback:function(a,b){if(null==a)return!1;for(var c=0,d=a.length;d>c;c++){var e=a[c];if(e._onCustomEvent===b||e._onEvent===b)return e._setRegistered(!1),null!=e._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(e._getSceneGraphPriority(),e),e._setSceneGraphPriority(null)),0===this._inDispatch&&cc.arrayRemoveObject(a,e),!0}return!1},_removeListenerInVector:function(a,b){if(null==a)return!1;for(var c=0,d=a.length;d>c;c++){var e=a[c];if(e===b)return e._setRegistered(!1),null!=e._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(e._getSceneGraphPriority(),e),e._setSceneGraphPriority(null)),0===this._inDispatch&&cc.arrayRemoveObject(a,e),!0}return!1},removeListeners:function(a,b){var c=this;if(a instanceof cc.Node){delete c._nodePriorityMap[a.__instanceId],cc.arrayRemoveObject(c._dirtyNodes,a);var d,e=c._nodeListenersMap[a.__instanceId];if(e){var f=cc.copyArray(e);for(d=0;dd;d++)c.removeListeners(j[d],!0)}}else a===cc.EventListener.TOUCH_ONE_BY_ONE?c._removeListenersForListenerID(cc._EventListenerTouchOneByOne.LISTENER_ID):a===cc.EventListener.TOUCH_ALL_AT_ONCE?c._removeListenersForListenerID(cc._EventListenerTouchAllAtOnce.LISTENER_ID):a===cc.EventListener.MOUSE?c._removeListenersForListenerID(cc._EventListenerMouse.LISTENER_ID):a===cc.EventListener.ACCELERATION?c._removeListenersForListenerID(cc._EventListenerAcceleration.LISTENER_ID):a===cc.EventListener.KEYBOARD?c._removeListenersForListenerID(cc._EventListenerKeyboard.LISTENER_ID):cc.log(cc._LogInfos.eventManager_removeListeners)},removeCustomListeners:function(a){this._removeListenersForListenerID(a)},removeAllListeners:function(){var a=this._listenersMap,b=this._internalCustomListenerIDs;for(var c in a)-1===b.indexOf(c)&&this._removeListenersForListenerID(c)},setPriority:function(a,b){if(null!=a){var c=this._listenersMap;for(var d in c){var e=c[d],f=e.getFixedPriorityListeners();if(f){var g=f.indexOf(a);if(-1!==g)return null!=a._getSceneGraphPriority()&&cc.log(cc._LogInfos.eventManager_setPriority),void(a._getFixedPriority()!==b&&(a._setFixedPriority(b),this._setDirty(a._getListenerID(),this.DIRTY_FIXED_PRIORITY)))}}}},setEnabled:function(a){this._isEnabled=a},isEnabled:function(){return this._isEnabled},dispatchEvent:function(a){if(this._isEnabled){if(this._updateDirtyFlagForSceneGraph(),this._inDispatch++,!a||!a.getType)throw new Error("event is undefined");if(a.getType()===cc.Event.TOUCH)return this._dispatchTouchEvent(a),void this._inDispatch--;var b=cc.__getListenerID(a);this._sortEventListeners(b);var c=this._listenersMap[b];null!=c&&this._dispatchEventToListeners(c,this._onListenerCallback,a),this._updateListeners(a),this._inDispatch--}},_onListenerCallback:function(a,b){return b._setCurrentTarget(a._getSceneGraphPriority()),a._onEvent(b),b.isStopped()},dispatchCustomEvent:function(a,b){var c=new cc.EventCustom(a);c.setUserData(b),this.dispatchEvent(c)}},cc._tmp.PrototypeCCNode=function(){var a=cc.Node.prototype;cc.defineGetterSetter(a,"x",a.getPositionX,a.setPositionX),cc.defineGetterSetter(a,"y",a.getPositionY,a.setPositionY),a.width,cc.defineGetterSetter(a,"width",a._getWidth,a._setWidth),a.height,cc.defineGetterSetter(a,"height",a._getHeight,a._setHeight),a.anchorX,cc.defineGetterSetter(a,"anchorX",a._getAnchorX,a._setAnchorX),a.anchorY,cc.defineGetterSetter(a,"anchorY",a._getAnchorY,a._setAnchorY),a.skewX,cc.defineGetterSetter(a,"skewX",a.getSkewX,a.setSkewX),a.skewY,cc.defineGetterSetter(a,"skewY",a.getSkewY,a.setSkewY),a.zIndex,cc.defineGetterSetter(a,"zIndex",a.getLocalZOrder,a.setLocalZOrder),a.vertexZ,cc.defineGetterSetter(a,"vertexZ",a.getVertexZ,a.setVertexZ),a.rotation,cc.defineGetterSetter(a,"rotation",a.getRotation,a.setRotation),a.rotationX,cc.defineGetterSetter(a,"rotationX",a.getRotationX,a.setRotationX),a.rotationY,cc.defineGetterSetter(a,"rotationY",a.getRotationY,a.setRotationY),a.scale,cc.defineGetterSetter(a,"scale",a.getScale,a.setScale),a.scaleX,cc.defineGetterSetter(a,"scaleX",a.getScaleX,a.setScaleX),a.scaleY,cc.defineGetterSetter(a,"scaleY",a.getScaleY,a.setScaleY),a.children,cc.defineGetterSetter(a,"children",a.getChildren),a.childrenCount,cc.defineGetterSetter(a,"childrenCount",a.getChildrenCount),a.parent,cc.defineGetterSetter(a,"parent",a.getParent,a.setParent),a.visible,cc.defineGetterSetter(a,"visible",a.isVisible,a.setVisible),a.running,cc.defineGetterSetter(a,"running",a.isRunning),a.ignoreAnchor,cc.defineGetterSetter(a,"ignoreAnchor",a.isIgnoreAnchorPointForPosition,a.ignoreAnchorPointForPosition),a.tag,a.userData,a.userObject,a.arrivalOrder,a.actionManager,cc.defineGetterSetter(a,"actionManager",a.getActionManager,a.setActionManager),a.scheduler,cc.defineGetterSetter(a,"scheduler",a.getScheduler,a.setScheduler),a.shaderProgram,cc.defineGetterSetter(a,"shaderProgram",a.getShaderProgram,a.setShaderProgram),a.opacity,cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity),a.opacityModifyRGB,cc.defineGetterSetter(a,"opacityModifyRGB",a.isOpacityModifyRGB),a.cascadeOpacity,cc.defineGetterSetter(a,"cascadeOpacity",a.isCascadeOpacityEnabled,a.setCascadeOpacityEnabled),a.color,cc.defineGetterSetter(a,"color",a.getColor,a.setColor),a.cascadeColor,cc.defineGetterSetter(a,"cascadeColor",a.isCascadeColorEnabled,a.setCascadeColorEnabled)},cc.NODE_TAG_INVALID=-1,cc.s_globalOrderOfArrival=1,cc.Node=cc.Class.extend({_localZOrder:0,_globalZOrder:0,_vertexZ:0,_rotationX:0,_rotationY:0,_scaleX:1,_scaleY:1,_position:null,_normalizedPosition:null,_usingNormalizedPosition:!1,_normalizedPositionDirty:!1,_skewX:0,_skewY:0,_children:null,_visible:!0,_anchorPoint:null,_contentSize:null,_running:!1,_parent:null,_ignoreAnchorPointForPosition:!1,tag:cc.NODE_TAG_INVALID,userData:null,userObject:null,_reorderChildDirty:!1,_shaderProgram:null,arrivalOrder:0,_actionManager:null,_scheduler:null,_eventDispatcher:null,_additionalTransformDirty:!1,_additionalTransform:null,_componentContainer:null,_isTransitionFinished:!1,_className:"Node",_showNode:!1,_name:"",_realOpacity:255,_realColor:null,_cascadeColorEnabled:!1,_cascadeOpacityEnabled:!1,_renderCmd:null,_camera:null,ctor:function(){this._initNode(),this._initRendererCmd()},_initNode:function(){var a=this;a._anchorPoint=cc.p(0,0),a._contentSize=cc.size(0,0),a._position=cc.p(0,0),a._normalizedPosition=cc.p(0,0),a._children=[];var b=cc.director;a._actionManager=b.getActionManager(),a._scheduler=b.getScheduler(),a._additionalTransform=cc.affineTransformMakeIdentity(),cc.ComponentContainer&&(a._componentContainer=new cc.ComponentContainer(a)),this._realOpacity=255,this._realColor=cc.color(255,255,255,255),this._cascadeColorEnabled=!1,this._cascadeOpacityEnabled=!1},init:function(){return!0},_arrayMakeObjectsPerformSelector:function(a,b){if(a&&0!==a.length){var c,d,e=a.length,f=cc.Node._stateCallbackType;switch(b){case f.onEnter:for(c=0;e>c;c++)d=a[c],d&&d.onEnter();break;case f.onExit:for(c=0;e>c;c++)d=a[c],d&&d.onExit();break;case f.onEnterTransitionDidFinish:for(c=0;e>c;c++)d=a[c],d&&d.onEnterTransitionDidFinish();break;case f.cleanup:for(c=0;e>c;c++)d=a[c],d&&d.cleanup();break;case f.updateTransform:for(c=0;e>c;c++)d=a[c],d&&d.updateTransform();break;case f.onExitTransitionDidStart:for(c=0;e>c;c++)d=a[c],d&&d.onExitTransitionDidStart();break;case f.sortAllChildren:for(c=0;e>c;c++)d=a[c],d&&d.sortAllChildren();break;default:cc.assert(0,cc._LogInfos.Node__arrayMakeObjectsPerformSelector)}}},attr:function(a){for(var b in a)this[b]=a[b]},getSkewX:function(){return this._skewX},setSkewX:function(a){this._skewX=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getSkewY:function(){return this._skewY},setSkewY:function(a){this._skewY=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setLocalZOrder:function(a){this._localZOrder=a,this._parent&&this._parent.reorderChild(this,a),cc.eventManager._setDirtyForNode(this)},_setLocalZOrder:function(a){this._localZOrder=a},getLocalZOrder:function(){return this._localZOrder},getZOrder:function(){return cc.log(cc._LogInfos.Node_getZOrder),this.getLocalZOrder()},setZOrder:function(a){cc.log(cc._LogInfos.Node_setZOrder),this.setLocalZOrder(a)},setGlobalZOrder:function(a){this._globalZOrder!==a&&(this._globalZOrder=a,cc.eventManager._setDirtyForNode(this))},getGlobalZOrder:function(){return this._globalZOrder},getVertexZ:function(){return this._vertexZ},setVertexZ:function(a){this._vertexZ=a},getRotation:function(){return this._rotationX!==this._rotationY&&cc.log(cc._LogInfos.Node_getRotation),this._rotationX},setRotation:function(a){this._rotationX=this._rotationY=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getRotationX:function(){return this._rotationX},setRotationX:function(a){this._rotationX=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getRotationY:function(){return this._rotationY},setRotationY:function(a){this._rotationY=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScale:function(){return this._scaleX!==this._scaleY&&cc.log(cc._LogInfos.Node_getScale),this._scaleX},setScale:function(a,b){this._scaleX=a,this._scaleY=b||0===b?b:a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScaleX:function(){return this._scaleX},setScaleX:function(a){this._scaleX=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getScaleY:function(){return this._scaleY},setScaleY:function(a){this._scaleY=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setPosition:function(a,b){var c=this._position;if(void 0===b){if(c.x===a.x&&c.y===a.y)return;c.x=a.x,c.y=a.y}else{if(c.x===a&&c.y===b)return;c.x=a,c.y=b}this._usingNormalizedPosition=!1,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setNormalizedPosition:function(a,b){var c=this._normalizedPosition;void 0===b?(c.x=a.x,c.y=a.y):(c.x=a,c.y=b),this._normalizedPositionDirty=this._usingNormalizedPosition=!0,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getPosition:function(){return cc.p(this._position)},getNormalizedPosition:function(){return cc.p(this._normalizedPosition)},getPositionX:function(){return this._position.x},setPositionX:function(a){this._position.x=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getPositionY:function(){return this._position.y},setPositionY:function(a){this._position.y=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getChildrenCount:function(){return this._children.length},getChildren:function(){return this._children},isVisible:function(){return this._visible},setVisible:function(a){this._visible!==a&&(this._visible=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),cc.renderer.childrenOrderDirty=!0)},getAnchorPoint:function(){return cc.p(this._anchorPoint)},setAnchorPoint:function(a,b){var c=this._anchorPoint;if(void 0===b){if(a.x===c.x&&a.y===c.y)return;c.x=a.x,c.y=a.y}else{if(a===c.x&&b===c.y)return;c.x=a,c.y=b}this._renderCmd._updateAnchorPointInPoint()},_getAnchorX:function(){return this._anchorPoint.x},_setAnchorX:function(a){this._anchorPoint.x!==a&&(this._anchorPoint.x=a,this._renderCmd._updateAnchorPointInPoint())},_getAnchorY:function(){return this._anchorPoint.y},_setAnchorY:function(a){this._anchorPoint.y!==a&&(this._anchorPoint.y=a,this._renderCmd._updateAnchorPointInPoint())},getAnchorPointInPoints:function(){return this._renderCmd.getAnchorPointInPoints()},_getWidth:function(){return this._contentSize.width},_setWidth:function(a){this._contentSize.width=a,this._renderCmd._updateAnchorPointInPoint()},_getHeight:function(){return this._contentSize.height},_setHeight:function(a){this._contentSize.height=a,this._renderCmd._updateAnchorPointInPoint()},getContentSize:function(){return cc.size(this._contentSize)},setContentSize:function(a,b){var c=this._contentSize;if(void 0===b){if(a.width===c.width&&a.height===c.height)return;c.width=a.width,c.height=a.height}else{if(a===c.width&&b===c.height)return;c.width=a,c.height=b}this._renderCmd._updateAnchorPointInPoint()},isRunning:function(){return this._running},getParent:function(){return this._parent},setParent:function(a){this._parent=a},isIgnoreAnchorPointForPosition:function(){return this._ignoreAnchorPointForPosition},ignoreAnchorPointForPosition:function(a){a!==this._ignoreAnchorPointForPosition&&(this._ignoreAnchorPointForPosition=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty))},getTag:function(){return this.tag},setTag:function(a){this.tag=a},setName:function(a){this._name=a},getName:function(){return this._name},getUserData:function(){return this.userData},setUserData:function(a){this.userData=a},getUserObject:function(){return this.userObject},setUserObject:function(a){this.userObject!==a&&(this.userObject=a)},getOrderOfArrival:function(){return this.arrivalOrder},setOrderOfArrival:function(a){this.arrivalOrder=a},getActionManager:function(){return this._actionManager||(this._actionManager=cc.director.getActionManager()),this._actionManager},setActionManager:function(a){this._actionManager!==a&&(this.stopAllActions(),this._actionManager=a)},getScheduler:function(){return this._scheduler||(this._scheduler=cc.director.getScheduler()),this._scheduler},setScheduler:function(a){this._scheduler!==a&&(this.unscheduleAllCallbacks(),this._scheduler=a)},boundingBox:function(){return cc.log(cc._LogInfos.Node_boundingBox),this.getBoundingBox()},getBoundingBox:function(){var a=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc._rectApplyAffineTransformIn(a,this.getNodeToParentTransform())},cleanup:function(){this.stopAllActions(),this.unscheduleAllCallbacks(),cc.eventManager.removeListeners(this),this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.cleanup)},getChildByTag:function(a){var b=this._children;if(null!==b)for(var c=0;cc;c++)if(b[c]._name===a)return b[c];return null},addChild:function(a,b,c){b=void 0===b?a._localZOrder:b;var d,e=!1;cc.isUndefined(c)?(c=void 0,d=a._name):cc.isString(c)?(d=c,c=void 0):cc.isNumber(c)&&(e=!0,d=""),cc.assert(a,cc._LogInfos.Node_addChild_3),cc.assert(null===a._parent,"child already added. It can't be added again"),this._addChildHelper(a,b,c,d,e)},_addChildHelper:function(a,b,c,d,e){this._children||(this._children=[]),this._insertChild(a,b),e?a.setTag(c):a.setName(d),a.setParent(this),a.setOrderOfArrival(cc.s_globalOrderOfArrival++),this._running&&(a.onEnter(),this._isTransitionFinished&&a.onEnterTransitionDidFinish()),this._cascadeColorEnabled&&a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty),this._cascadeOpacityEnabled&&a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},removeFromParent:function(a){this._parent&&(void 0===a&&(a=!0),this._parent.removeChild(this,a))},removeFromParentAndCleanup:function(a){cc.log(cc._LogInfos.Node_removeFromParentAndCleanup),this.removeFromParent(a)},removeChild:function(a,b){0!==this._children.length&&(void 0===b&&(b=!0),this._children.indexOf(a)>-1&&this._detachChild(a,b),cc.renderer.childrenOrderDirty=!0)},removeChildByTag:function(a,b){a===cc.NODE_TAG_INVALID&&cc.log(cc._LogInfos.Node_removeChildByTag);var c=this.getChildByTag(a);c?this.removeChild(c,b):cc.log(cc._LogInfos.Node_removeChildByTag_2,a)},removeAllChildrenWithCleanup:function(a){this.removeAllChildren(a)},removeAllChildren:function(a){var b=this._children;if(null!==b){void 0===a&&(a=!0);for(var c=0;ca;a++){for(c=d[a],b=a-1;b>=0;){if(c._localZOrder=0,cc._LogInfos.Node_schedule_2),b=b||0,c=null==c?cc.REPEAT_FOREVER:c,d=d||0,this.scheduler.schedule(a,this,b,c,d,!this._running,e)},scheduleOnce:function(a,b,c){void 0===c&&(c=this.__instanceId),this.schedule(a,0,0,b,c)},unschedule:function(a){a&&this.scheduler.unschedule(a,this)},unscheduleAllCallbacks:function(){this.scheduler.unscheduleAllForTarget(this)},resumeSchedulerAndActions:function(){cc.log(cc._LogInfos.Node_resumeSchedulerAndActions),this.resume()},resume:function(){this.scheduler.resumeTarget(this),this.actionManager&&this.actionManager.resumeTarget(this),cc.eventManager.resumeTarget(this)},pauseSchedulerAndActions:function(){cc.log(cc._LogInfos.Node_pauseSchedulerAndActions),this.pause()},pause:function(){this.scheduler.pauseTarget(this),this.actionManager&&this.actionManager.pauseTarget(this),cc.eventManager.pauseTarget(this)},setAdditionalTransform:function(a){return void 0===a?this._additionalTransformDirty=!1:(this._additionalTransform=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),void(this._additionalTransformDirty=!0))},getParentToNodeTransform:function(){this._renderCmd.getParentToNodeTransform()},parentToNodeTransform:function(){return this.getParentToNodeTransform()},getNodeToWorldTransform:function(){for(var a=this.getNodeToParentTransform(),b=this._parent;null!==b;b=b.parent)a=cc.affineTransformConcat(a,b.getNodeToParentTransform());return a},nodeToWorldTransform:function(){return this.getNodeToWorldTransform()},getWorldToNodeTransform:function(){return cc.affineTransformInvert(this.getNodeToWorldTransform())},worldToNodeTransform:function(){return this.getWorldToNodeTransform()},convertToNodeSpace:function(a){return cc.pointApplyAffineTransform(a,this.getWorldToNodeTransform())},convertToWorldSpace:function(a){return a=a||cc.p(0,0),cc.pointApplyAffineTransform(a,this.getNodeToWorldTransform())},convertToNodeSpaceAR:function(a){return cc.pSub(this.convertToNodeSpace(a),this._renderCmd.getAnchorPointInPoints())},convertToWorldSpaceAR:function(a){a=a||cc.p(0,0);var b=cc.pAdd(a,this._renderCmd.getAnchorPointInPoints());return this.convertToWorldSpace(b)},_convertToWindowSpace:function(a){var b=this.convertToWorldSpace(a);return cc.director.convertToUI(b)},convertTouchToNodeSpace:function(a){var b=a.getLocation();return this.convertToNodeSpace(b)},convertTouchToNodeSpaceAR:function(a){var b=cc.director.convertToGL(a.getLocation());return this.convertToNodeSpaceAR(b)},update:function(a){this._componentContainer&&!this._componentContainer.isEmpty()&&this._componentContainer.visit(a)},updateTransform:function(){this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.updateTransform)},retain:function(){},release:function(){},getComponent:function(a){return this._componentContainer?this._componentContainer.getComponent(a):null},addComponent:function(a){this._componentContainer&&this._componentContainer.add(a)},removeComponent:function(a){return this._componentContainer?this._componentContainer.remove(a):!1},removeAllComponents:function(){this._componentContainer&&this._componentContainer.removeAll()},grid:null,visit:function(a){this._renderCmd.visit(a)},transform:function(a,b){this._renderCmd.transform(a,b)},nodeToParentTransform:function(){return this.getNodeToParentTransform()},getNodeToParentTransform:function(a){var b=this._renderCmd.getNodeToParentTransform();if(a){for(var c={a:b.a,b:b.b,c:b.c,d:b.d,tx:b.tx,ty:b.ty},d=this._parent;null!=d&&d!=a;d=d.getParent())cc.affineTransformConcatIn(c,d.getNodeToParentTransform());return c}return b},getNodeToParentAffineTransform:function(a){return this.getNodeToParentTransform(a)},getCamera:function(){return this._camera||(this._camera=new cc.Camera),this._camera},getGrid:function(){return this.grid},setGrid:function(a){this.grid=a},getShaderProgram:function(){return this._renderCmd.getShaderProgram()},setShaderProgram:function(a){this._renderCmd.setShaderProgram(a)},getGLServerState:function(){return 0},setGLServerState:function(a){},getBoundingBoxToWorld:function(){var a=cc.rect(0,0,this._contentSize.width,this._contentSize.height),b=this.getNodeToWorldTransform();if(a=cc.rectApplyAffineTransform(a,b),!this._children)return a;for(var c=this._children,d=0;d2&&"/"===a[0]&&"/"===a[1]&&(f=!0,d=2,e-=2);var g=!1;c>3&&"/"===a[c-3]&&"."===a[c-2]&&"."===a[c-1]&&(g=!0,e-=3);var h=a.substr(d,e);g&&(h="[[:alnum:]]+/"+h),f?this.doEnumerateRecursive(this,h,b):this.doEnumerate(h,b)},doEnumerateRecursive:function(a,b,c){var d=!1;if(a.doEnumerate(b,c))d=!0;else for(var e,f=a.getChildren(),g=f.length,h=0;g>h;h++)if(e=f[h],this.doEnumerateRecursive(e,b,c)){d=!0;break}},doEnumerate:function(a,b){var c=a.indexOf("/"),d=a,e=!1;-1!==c&&(d=a.substr(0,c),e=!0);for(var f,g=!1,h=this._children,i=h.length,j=0;i>j;j++)if(f=h[j],-1!==f._name.indexOf(d))if(e){if(g=f.doEnumerate(a,b))break}else if(b(f)){g=!0;break}return g}}),cc.Node.create=function(){return new cc.Node},cc.Node._stateCallbackType={onEnter:1,onExit:2,cleanup:3,onEnterTransitionDidFinish:4,updateTransform:5,onExitTransitionDidStart:6,sortAllChildren:7},cc.assert(cc.isFunction(cc._tmp.PrototypeCCNode),cc._LogInfos.MissingFile,"BaseNodesPropertyDefine.js"),cc._tmp.PrototypeCCNode(),delete cc._tmp.PrototypeCCNode,cc.CustomRenderCmd=function(a,b){this._needDraw=!0,this._target=a,this._callback=b,this.rendering=function(a,b,c){this._callback&&this._callback.call(this._target,a,b,c)}},cc.Node._dirtyFlags={transformDirty:1,visibleDirty:2,colorDirty:4,opacityDirty:8,cacheDirty:16,orderDirty:32,textDirty:64,gradientDirty:128,all:255},cc.Node.RenderCmd=function(a){this._dirtyFlag=1,this._node=a,this._needDraw=!1,this._anchorPointInPoints=new cc.Point(0,0),this._transform={a:1,b:0,c:0,d:1,tx:0,ty:0},this._worldTransform={a:1,b:0,c:0,d:1,tx:0,ty:0},this._inverse={a:1,b:0,c:0,d:1,tx:0,ty:0},this._displayedOpacity=255,this._displayedColor=cc.color(255,255,255,255),this._cascadeColorEnabledDirty=!1,this._cascadeOpacityEnabledDirty=!1,this._curLevel=-1},cc.Node.RenderCmd.prototype={constructor:cc.Node.RenderCmd,getAnchorPointInPoints:function(){return cc.p(this._anchorPointInPoints)},getDisplayedColor:function(){var a=this._displayedColor;return cc.color(a.r,a.g,a.b,a.a)},getDisplayedOpacity:function(){return this._displayedOpacity},setCascadeColorEnabledDirty:function(){this._cascadeColorEnabledDirty=!0,this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},setCascadeOpacityEnabledDirty:function(){this._cascadeOpacityEnabledDirty=!0,this.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getParentToNodeTransform:function(){return this._dirtyFlag&cc.Node._dirtyFlags.transformDirty&&(this._inverse=cc.affineTransformInvert(this.getNodeToParentTransform())),this._inverse},detachFromParent:function(){},_updateAnchorPointInPoint:function(){var a=this._anchorPointInPoints,b=this._node._contentSize,c=this._node._anchorPoint;a.x=b.width*c.x,a.y=b.height*c.y,this.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},setDirtyFlag:function(a){0===this._dirtyFlag&&0!==a&&cc.renderer.pushDirtyNode(this),this._dirtyFlag|=a},getParentRenderCmd:function(){return this._node&&this._node._parent&&this._node._parent._renderCmd?this._node._parent._renderCmd:null},_updateDisplayColor:function(a){var b,c,d,e,f=this._node,g=this._displayedColor,h=f._realColor;if(this._cascadeColorEnabledDirty&&!f._cascadeColorEnabled){g.r=h.r,g.g=h.g,g.b=h.b;var i=new cc.Color(255,255,255,255);for(d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&e._renderCmd._updateDisplayColor(i);this._cascadeColorEnabledDirty=!1}else{if(void 0===a){var j=f._parent;a=j&&j._cascadeColorEnabled?j.getDisplayedColor():cc.color.WHITE}if(g.r=0|h.r*a.r/255,g.g=0|h.g*a.g/255,g.b=0|h.b*a.b/255,f._cascadeColorEnabled)for(d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&(e._renderCmd._updateDisplayColor(g),e._renderCmd._updateColor())}this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.colorDirty^this._dirtyFlag},_updateDisplayOpacity:function(a){var b,c,d,e,f=this._node;if(this._cascadeOpacityEnabledDirty&&!f._cascadeOpacityEnabled){for(this._displayedOpacity=f._realOpacity,d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&e._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else{if(void 0===a){var g=f._parent;a=255,g&&g._cascadeOpacityEnabled&&(a=g.getDisplayedOpacity())}if(this._displayedOpacity=f._realOpacity*a/255,f._cascadeOpacityEnabled)for(d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&(e._renderCmd._updateDisplayOpacity(this._displayedOpacity),e._renderCmd._updateColor())}this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.opacityDirty^this._dirtyFlag},_syncDisplayColor:function(a){var b=this._node,c=this._displayedColor,d=b._realColor;if(void 0===a){var e=b._parent;a=e&&e._cascadeColorEnabled?e.getDisplayedColor():cc.color.WHITE}c.r=0|d.r*a.r/255,c.g=0|d.g*a.g/255,c.b=0|d.b*a.b/255},_syncDisplayOpacity:function(a){var b=this._node;if(void 0===a){var c=b._parent;a=255,c&&c._cascadeOpacityEnabled&&(a=c.getDisplayedOpacity())}this._displayedOpacity=b._realOpacity*a/255},_updateColor:function(){},updateStatus:function(){var a=cc.Node._dirtyFlags,b=this._dirtyFlag,c=b&a.colorDirty,d=b&a.opacityDirty;c&&this._updateDisplayColor(),d&&this._updateDisplayOpacity(),(c||d)&&this._updateColor(),b&a.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag=this._dirtyFlag&a.transformDirty^this._dirtyFlag),b&a.orderDirty&&(this._dirtyFlag=this._dirtyFlag&a.orderDirty^this._dirtyFlag)},getNodeToParentTransform:function(){var a=this._node;if(a._usingNormalizedPosition&&a._parent){var b=a._parent._contentSize;a._position.x=a._normalizedPosition.x*b.width,a._position.y=a._normalizedPosition.y*b.height,a._normalizedPositionDirty=!1,this._dirtyFlag=this._dirtyFlag|cc.Node._dirtyFlags.transformDirty}if(this._dirtyFlag&cc.Node._dirtyFlags.transformDirty){var c=this._transform;c.tx=a._position.x,c.ty=a._position.y;var d=1,e=0,f=0,g=1;if(a._rotationX){ +var h=.017453292519943295*a._rotationX;f=Math.sin(h),g=Math.cos(h)}if(a._rotationY){var i=.017453292519943295*a._rotationY;d=Math.cos(i),e=-Math.sin(i)}c.a=d,c.b=e,c.c=f,c.d=g;var j=a._scaleX,k=a._scaleY,l=this._anchorPointInPoints.x,m=this._anchorPointInPoints.y,n=1e-6>j&&j>-1e-6?1e-6:j,o=1e-6>k&&k>-1e-6?1e-6:k;if((1!==j||1!==k)&&(d=c.a*=n,e=c.b*=n,f=c.c*=o,g=c.d*=o),a._skewX||a._skewY){var p=Math.tan(-a._skewX*Math.PI/180),q=Math.tan(-a._skewY*Math.PI/180);p===1/0&&(p=99999999),q===1/0&&(q=99999999);var r=m*p,s=l*q;c.a=d-f*q,c.b=e-g*q,c.c=f-d*p,c.d=g-e*p,c.tx+=d*r+f*s,c.ty+=e*r+g*s}c.tx-=d*l+f*m,c.ty-=e*l+g*m,a._ignoreAnchorPointForPosition&&(c.tx+=l,c.ty+=m),a._additionalTransformDirty&&(this._transform=cc.affineTransformConcat(c,a._additionalTransform))}return this._transform},_syncStatus:function(a){var b=cc.Node._dirtyFlags,c=this._dirtyFlag,d=a?a._node:null;d&&d._cascadeColorEnabled&&a._dirtyFlag&b.colorDirty&&(c|=b.colorDirty),d&&d._cascadeOpacityEnabled&&a._dirtyFlag&b.opacityDirty&&(c|=b.opacityDirty),a&&a._dirtyFlag&b.transformDirty&&(c|=b.transformDirty);var e=c&b.colorDirty,f=c&b.opacityDirty;this._dirtyFlag=c,e&&this._syncDisplayColor(),f&&this._syncDisplayOpacity(),(e||f)&&this._updateColor(),(cc._renderType===cc.game.RENDER_TYPE_WEBGL||c&b.transformDirty)&&this.transform(a,!0),c&b.orderDirty&&(this._dirtyFlag=this._dirtyFlag&b.orderDirty^this._dirtyFlag)},visitChildren:function(){var a,b,c=this._node,d=c._children,e=d.length;if(e>0){for(c.sortAllChildren(),a=0;e>a&&(b=d[a],b._localZOrder<0);a++)b._renderCmd.visit(this);for(cc.renderer.pushRenderCommand(this);e>a;a++)d[a]._renderCmd.visit(this)}else cc.renderer.pushRenderCommand(this);this._dirtyFlag=0}},function(){cc.Node.CanvasRenderCmd=function(a){cc.Node.RenderCmd.call(this,a),this._cachedParent=null,this._cacheDirty=!1};var a=cc.Node.CanvasRenderCmd.prototype=Object.create(cc.Node.RenderCmd.prototype);a.constructor=cc.Node.CanvasRenderCmd,a.transform=function(a,b){var c=this.getNodeToParentTransform(),d=this._worldTransform;if(this._cacheDirty=!0,a){var e=a._worldTransform;d.a=c.a*e.a+c.b*e.c,d.b=c.a*e.b+c.b*e.d,d.c=c.c*e.a+c.d*e.c,d.d=c.c*e.b+c.d*e.d,d.tx=e.a*c.tx+e.c*c.ty+e.tx,d.ty=e.d*c.ty+e.ty+e.b*c.tx}else d.a=c.a,d.b=c.b,d.c=c.c,d.d=c.d,d.tx=c.tx,d.ty=c.ty;if(b){var f=this._node._children;if(!f||0===f.length)return;var g,h;for(g=0,h=f.length;h>g;g++)f[g]._renderCmd.transform(this,b)}},a.visit=function(a){var b=this._node;b._visible&&(a=a||this.getParentRenderCmd(),a&&(this._curLevel=a._curLevel+1),this._syncStatus(a),this.visitChildren())},a.setDirtyFlag=function(a,b){cc.Node.RenderCmd.prototype.setDirtyFlag.call(this,a,b),this._setCacheDirty(b),this._cachedParent&&this._cachedParent.setDirtyFlag(a,!0)},a._setCacheDirty=function(){if(this._cacheDirty===!1){this._cacheDirty=!0;var a=this._cachedParent;a&&a!==this&&a._setNodeDirtyForCache&&a._setNodeDirtyForCache()}},a._setCachedParent=function(a){if(this._cachedParent!==a){this._cachedParent=a;for(var b=this._node._children,c=0,d=b.length;d>c;c++)b[c]._renderCmd._setCachedParent(a)}},a.detachFromParent=function(){this._cachedParent=null;for(var a,b=this._node._children,c=0,d=b.length;d>c;c++)a=b[c],a&&a._renderCmd&&a._renderCmd.detachFromParent()},a.setShaderProgram=function(a){},a.getShaderProgram=function(){return null},cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc=function(a){return a?a.src===cc.SRC_ALPHA&&a.dst===cc.ONE||a.src===cc.ONE&&a.dst===cc.ONE?"lighter":a.src===cc.ZERO&&a.dst===cc.SRC_ALPHA?"destination-in":a.src===cc.ZERO&&a.dst===cc.ONE_MINUS_SRC_ALPHA?"destination-out":"source-over":"source-over"}}(),cc._tmp.PrototypeTexture2D=function(){var a=cc.Texture2D;a.PVRImagesHavePremultipliedAlpha=function(a){cc.PVRHaveAlphaPremultiplied_=a},a.PIXEL_FORMAT_RGBA8888=2,a.PIXEL_FORMAT_RGB888=3,a.PIXEL_FORMAT_RGB565=4,a.PIXEL_FORMAT_A8=5,a.PIXEL_FORMAT_I8=6,a.PIXEL_FORMAT_AI88=7,a.PIXEL_FORMAT_RGBA4444=8,a.PIXEL_FORMAT_RGB5A1=7,a.PIXEL_FORMAT_PVRTC4=9,a.PIXEL_FORMAT_PVRTC2=10,a.PIXEL_FORMAT_DEFAULT=a.PIXEL_FORMAT_RGBA8888,a.defaultPixelFormat=a.PIXEL_FORMAT_DEFAULT;var b=cc.Texture2D._M={};b[a.PIXEL_FORMAT_RGBA8888]="RGBA8888",b[a.PIXEL_FORMAT_RGB888]="RGB888",b[a.PIXEL_FORMAT_RGB565]="RGB565",b[a.PIXEL_FORMAT_A8]="A8",b[a.PIXEL_FORMAT_I8]="I8",b[a.PIXEL_FORMAT_AI88]="AI88",b[a.PIXEL_FORMAT_RGBA4444]="RGBA4444",b[a.PIXEL_FORMAT_RGB5A1]="RGB5A1",b[a.PIXEL_FORMAT_PVRTC4]="PVRTC4",b[a.PIXEL_FORMAT_PVRTC2]="PVRTC2";var c=cc.Texture2D._B={};c[a.PIXEL_FORMAT_RGBA8888]=32,c[a.PIXEL_FORMAT_RGB888]=24,c[a.PIXEL_FORMAT_RGB565]=16,c[a.PIXEL_FORMAT_A8]=8,c[a.PIXEL_FORMAT_I8]=8,c[a.PIXEL_FORMAT_AI88]=16,c[a.PIXEL_FORMAT_RGBA4444]=16,c[a.PIXEL_FORMAT_RGB5A1]=16,c[a.PIXEL_FORMAT_PVRTC4]=4,c[a.PIXEL_FORMAT_PVRTC2]=3;var d=cc.Texture2D.prototype;d.name,cc.defineGetterSetter(d,"name",d.getName),d.pixelFormat,cc.defineGetterSetter(d,"pixelFormat",d.getPixelFormat),d.pixelsWidth,cc.defineGetterSetter(d,"pixelsWidth",d.getPixelsWide),d.pixelsHeight,cc.defineGetterSetter(d,"pixelsHeight",d.getPixelsHigh),d.width,cc.defineGetterSetter(d,"width",d._getWidth),d.height,cc.defineGetterSetter(d,"height",d._getHeight)},cc._tmp.PrototypeTextureAtlas=function(){var a=cc.TextureAtlas.prototype;a.totalQuads,cc.defineGetterSetter(a,"totalQuads",a.getTotalQuads),a.capacity,cc.defineGetterSetter(a,"capacity",a.getCapacity),a.quads,cc.defineGetterSetter(a,"quads",a.getQuads,a.setQuads)},cc._tmp.WebGLTexture2D=function(){cc.Texture2D=cc.Class.extend({_pVRHaveAlphaPremultiplied:!0,_pixelFormat:null,_pixelsWide:0,_pixelsHigh:0,_name:"",_contentSize:null,maxS:0,maxT:0,_hasPremultipliedAlpha:!1,_hasMipmaps:!1,shaderProgram:null,_textureLoaded:!1,_htmlElementObj:null,_webTextureObj:null,url:null,ctor:function(){this._contentSize=cc.size(0,0),this._pixelFormat=cc.Texture2D.defaultPixelFormat},releaseTexture:function(){this._webTextureObj&&cc._renderContext.deleteTexture(this._webTextureObj),cc.loader.release(this.url)},getPixelFormat:function(){return this._pixelFormat},getPixelsWide:function(){return this._pixelsWide},getPixelsHigh:function(){return this._pixelsHigh},getName:function(){return this._webTextureObj},getContentSize:function(){return cc.size(this._contentSize.width/cc.contentScaleFactor(),this._contentSize.height/cc.contentScaleFactor())},_getWidth:function(){return this._contentSize.width/cc.contentScaleFactor()},_getHeight:function(){return this._contentSize.height/cc.contentScaleFactor()},getContentSizeInPixels:function(){return this._contentSize},getMaxS:function(){return this.maxS},setMaxS:function(a){this.maxS=a},getMaxT:function(){return this.maxT},setMaxT:function(a){this.maxT=a},getShaderProgram:function(){return this.shaderProgram},setShaderProgram:function(a){this.shaderProgram=a},hasPremultipliedAlpha:function(){return this._hasPremultipliedAlpha},hasMipmaps:function(){return this._hasMipmaps},description:function(){var a=this;return""},releaseData:function(a){a=null},keepData:function(a,b){return a},initWithData:function(a,b,c,d,e){var f=this,g=cc.Texture2D,h=cc._renderContext,i=h.RGBA,j=h.UNSIGNED_BYTE,k=cc.Texture2D._B[b],l=c*k/8;switch(l%8===0?h.pixelStorei(h.UNPACK_ALIGNMENT,8):l%4===0?h.pixelStorei(h.UNPACK_ALIGNMENT,4):l%2===0?h.pixelStorei(h.UNPACK_ALIGNMENT,2):h.pixelStorei(h.UNPACK_ALIGNMENT,1),f._webTextureObj=h.createTexture(),cc.glBindTexture2D(f),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.LINEAR),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),b){case g.PIXEL_FORMAT_RGBA8888:i=h.RGBA;break;case g.PIXEL_FORMAT_RGB888:i=h.RGB;break;case g.PIXEL_FORMAT_RGBA4444:j=h.UNSIGNED_SHORT_4_4_4_4;break;case g.PIXEL_FORMAT_RGB5A1:j=h.UNSIGNED_SHORT_5_5_5_1;break;case g.PIXEL_FORMAT_RGB565:j=h.UNSIGNED_SHORT_5_6_5;break;case g.PIXEL_FORMAT_AI88:i=h.LUMINANCE_ALPHA;break;case g.PIXEL_FORMAT_A8:i=h.ALPHA;break;case g.PIXEL_FORMAT_I8:i=h.LUMINANCE;break;default:cc.assert(0,cc._LogInfos.Texture2D_initWithData)}return h.texImage2D(h.TEXTURE_2D,0,i,c,d,0,i,j,a),f._contentSize.width=e.width,f._contentSize.height=e.height,f._pixelsWide=c,f._pixelsHigh=d,f._pixelFormat=b,f.maxS=e.width/c,f.maxT=e.height/d,f._hasPremultipliedAlpha=!1,f._hasMipmaps=!1,f.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE),f._textureLoaded=!0,!0},drawAtPoint:function(a){var b=this,c=[0,b.maxT,b.maxS,b.maxT,0,0,b.maxS,0],d=b._pixelsWide*b.maxS,e=b._pixelsHigh*b.maxT,f=[a.x,a.y,0,d+a.x,a.y,0,a.x,e+a.y,0,d+a.x,e+a.y,0];cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS),b._shaderProgram.use(),b._shaderProgram.setUniformsForBuiltins(),cc.glBindTexture2D(b);var g=cc._renderContext;g.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,g.FLOAT,!1,0,f),g.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,g.FLOAT,!1,0,c),g.drawArrays(g.TRIANGLE_STRIP,0,4)},drawInRect:function(a){var b=this,c=[0,b.maxT,b.maxS,b.maxT,0,0,b.maxS,0],d=[a.x,a.y,a.x+a.width,a.y,a.x,a.y+a.height,a.x+a.width,a.y+a.height];cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS),b._shaderProgram.use(),b._shaderProgram.setUniformsForBuiltins(),cc.glBindTexture2D(b);var e=cc._renderContext;e.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,e.FLOAT,!1,0,d),e.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,e.FLOAT,!1,0,c),e.drawArrays(e.TRIANGLE_STRIP,0,4)},initWithImage:function(a){if(null==a)return cc.log(cc._LogInfos.Texture2D_initWithImage),!1;var b=a.getWidth(),c=a.getHeight(),d=cc.configuration.getMaxTextureSize();return b>d||c>d?(cc.log(cc._LogInfos.Texture2D_initWithImage_2,b,c,d,d),!1):(this._textureLoaded=!0,this._initPremultipliedATextureWithImage(a,b,c))},initWithElement:function(a){a&&(this._webTextureObj=cc._renderContext.createTexture(),this._htmlElementObj=a,this._textureLoaded=!0)},getHtmlElementObj:function(){return this._htmlElementObj},isLoaded:function(){return this._textureLoaded},handleLoadedTexture:function(a){a=void 0===a?!1:a;var b=this;if(cc.game._rendererInitialized){if(!b._htmlElementObj){var c=cc.loader.getRes(b.url);if(!c)return;b.initWithElement(c)}if(b._htmlElementObj.width&&b._htmlElementObj.height){var d=cc._renderContext;cc.glBindTexture2D(b),d.pixelStorei(d.UNPACK_ALIGNMENT,4),a&&d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,b._htmlElementObj),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),b.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE),cc.glBindTexture2D(null),a&&d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0);var e=b._htmlElementObj.width,f=b._htmlElementObj.height;b._pixelsWide=b._contentSize.width=e,b._pixelsHigh=b._contentSize.height=f,b._pixelFormat=cc.Texture2D.PIXEL_FORMAT_RGBA8888,b.maxS=1,b.maxT=1,b._hasPremultipliedAlpha=a,b._hasMipmaps=!1,b.dispatchEvent("load")}}},initWithString:function(a,b,c,d,e,f){return cc.log(cc._LogInfos.Texture2D_initWithString),null},initWithETCFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithETCFile_2),!1},initWithPVRFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithPVRFile_2),!1},initWithPVRTCData:function(a,b,c,d,e,f){return cc.log(cc._LogInfos.Texture2D_initWithPVRTCData_2),!1},setTexParameters:function(a,b,c,d){var e=this,f=cc._renderContext;void 0!==b&&(a={minFilter:a,magFilter:b,wrapS:c,wrapT:d}),cc.assert(e._pixelsWide===cc.NextPOT(e._pixelsWide)&&e._pixelsHigh===cc.NextPOT(e._pixelsHigh)||a.wrapS===f.CLAMP_TO_EDGE&&a.wrapT===f.CLAMP_TO_EDGE,"WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures"),cc.glBindTexture2D(e),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,a.minFilter),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,a.magFilter),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,a.wrapS),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,a.wrapT)},setAntiAliasTexParameters:function(){var a=cc._renderContext;cc.glBindTexture2D(this),this._hasMipmaps?a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_NEAREST):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR)},setAliasTexParameters:function(){var a=cc._renderContext;cc.glBindTexture2D(this),this._hasMipmaps?a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST_MIPMAP_NEAREST):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST)},generateMipmap:function(){var a=this;cc.assert(a._pixelsWide===cc.NextPOT(a._pixelsWide)&&a._pixelsHigh===cc.NextPOT(a._pixelsHigh),"Mimpap texture only works in POT textures"),cc.glBindTexture2D(a),cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D),a._hasMipmaps=!0},stringForFormat:function(){return cc.Texture2D._M[this._pixelFormat]},bitsPerPixelForFormat:function(a){a=a||this._pixelFormat;var b=cc.Texture2D._B[a];return null!=b?b:(cc.log(cc._LogInfos.Texture2D_bitsPerPixelForFormat,a),-1)},_initPremultipliedATextureWithImage:function(a,b,c){var d,e=cc.Texture2D,f=a.getData(),g=null,h=null,i=a.hasAlpha(),j=cc.size(a.getWidth(),a.getHeight()),k=e.defaultPixelFormat,l=a.getBitsPerComponent();i||(l>=8?k=e.PIXEL_FORMAT_RGB888:(cc.log(cc._LogInfos.Texture2D__initPremultipliedATextureWithImage),k=e.PIXEL_FORMAT_RGB565));var m=b*c;if(k===e.PIXEL_FORMAT_RGB565)if(i)for(f=new Uint16Array(b*c),g=a.getData(),d=0;m>d;++d)f[d]=(g[d]>>0&255)>>3<<11|(g[d]>>8&255)>>2<<5|(g[d]>>16&255)>>3<<0;else for(f=new Uint16Array(b*c),h=a.getData(),d=0;m>d;++d)f[d]=(255&h[d])>>3<<11|(255&h[d])>>2<<5|(255&h[d])>>3<<0;else if(k===e.PIXEL_FORMAT_RGBA4444)for(f=new Uint16Array(b*c),g=a.getData(),d=0;m>d;++d)f[d]=(g[d]>>0&255)>>4<<12|(g[d]>>8&255)>>4<<8|(g[d]>>16&255)>>4<<4|(g[d]>>24&255)>>4<<0;else if(k===e.PIXEL_FORMAT_RGB5A1)for(f=new Uint16Array(b*c),g=a.getData(),d=0;m>d;++d)f[d]=(g[d]>>0&255)>>3<<11|(g[d]>>8&255)>>3<<6|(g[d]>>16&255)>>3<<1|(g[d]>>24&255)>>7<<0;else if(k===e.PIXEL_FORMAT_A8)for(f=new Uint8Array(b*c),g=a.getData(),d=0;m>d;++d)f[d]=g>>24&255;if(i&&k===e.PIXEL_FORMAT_RGB888)for(g=a.getData(),f=new Uint8Array(b*c*3),d=0;m>d;++d)f[3*d]=g>>0&255,f[3*d+1]=g>>8&255,f[3*d+2]=g>>16&255;return this.initWithData(f,k,b,c,j),f!=a.getData()&&(f=null),this._hasPremultipliedAlpha=a.isPremultipliedAlpha(),!0},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},removeLoadedEventListener:function(a){this.removeEventListener("load",a)}})},cc._tmp.WebGLTextureAtlas=function(){var a=cc.TextureAtlas.prototype;a._setupVBO=function(){var a=this,b=cc._renderContext;a._buffersVBO[0]=b.createBuffer(),a._buffersVBO[1]=b.createBuffer(),a._quadsWebBuffer=b.createBuffer(),a._mapBuffers()},a._mapBuffers=function(){var a=this,b=cc._renderContext;b.bindBuffer(b.ARRAY_BUFFER,a._quadsWebBuffer),b.bufferData(b.ARRAY_BUFFER,a._quadsArrayBuffer,b.DYNAMIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._buffersVBO[1]),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a._indices,b.STATIC_DRAW)},a.drawNumberOfQuads=function(a,b){var c=this;if(b=b||0,0!==a&&c.texture&&c.texture.isLoaded()){var d=cc._renderContext;cc.glBindTexture2D(c.texture),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),d.bindBuffer(d.ARRAY_BUFFER,c._quadsWebBuffer),c.dirty&&(d.bufferData(d.ARRAY_BUFFER,c._quadsArrayBuffer,d.DYNAMIC_DRAW),c.dirty=!1),d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,d.FLOAT,!1,24,0),d.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,d.UNSIGNED_BYTE,!0,24,12),d.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,d.FLOAT,!1,24,16),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c._buffersVBO[1]),cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP?d.drawElements(d.TRIANGLE_STRIP,6*a,d.UNSIGNED_SHORT,6*b*c._indices.BYTES_PER_ELEMENT):d.drawElements(d.TRIANGLES,6*a,d.UNSIGNED_SHORT,6*b*c._indices.BYTES_PER_ELEMENT),cc.g_NumberOfDraws++}}},cc._tmp.WebGLTextureCache=function(){var a=cc.textureCache;a.handleLoadedTexture=function(a){var b,c,d=this._textures;cc.game._rendererInitialized||(d=this._loadedTexturesBefore),b=d[a],b||(b=d[a]=new cc.Texture2D,b.url=a),c=cc.path.extname(a),".png"===c?b.handleLoadedTexture(!0):b.handleLoadedTexture()},a.addImage=function(a,b,c){cc.assert(a,cc._LogInfos.Texture2D_addImage_2);var d=this._textures;cc.game._rendererInitialized||(d=this._loadedTexturesBefore);var e=d[a]||d[cc.loader._getAliase(a)];if(e)return e.isLoaded()?(b&&b.call(c,e),e):(e.addEventListener("load",function(){b&&b.call(c,e)},c),e);e=d[a]=new cc.Texture2D,e.url=a;var f=cc.loader._checkIsImageURL(a)?cc.loader.load:cc.loader.loadImg;return f.call(cc.loader,a,function(e,f){if(e)return b&&b.call(c,e);cc.textureCache.handleLoadedTexture(a);var g=d[a];b&&b.call(c,g)}),e},a.addImageAsync=a.addImage,a=null},cc.ALIGN_CENTER=51,cc.ALIGN_TOP=19,cc.ALIGN_TOP_RIGHT=18,cc.ALIGN_RIGHT=50,cc.ALIGN_BOTTOM_RIGHT=34,cc.ALIGN_BOTTOM=35,cc.ALIGN_BOTTOM_LEFT=33,cc.ALIGN_LEFT=49,cc.ALIGN_TOP_LEFT=17,cc.PVRHaveAlphaPremultiplied_=!1,cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var a={_contentSize:null,_textureLoaded:!1,_htmlElementObj:null,url:null,_pattern:null,ctor:function(){this._contentSize=cc.size(0,0),this._textureLoaded=!1,this._htmlElementObj=null,this._pattern=""},getPixelsWide:function(){return this._contentSize.width},getPixelsHigh:function(){return this._contentSize.height},getContentSize:function(){var a=cc.contentScaleFactor();return cc.size(this._contentSize.width/a,this._contentSize.height/a)},_getWidth:function(){return this._contentSize.width/cc.contentScaleFactor()},_getHeight:function(){return this._contentSize.height/cc.contentScaleFactor()},getContentSizeInPixels:function(){return this._contentSize},initWithElement:function(a){a&&(this._htmlElementObj=a,this._contentSize.width=a.width,this._contentSize.height=a.height,this._textureLoaded=!0)},getHtmlElementObj:function(){return this._htmlElementObj},isLoaded:function(){return this._textureLoaded},handleLoadedTexture:function(){var a=this;if(!a._textureLoaded){if(!a._htmlElementObj){var b=cc.loader.getRes(a.url);if(!b)return;a.initWithElement(b)}var c=a._htmlElementObj;a._contentSize.width=c.width,a._contentSize.height=c.height,a.dispatchEvent("load")}},description:function(){return""},initWithData:function(a,b,c,d,e){return!1},initWithImage:function(a){return!1},initWithString:function(a,b,c,d,e,f){return!1},releaseTexture:function(){cc.loader.release(this.url)},getName:function(){return null},getMaxS:function(){return 1},setMaxS:function(a){},getMaxT:function(){return 1},setMaxT:function(a){},getPixelFormat:function(){return null},getShaderProgram:function(){return null},setShaderProgram:function(a){},hasPremultipliedAlpha:function(){return!1},hasMipmaps:function(){return!1},releaseData:function(a){a=null},keepData:function(a,b){return a},drawAtPoint:function(a){},drawInRect:function(a){},initWithETCFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithETCFile),!1},initWithPVRFile:function(a){return cc.log(cc._LogInfos.Texture2D_initWithPVRFile),!1},initWithPVRTCData:function(a,b,c,d,e,f){return cc.log(cc._LogInfos.Texture2D_initWithPVRTCData),!1},setTexParameters:function(a,b,c,d){return void 0!==b&&(a={minFilter:a,magFilter:b,wrapS:c,wrapT:d}),a.wrapS===cc.REPEAT&&a.wrapT===cc.REPEAT?void(this._pattern="repeat"):a.wrapS===cc.REPEAT?void(this._pattern="repeat-x"):a.wrapT===cc.REPEAT?void(this._pattern="repeat-y"):void(this._pattern="")},setAntiAliasTexParameters:function(){},setAliasTexParameters:function(){},generateMipmap:function(){},stringForFormat:function(){return""},bitsPerPixelForFormat:function(a){return-1},addLoadedEventListener:function(a,b){this.addEventListener("load",a,b)},removeLoadedEventListener:function(a){this.removeEventListener("load",a)},_generateColorTexture:function(){},_generateTextureCacheForColor:function(){if(this.channelCache)return this.channelCache;var a=[document.createElement("canvas"),document.createElement("canvas"),document.createElement("canvas"),document.createElement("canvas")];return b(this._htmlElementObj,a),this.channelCache=a},_grayElementObj:null,_backupElement:null,_isGray:!1,_switchToGray:function(a){this._textureLoaded&&this._isGray!==a&&(this._isGray=a,this._isGray?(this._backupElement=this._htmlElementObj,this._grayElementObj||(this._grayElementObj=cc.Texture2D._generateGrayTexture(this._htmlElementObj)),this._htmlElementObj=this._grayElementObj):null!==this._backupElement&&(this._htmlElementObj=this._backupElement))}},b=function(a,b){var c=a.width,d=a.height;b[0].width=c,b[0].height=d,b[1].width=c,b[1].height=d,b[2].width=c,b[2].height=d,b[3].width=c,b[3].height=d;var e=b[3].getContext("2d");e.drawImage(a,0,0);for(var f,g=e.getImageData(0,0,c,d).data,h=0;4>h;h++){f=b[h].getContext("2d");for(var i=f.getImageData(0,0,c,d),j=i.data,k=0;k0&&(l.globalAlpha=a/255,l.drawImage(m[0],h,i,j,k,0,0,j,k)),b>0&&(l.globalAlpha=b/255,l.drawImage(m[1],h,i,j,k,0,0,j,k)),c>0&&(l.globalAlpha=c/255,l.drawImage(m[2],h,i,j,k,0,0,j,k)),f)return e;var n=new cc.Texture2D;return n.initWithElement(e),n.handleLoadedTexture(),n}},cc.Texture2D=cc.Class.extend(a),cc.Texture2D._generateGrayTexture=function(a,b,c){if(null===a)return null;c=c||document.createElement("canvas"),b=b||cc.rect(0,0,a.width,a.height),c.width=b.width,c.height=b.height;var d=c.getContext("2d");d.drawImage(a,b.x,b.y,b.width,b.height,0,0,b.width,b.height);for(var e=d.getImageData(0,0,b.width,b.height),f=e.data,g=0,h=f.length;h>g;g+=4)f[g]=f[g+1]=f[g+2]=.34*f[g]+.5*f[g+1]+.16*f[g+2];return d.putImageData(e,0,0),c}}else cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(cc.assert(cc.isFunction(cc._tmp.WebGLTexture2D),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTexture2D(),delete cc._tmp.WebGLTexture2D);cc.EventHelper.prototype.apply(cc.Texture2D.prototype),cc.assert(cc.isFunction(cc._tmp.PrototypeTexture2D),cc._LogInfos.MissingFile,"TexturesPropertyDefine.js"),cc._tmp.PrototypeTexture2D(),delete cc._tmp.PrototypeTexture2D}),cc.textureCache={_textures:{},_textureColorsCache:{},_textureKeySeq:0|1e3*Math.random(),_loadedTexturesBefore:{},_initializingRenderer:function(){var a,b=this._loadedTexturesBefore,c=this._textures;for(a in b){var d=b[a];d.handleLoadedTexture(),c[a]=d}this._loadedTexturesBefore={}},addPVRTCImage:function(a){cc.log(cc._LogInfos.textureCache_addPVRTCImage)},addETCImage:function(a){cc.log(cc._LogInfos.textureCache_addETCImage)},description:function(){return""},textureForKey:function(a){return cc.log(cc._LogInfos.textureCache_textureForKey),this.getTextureForKey(a)},getTextureForKey:function(a){return this._textures[a]||this._textures[cc.loader._getAliase(a)]},getKeyByTexture:function(a){for(var b in this._textures)if(this._textures[b]===a)return b;return null},_generalTextureKey:function(a){return"_textureKey_"+a},getTextureColors:function(a){var b=a._htmlElementObj,c=this.getKeyByTexture(b);return c||(c=b instanceof HTMLImageElement?b.src:this._generalTextureKey(a.__instanceId)),this._textureColorsCache[c]||(this._textureColorsCache[c]=a._generateTextureCacheForColor()),this._textureColorsCache[c]},addPVRImage:function(a){cc.log(cc._LogInfos.textureCache_addPVRImage)},removeAllTextures:function(){var a=this._textures;for(var b in a)a[b]&&a[b].releaseTexture();this._textures={}},removeTexture:function(a){if(a){var b=this._textures;for(var c in b)b[c]===a&&(b[c].releaseTexture(),delete b[c])}},removeTextureForKey:function(a){null!=a&&this._textures[a]&&delete this._textures[a]},cacheImage:function(a,b){if(b instanceof cc.Texture2D)return void(this._textures[a]=b);var c=new cc.Texture2D;c.initWithElement(b),c.handleLoadedTexture(),this._textures[a]=c},addUIImage:function(a,b){if(cc.assert(a,cc._LogInfos.textureCache_addUIImage_2),b&&this._textures[b])return this._textures[b];var c=new cc.Texture2D;return c.initWithImage(a),null!=b?this._textures[b]=c:cc.log(cc._LogInfos.textureCache_addUIImage),c},dumpCachedTextureInfo:function(){var a=0,b=0,c=this._textures;for(var d in c){var e=c[d];a++,e.getHtmlElementObj()instanceof HTMLImageElement?cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo,d,e.getHtmlElementObj().src,e.pixelsWidth,e.pixelsHeight):cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,d,e.pixelsWidth,e.pixelsHeight),b+=e.pixelsWidth*e.pixelsHeight*4}var f=this._textureColorsCache;for(d in f){var g=f[d];for(var h in g){var i=g[h];a++,cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_2,d,i.width,i.height),b+=i.width*i.height*4}}cc.log(cc._LogInfos.textureCache_dumpCachedTextureInfo_3,a,b/1024,(b/1048576).toFixed(2))},_clear:function(){this._textures={},this._textureColorsCache={},this._textureKeySeq=0|1e3*Math.random(),this._loadedTexturesBefore={}}},cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var a=cc.textureCache;a.handleLoadedTexture=function(a){var b=this._textures,c=b[a];c||(c=b[a]=new cc.Texture2D,c.url=a),c.handleLoadedTexture()},a.addImage=function(a,b,c){cc.assert(a,cc._LogInfos.Texture2D_addImage);var d=this._textures,e=d[a]||d[cc.loader._getAliase(a)];if(e)return e.isLoaded()?(b&&b.call(c,e),e):(e.addEventListener("load",function(){b&&b.call(c,e)},c),e);e=d[a]=new cc.Texture2D,e.url=a;var f=cc.loader._checkIsImageURL(a)?cc.loader.load:cc.loader.loadImg;return f.call(cc.loader,a,function(e,f){if(e)return b&&b.call(c,e);cc.textureCache.handleLoadedTexture(a);var g=d[a];b&&b.call(c,g)}),e},a.addImageAsync=a.addImage,a=null}else cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(cc.assert(cc.isFunction(cc._tmp.WebGLTextureCache),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTextureCache(),delete cc._tmp.WebGLTextureCache)}),cc.Scene=cc.Node.extend({_className:"Scene",ctor:function(){cc.Node.prototype.ctor.call(this),this._ignoreAnchorPointForPosition=!0,this.setAnchorPoint(.5,.5),this.setContentSize(cc.director.getWinSize())}}),cc.Scene.create=function(){return new cc.Scene},cc.LoaderScene=cc.Scene.extend({_interval:null,_label:null,_className:"LoaderScene",cb:null,target:null,init:function(){var a=this,b=160,c=200,d=a._bgLayer=new cc.LayerColor(cc.color(32,32,32,255));a.addChild(d,0);var e=24,f=-c/2+100;cc._loaderImage&&(cc.loader.loadImg(cc._loaderImage,{isCrossOrigin:!1},function(d,e){b=e.width,c=e.height,a._initStage(e,cc.visibleRect.center)}),e=14,f=-c/2-10);var g=a._label=new cc.LabelTTF("Loading... 0%","Arial",e);return g.setPosition(cc.pAdd(cc.visibleRect.center,cc.p(0,f))),g.setColor(cc.color(180,180,180)),d.addChild(this._label,10),!0},_initStage:function(a,b){var c=this,d=c._texture2d=new cc.Texture2D;d.initWithElement(a),d.handleLoadedTexture();var e=c._logo=new cc.Sprite(d);e.setScale(cc.contentScaleFactor()),e.x=b.x,e.y=b.y,c._bgLayer.addChild(e,10)},onEnter:function(){var a=this;cc.Node.prototype.onEnter.call(a),a.schedule(a._startLoading,.3)},onExit:function(){cc.Node.prototype.onExit.call(this);var a="Loading... 0%";this._label.setString(a)},initWithResources:function(a,b,c){cc.isString(a)&&(a=[a]),this.resources=a||[],this.cb=b,this.target=c},_startLoading:function(){var a=this;a.unschedule(a._startLoading);var b=a.resources;cc.loader.load(b,function(b,c,d){var e=d/c*100|0;e=Math.min(e,100),a._label.setString("Loading... "+e+"%")},function(){a.cb&&a.cb.call(a.target)})},_updateTransform:function(){this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),this._bgLayer._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),this._label._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),this._logo._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)}}),cc.LoaderScene.preload=function(a,b,c){var d=cc;return d.loaderScene||(d.loaderScene=new cc.LoaderScene,d.loaderScene.init(),cc.eventManager.addCustomListener(cc.Director.EVENT_PROJECTION_CHANGED,function(){d.loaderScene._updateTransform()})),d.loaderScene.initWithResources(a,b,c),cc.director.runScene(d.loaderScene),d.loaderScene},cc.Layer=cc.Node.extend({_className:"Layer",ctor:function(){var a=cc.Node.prototype;a.ctor.call(this),this._ignoreAnchorPointForPosition=!0,a.setAnchorPoint.call(this,.5,.5),a.setContentSize.call(this,cc.winSize)},init:function(){var a=this;return a._ignoreAnchorPointForPosition=!0,a.setAnchorPoint(.5,.5),a.setContentSize(cc.winSize),a._cascadeColorEnabled=!1,a._cascadeOpacityEnabled=!1,!0},bake:function(){this._renderCmd.bake()},unbake:function(){this._renderCmd.unbake()},isBaked:function(){return this._renderCmd._isBaked},addChild:function(a,b,c){cc.Node.prototype.addChild.call(this,a,b,c),this._renderCmd._bakeForAddChild(a)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.Layer.CanvasRenderCmd(this):new cc.Layer.WebGLRenderCmd(this)}}),cc.Layer.create=function(){return new cc.Layer},cc.LayerColor=cc.Layer.extend({_blendFunc:null,_className:"LayerColor",getBlendFunc:function(){return this._blendFunc},changeWidthAndHeight:function(a,b){this.width=a,this.height=b},changeWidth:function(a){this.width=a},changeHeight:function(a){this.height=a},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},ctor:function(a,b,c){cc.Layer.prototype.ctor.call(this),this._blendFunc=new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA),cc.LayerColor.prototype.init.call(this,a,b,c)},init:function(a,b,c){cc._renderType!==cc.game.RENDER_TYPE_CANVAS&&(this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR));var d=cc.director.getWinSize();a=a||cc.color(0,0,0,255),b=void 0===b?d.width:b,c=void 0===c?d.height:c;var e=this._realColor;return e.r=a.r,e.g=a.g,e.b=a.b,this._realOpacity=a.a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty),cc.LayerColor.prototype.setContentSize.call(this,b,c),!0},setBlendFunc:function(a,b){var c=this._blendFunc;void 0===b?(c.src=a.src,c.dst=a.dst):(c.src=a,c.dst=b),this._renderCmd.updateBlendFunc(c)},_setWidth:function(a){cc.Node.prototype._setWidth.call(this,a),this._renderCmd._updateSquareVerticesWidth(a)},_setHeight:function(a){cc.Node.prototype._setHeight.call(this,a),this._renderCmd._updateSquareVerticesHeight(a)},setContentSize:function(a,b){cc.Layer.prototype.setContentSize.call(this,a,b),this._renderCmd._updateSquareVertices(a,b)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.LayerColor.CanvasRenderCmd(this):new cc.LayerColor.WebGLRenderCmd(this)}}),cc.LayerColor.create=function(a,b,c){ +return new cc.LayerColor(a,b,c)},function(){var a=cc.LayerColor.prototype;cc.defineGetterSetter(a,"width",a._getWidth,a._setWidth),cc.defineGetterSetter(a,"height",a._getHeight,a._setHeight)}(),cc.LayerGradient=cc.LayerColor.extend({_endColor:null,_startOpacity:255,_endOpacity:255,_alongVector:null,_compressedInterpolation:!1,_className:"LayerGradient",_colorStops:[],ctor:function(a,b,c,d){cc.LayerColor.prototype.ctor.call(this),this._endColor=cc.color(0,0,0,255),this._alongVector=cc.p(0,-1),this._startOpacity=255,this._endOpacity=255,d&&d instanceof Array?(this._colorStops=d,d.splice(0,0,{p:0,color:a||cc.color.BLACK}),d.push({p:1,color:b||cc.color.BLACK})):this._colorStops=[{p:0,color:a||cc.color.BLACK},{p:1,color:b||cc.color.BLACK}],cc.LayerGradient.prototype.init.call(this,a,b,c,d)},init:function(a,b,c,d){a=a||cc.color(0,0,0,255),b=b||cc.color(0,0,0,255),c=c||cc.p(0,-1);var e=this,f=e._endColor;return e._startOpacity=a.a,f.r=b.r,f.g=b.g,f.b=b.b,e._endOpacity=b.a,e._alongVector=c,e._compressedInterpolation=!0,cc.LayerColor.prototype.init.call(e,cc.color(a.r,a.g,a.b,255)),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty),!0},setContentSize:function(a,b){cc.LayerColor.prototype.setContentSize.call(this,a,b),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},_setWidth:function(a){cc.LayerColor.prototype._setWidth.call(this,a),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},_setHeight:function(a){cc.LayerColor.prototype._setHeight.call(this,a),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},getStartColor:function(){return cc.color(this._realColor)},setStartColor:function(a){this.color=a;var b=this._colorStops;if(b&&b.length>0){var c=b[0].color;c.r=a.r,c.g=a.g,c.b=a.b}},setEndColor:function(a){var b=this._endColor;b.r=a.r,b.g=a.g,b.b=a.b;var c=this._colorStops;if(c&&c.length>0){var d=c[c.length-1].color;d.r=a.r,d.g=a.g,d.b=a.b}this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},getEndColor:function(){return cc.color(this._endColor)},setStartOpacity:function(a){this._startOpacity=a;var b=this._colorStops;b&&b.length>0&&(b[0].color.a=a),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getStartOpacity:function(){return this._startOpacity},setEndOpacity:function(a){this._endOpacity=a;var b=this._colorStops;b&&b.length>0&&(b[b.length-1].color.a=a),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getEndOpacity:function(){return this._endOpacity},setVector:function(a){this._alongVector.x=a.x,this._alongVector.y=a.y,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},getVector:function(){return cc.p(this._alongVector.x,this._alongVector.y)},isCompressedInterpolation:function(){return this._compressedInterpolation},setCompressedInterpolation:function(a){this._compressedInterpolation=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.gradientDirty)},getColorStops:function(){return this._colorStops},setColorStops:function(a){this._colorStops=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty|cc.Node._dirtyFlags.gradientDirty)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.LayerGradient.CanvasRenderCmd(this):new cc.LayerGradient.WebGLRenderCmd(this)}}),cc.LayerGradient.create=function(a,b,c,d){return new cc.LayerGradient(a,b,c,d)},function(){var a=cc.LayerGradient.prototype;a.startColor,cc.defineGetterSetter(a,"startColor",a.getStartColor,a.setStartColor),a.endColor,cc.defineGetterSetter(a,"endColor",a.getEndColor,a.setEndColor),a.startOpacity,cc.defineGetterSetter(a,"startOpacity",a.getStartOpacity,a.setStartOpacity),a.endOpacity,cc.defineGetterSetter(a,"endOpacity",a.getEndOpacity,a.setEndOpacity),a.vector,cc.defineGetterSetter(a,"vector",a.getVector,a.setVector),a.colorStops,cc.defineGetterSetter(a,"colorStops",a.getColorStops,a.setColorStops)}(),cc.LayerMultiplex=cc.Layer.extend({_enabledLayer:0,_layers:null,_className:"LayerMultiplex",ctor:function(a){cc.Layer.prototype.ctor.call(this),a instanceof Array?cc.LayerMultiplex.prototype.initWithLayers.call(this,a):cc.LayerMultiplex.prototype.initWithLayers.call(this,Array.prototype.slice.call(arguments))},initWithLayers:function(a){return a.length>0&&null==a[a.length-1]&&cc.log(cc._LogInfos.LayerMultiplex_initWithLayers),this._layers=a,this._enabledLayer=0,this.addChild(this._layers[this._enabledLayer]),!0},switchTo:function(a){return a>=this._layers.length?void cc.log(cc._LogInfos.LayerMultiplex_switchTo):(this.removeChild(this._layers[this._enabledLayer],!0),this._enabledLayer=a,void this.addChild(this._layers[a]))},switchToAndReleaseMe:function(a){return a>=this._layers.length?void cc.log(cc._LogInfos.LayerMultiplex_switchToAndReleaseMe):(this.removeChild(this._layers[this._enabledLayer],!0),this._layers[this._enabledLayer]=null,this._enabledLayer=a,void this.addChild(this._layers[a]))},addLayer:function(a){return a?void this._layers.push(a):void cc.log(cc._LogInfos.LayerMultiplex_addLayer)}}),cc.LayerMultiplex.create=function(){return new cc.LayerMultiplex(Array.prototype.slice.call(arguments))},function(){cc.Layer.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._isBaked=!1,this._bakeSprite=null,this._updateCache=2};var a=cc.Layer.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Layer.CanvasRenderCmd,a._setCacheDirty=function(a){if(a&&0===this._updateCache&&(this._updateCache=2),this._cacheDirty===!1){this._cacheDirty=!0;var b=this._cachedParent;b&&b!==this&&b._setNodeDirtyForCache&&b._setNodeDirtyForCache()}},a.updateStatus=function(){var a=cc.Node._dirtyFlags,b=this._dirtyFlag;b&a.orderDirty&&(this._cacheDirty=!0,0===this._updateCache&&(this._updateCache=2),this._dirtyFlag=this._dirtyFlag&a.orderDirty^this._dirtyFlag),cc.Node.RenderCmd.prototype.updateStatus.call(this)},a._syncStatus=function(a){var b=cc.Node._dirtyFlags,c=this._dirtyFlag;c&b.orderDirty&&(this._cacheDirty=!0,0===this._updateCache&&(this._updateCache=2),this._dirtyFlag=this._dirtyFlag&b.orderDirty^this._dirtyFlag),cc.Node.RenderCmd.prototype._syncStatus.call(this,a)},a.transform=function(a,b){var c=this._worldTransform,d=c.a,e=c.b,f=c.c,g=c.d;c.tx,c.ty;cc.Node.CanvasRenderCmd.prototype.transform.call(this,a,b),c.a===d&&c.b===e&&c.c===f&&c.d===g||0!==this._updateCache||(this._updateCache=2)},a.bake=function(){if(!this._isBaked){this._needDraw=!0,cc.renderer.childrenOrderDirty=!0,this._isBaked=this._cacheDirty=!0,0===this._updateCache&&(this._updateCache=2);for(var a=this._node._children,b=0,c=a.length;c>b;b++)a[b]._renderCmd._setCachedParent(this);this._bakeSprite||(this._bakeSprite=new cc.BakeSprite,this._bakeSprite.setAnchorPoint(0,0))}},a.unbake=function(){if(this._isBaked){cc.renderer.childrenOrderDirty=!0,this._needDraw=!1,this._isBaked=!1,this._cacheDirty=!0,0===this._updateCache&&(this._updateCache=2);for(var a=this._node._children,b=0,c=a.length;c>b;b++)a[b]._renderCmd._setCachedParent(null)}},a.isBaked=function(){return this._isBaked},a.rendering=function(){if(this._cacheDirty){var a=this._node,b=a._children,c=this._bakeSprite;this.transform(this.getParentRenderCmd(),!0);var d=this._getBoundingBoxForBake();d.width=0|d.width+.5,d.height=0|d.height+.5;var e=c.getCacheContext(),f=e.getContext();if(c.setPosition(d.x,d.y),this._updateCache>0){c.resetCanvasSize(d.width,d.height),e.setOffset(0-d.x,f.canvas.height-d.height+d.y),a.sortAllChildren(),cc.renderer._turnToCacheMode(this.__instanceId);for(var g=0,h=b.length;h>g;g++)b[g].visit(this);cc.renderer._renderingToCacheCanvas(e,this.__instanceId),c.transform(),this._updateCache--}this._cacheDirty=!1}},a.visit=function(a){if(!this._isBaked)return void cc.Node.CanvasRenderCmd.prototype.visit.call(this,a);var b=this._node,c=b._children,d=c.length;b._visible&&0!==d&&(this._syncStatus(a),cc.renderer.pushRenderCommand(this),this._bakeSprite.visit(this),this._dirtyFlag=0)},a._bakeForAddChild=function(a){a._parent===this._node&&this._isBaked&&a._renderCmd._setCachedParent(this)},a._getBoundingBoxForBake=function(){var a=null,b=this._node;if(!b._children||0===b._children.length)return cc.rect(0,0,10,10);for(var c=b.getNodeToWorldTransform(),d=b._children,e=0,f=d.length;f>e;e++){var g=d[e];if(g&&g._visible)if(a){var h=g._getBoundingBoxToCurrentNode(c);h&&(a=cc.rectUnion(a,h))}else a=g._getBoundingBoxToCurrentNode(c)}return a}}(),function(){cc.LayerColor.CanvasRenderCmd=function(a){cc.Layer.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._blendFuncStr="source-over",this._bakeRenderCmd=new cc.CustomRenderCmd(this,this._bakeRendering)};var a=cc.LayerColor.CanvasRenderCmd.prototype=Object.create(cc.Layer.CanvasRenderCmd.prototype);a.constructor=cc.LayerColor.CanvasRenderCmd,a.unbake=function(){cc.Layer.CanvasRenderCmd.prototype.unbake.call(this),this._needDraw=!0},a.rendering=function(a,b,c){var d=a||cc._renderContext,e=d.getContext(),f=this._node,g=this._displayedColor,h=this._displayedOpacity/255,i=f._contentSize.width,j=f._contentSize.height;0!==h&&(d.setCompositeOperation(this._blendFuncStr),d.setGlobalAlpha(h),d.setFillStyle("rgba("+(0|g.r)+","+(0|g.g)+","+(0|g.b)+", 1)"),d.setTransform(this._worldTransform,b,c),e.fillRect(0,0,i*b,-j*c),cc.g_NumberOfDraws++)},a.updateBlendFunc=function(a){this._blendFuncStr=cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a)},a._updateSquareVertices=a._updateSquareVerticesWidth=a._updateSquareVerticesHeight=function(){},a._bakeRendering=function(){if(this._cacheDirty){var a,b=this._node,c=this._bakeSprite,d=b._children,e=d.length;this.transform(this.getParentRenderCmd(),!0);var f=this._getBoundingBoxForBake();f.width=0|f.width+.5,f.height=0|f.height+.5;var g=c.getCacheContext(),h=g.getContext();if(c.setPosition(f.x,f.y),this._updateCache>0){h.fillStyle=g._currentFillStyle,c.resetCanvasSize(f.width,f.height),g.setOffset(0-f.x,h.canvas.height-f.height+f.y);var i;if(cc.renderer._turnToCacheMode(this.__instanceId),e>0){for(b.sortAllChildren(),a=0;e>a&&(i=d[a],i._localZOrder<0);a++)i._renderCmd.visit(this);for(cc.renderer.pushRenderCommand(this);e>a;a++)d[a]._renderCmd.visit(this)}else cc.renderer.pushRenderCommand(this);cc.renderer._renderingToCacheCanvas(g,this.__instanceId),c.transform(),this._updateCache--}this._cacheDirty=!1}},a.visit=function(a){if(!this._isBaked)return void cc.Node.CanvasRenderCmd.prototype.visit.call(this);var b=this._node;b._visible&&(this._syncStatus(a),cc.renderer.pushRenderCommand(this._bakeRenderCmd),this._bakeSprite._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),this._bakeSprite.visit(this),this._dirtyFlag=0)},a._getBoundingBoxForBake=function(){var a=this._node,b=cc.rect(0,0,a._contentSize.width,a._contentSize.height),c=a.getNodeToWorldTransform();if(b=cc.rectApplyAffineTransform(b,a.getNodeToWorldTransform()),!a._children||0===a._children.length)return b;for(var d=a._children,e=0;ea;a++){for(c=d[a],b=a-1;b>=0;){if(c._localZOrderd;d++)c.removeSpriteFromAtlas(b[d]);cc.Node.prototype.removeAllChildren.call(this,a),this._hasChildren=!1},ignoreAnchorPointForPosition:function(a){return this._batchNode?void cc.log(cc._LogInfos.Sprite_ignoreAnchorPointForPosition):void cc.Node.prototype.ignoreAnchorPointForPosition.call(this,a)},setFlippedX:function(a){this._flippedX!==a&&(this._flippedX=a,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},setFlippedY:function(a){this._flippedY!==a&&(this._flippedY=a,this.setTextureRect(this._rect,this._rectRotated,this._contentSize),this.setNodeDirty(!0))},isFlippedX:function(){return this._flippedX},isFlippedY:function(){return this._flippedY},setOpacityModifyRGB:function(a){this._opacityModifyRGB!==a&&(this._opacityModifyRGB=a,this._renderCmd._setColorDirty())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setDisplayFrameWithAnimationName:function(a,b){cc.assert(a,cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_3);var c=cc.animationCache.getAnimation(a);if(!c)return void cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName);var d=c.getFrames()[b];return d?void this.setSpriteFrame(d.getSpriteFrame()):void cc.log(cc._LogInfos.Sprite_setDisplayFrameWithAnimationName_2)},getBatchNode:function(){return this._batchNode},_setReorderChildDirtyRecursively:function(){if(!this._reorderChildDirty){this._reorderChildDirty=!0;for(var a=this._parent;a&&a!==this._batchNode;)a._setReorderChildDirtyRecursively(),a=a.parent}},getTexture:function(){return this._texture},_softInit:function(a,b,c){if(void 0===a)cc.Sprite.prototype.init.call(this);else if(cc.isString(a))if("#"===a[0]){var d=a.substr(1,a.length-1),e=cc.spriteFrameCache.getSpriteFrame(d);e?this.initWithSpriteFrame(e):cc.log("%s does not exist",a)}else cc.Sprite.prototype.init.call(this,a,b);else if("object"==typeof a)if(a instanceof cc.Texture2D)this.initWithTexture(a,b,c);else if(a instanceof cc.SpriteFrame)this.initWithSpriteFrame(a);else if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){var f=new cc.Texture2D;f.initWithElement(a),f.handleLoadedTexture(),this.initWithTexture(f)}},getQuad:function(){return this._renderCmd.getQuad()},setBlendFunc:function(a,b){var c=this._blendFunc;void 0===b?(c.src=a.src,c.dst=a.dst):(c.src=a,c.dst=b),this._renderCmd.updateBlendFunc(c)},init:function(){var a=this;return arguments.length>0?a.initWithFile(arguments[0],arguments[1]):(cc.Node.prototype.init.call(a),a.dirty=a._recursiveDirty=!1,a._blendFunc.src=cc.BLEND_SRC,a._blendFunc.dst=cc.BLEND_DST,a.texture=null,a._flippedX=a._flippedY=!1,a.anchorX=.5,a.anchorY=.5,a._offsetPosition.x=0,a._offsetPosition.y=0,a._hasChildren=!1,this._renderCmd._init(),a.setTextureRect(cc.rect(0,0,0,0),!1,cc.size(0,0)),!0)},initWithFile:function(a,b){cc.assert(a,cc._LogInfos.Sprite_initWithFile);var c=cc.textureCache.getTextureForKey(a);if(c){if(!b){var d=c.getContentSize();b=cc.rect(0,0,d.width,d.height)}return this.initWithTexture(c,b)}return c=cc.textureCache.addImage(a),this.initWithTexture(c,b||cc.rect(0,0,c._contentSize.width,c._contentSize.height))},initWithTexture:function(a,b,c,d){var e=this;if(cc.assert(0!==arguments.length,cc._LogInfos.CCSpriteBatchNode_initWithTexture),c=c||!1,a=this._renderCmd._handleTextureForRotatedTexture(a,b,c,d),!cc.Node.prototype.init.call(e))return!1;e._batchNode=null,e._recursiveDirty=!1,e.dirty=!1,e._opacityModifyRGB=!0,e._blendFunc.src=cc.BLEND_SRC,e._blendFunc.dst=cc.BLEND_DST,e._flippedX=e._flippedY=!1,e.setAnchorPoint(.5,.5),e._offsetPosition.x=0,e._offsetPosition.y=0,e._hasChildren=!1,this._renderCmd._init();var f=a.isLoaded();return e._textureLoaded=f,f?(b||(b=cc.rect(0,0,a.width,a.height)),this._renderCmd._checkTextureBoundary(a,b,c),e.setTexture(a),e.setTextureRect(b,c),e.setBatchNode(null),!0):(e._rectRotated=c,b&&(e._rect.x=b.x,e._rect.y=b.y,e._rect.width=b.width,e._rect.height=b.height),e.texture&&e.texture.removeEventListener("load",e),a.addEventListener("load",e._renderCmd._textureLoadedCallback,e),e.texture=a,!0)},setTextureRect:function(a,b,c,d){var e=this;e._rectRotated=b||!1,e.setContentSize(c||a),e.setVertexRect(a),e._renderCmd._setTextureCoords(a,d);var f=e._unflippedOffsetPositionFromCenter.x,g=e._unflippedOffsetPositionFromCenter.y;e._flippedX&&(f=-f),e._flippedY&&(g=-g);var h=e._rect;e._offsetPosition.x=f+(e._contentSize.width-h.width)/2,e._offsetPosition.y=g+(e._contentSize.height-h.height)/2,e._batchNode?e.dirty=!0:this._renderCmd._resetForBatchNode()},updateTransform:function(){this._renderCmd.updateTransform()},addChild:function(a,b,c){cc.assert(a,cc._LogInfos.CCSpriteBatchNode_addChild_2),null==b&&(b=a._localZOrder),null==c&&(c=a.tag),this._renderCmd._setBatchNodeForAddChild(a)&&(cc.Node.prototype.addChild.call(this,a,b,c),this._hasChildren=!0)},setSpriteFrame:function(a){var b=this;cc.isString(a)&&(a=cc.spriteFrameCache.getSpriteFrame(a),cc.assert(a,cc._LogInfos.Sprite_setSpriteFrame)),this.setNodeDirty(!0);var c=a.getOffset();b._unflippedOffsetPositionFromCenter.x=c.x,b._unflippedOffsetPositionFromCenter.y=c.y;var d=a.getTexture(),e=a.textureLoaded();e?(b._textureLoaded=!0,d!==b._texture&&(b._setTexture(d),b.setColor(b._realColor)),b.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize())):(b._textureLoaded=!1,a.addEventListener("load",function(a){b._textureLoaded=!0;var c=a.getTexture();c!==b._texture&&b._setTexture(c),b.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize()),b.dispatchEvent("load"),b.setColor(b._realColor)},b)),this._renderCmd._updateForSetSpriteFrame(d)},setDisplayFrame:function(a){cc.log(cc._LogInfos.Sprite_setDisplayFrame),this.setSpriteFrame(a)},isFrameDisplayed:function(a){return this._renderCmd.isFrameDisplayed(a)},displayFrame:function(){return this.getSpriteFrame()},getSpriteFrame:function(){return new cc.SpriteFrame(this._texture,cc.rectPointsToPixels(this._rect),this._rectRotated,cc.pointPointsToPixels(this._unflippedOffsetPositionFromCenter),cc.sizePointsToPixels(this._contentSize))},setBatchNode:function(a){var b=this;b._batchNode=a,b._batchNode?(b._transformToBatch=cc.affineTransformIdentity(),b.textureAtlas=b._batchNode.getTextureAtlas()):(b.atlasIndex=cc.Sprite.INDEX_NOT_INITIALIZED,b.textureAtlas=null,b._recursiveDirty=!1,b.dirty=!1,this._renderCmd._resetForBatchNode())},setTexture:function(a){if(!a)return this._renderCmd._setTexture(null);var b=cc.isString(a);b&&(a=cc.textureCache.addImage(a)),a._textureLoaded?(this._setTexture(a,b),this.setColor(this._realColor),this._textureLoaded=!0):(this._renderCmd._setTexture(null),a.addEventListener("load",function(){this._setTexture(a,b),this.setColor(this._realColor),this._textureLoaded=!0},this))},_setTexture:function(a,b){this._renderCmd._setTexture(a),b&&this._changeRectWithTexture(a)},_changeRectWithTexture:function(a){var b=a._contentSize,c=cc.rect(0,0,b.width,b.height);this.setTextureRect(c)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.Sprite.CanvasRenderCmd(this):new cc.Sprite.WebGLRenderCmd(this)}}),cc.Sprite.create=function(a,b,c){return new cc.Sprite(a,b,c)},cc.Sprite.createWithTexture=cc.Sprite.create,cc.Sprite.createWithSpriteFrameName=cc.Sprite.create,cc.Sprite.createWithSpriteFrame=cc.Sprite.create,cc.Sprite.INDEX_NOT_INITIALIZED=-1,cc.EventHelper.prototype.apply(cc.Sprite.prototype),cc.assert(cc.isFunction(cc._tmp.PrototypeSprite),cc._LogInfos.MissingFile,"SpritesPropertyDefine.js"),cc._tmp.PrototypeSprite(),delete cc._tmp.PrototypeSprite,function(){cc.Sprite.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._textureCoord={renderX:0,renderY:0,x:0,y:0,width:0,height:0,validRect:!1},this._blendFuncStr="source-over",this._colorized=!1,this._textureToRender=null};var a=cc.Sprite.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.Sprite.CanvasRenderCmd,a._init=function(){},a.setDirtyRecursively=function(a){},a._resetForBatchNode=function(){},a._setTexture=function(a){var b=this._node;b._texture!==a&&(a?b._textureLoaded=a._textureLoaded:b._textureLoaded=!1,b._texture=a,this._updateColor())},a._setColorDirty=function(){this.setDirtyFlag(cc.Node._dirtyFlags.colorDirty|cc.Node._dirtyFlags.opacityDirty)},a.isFrameDisplayed=function(a){var b=this._node;return a.getTexture()!==b._texture?!1:cc.rectEqualToRect(a.getRect(),b._rect)},a.updateBlendFunc=function(a){this._blendFuncStr=cc.Node.CanvasRenderCmd._getCompositeOperationByBlendFunc(a)},a._setBatchNodeForAddChild=function(a){return!0},a._handleTextureForRotatedTexture=function(a,b,c,d){if(c&&a.isLoaded()){var e=a.getHtmlElementObj();e=cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(e,b,d);var f=new cc.Texture2D;f.initWithElement(e),f.handleLoadedTexture(),a=f,b.x=b.y=0,this._node._rect=cc.rect(0,0,b.width,b.height)}return a},a._checkTextureBoundary=function(a,b,c){if(a&&a.url){var d=b.x+b.width,e=b.y+b.height;d>a.width&&cc.error(cc._LogInfos.RectWidth,a.url),e>a.height&&cc.error(cc._LogInfos.RectHeight,a.url)}},a.rendering=function(a,b,c){var d=this._node,e=this._textureCoord,f=this._displayedOpacity/255,g=this._textureToRender||d._texture;if((!g||0!==e.width&&0!==e.height&&g._textureLoaded)&&0!==f){var h,i=a||cc._renderContext,j=i.getContext(),k=d._offsetPosition.x,l=d._rect.height,m=d._rect.width,n=-d._offsetPosition.y-l;i.setTransform(this._worldTransform,b,c),i.setCompositeOperation(this._blendFuncStr),i.setGlobalAlpha(f),(d._flippedX||d._flippedY)&&i.save(),d._flippedX&&(k=-k-m,j.scale(-1,1)),d._flippedY&&(n=d._offsetPosition.y,j.scale(1,-1));var o,p,q,r,s,t,u,v;if(this._colorized?(o=0,p=0):(o=e.renderX,p=e.renderY),q=e.width,r=e.height,s=k*b,t=n*c,u=m*b,v=l*c,g)h=g._htmlElementObj,""!==g._pattern?(i.setFillStyle(j.createPattern(h,g._pattern)),j.fillRect(s,t,u,v)):j.drawImage(h,o,p,q,r,s,t,u,v);else{var w=d._contentSize;if(e.validRect){var x=this._displayedColor;i.setFillStyle("rgba("+x.r+","+x.g+","+x.b+",1)"),j.fillRect(s,t,w.width*b,w.height*c)}}(d._flippedX||d._flippedY)&&i.restore(),cc.g_NumberOfDraws++}},a._updateColor=function(){var a=this._node,b=a._texture,c=this._textureCoord,d=this._displayedColor;b&&(255!==d.r||255!==d.g||255!==d.b?(this._textureToRender=b._generateColorTexture(d.r,d.g,d.b,c),this._colorized=!0):b&&(this._textureToRender=b,this._colorized=!1))},a.getQuad=function(){return null},a._updateForSetSpriteFrame=function(a,b){if(this._colorized=!1,this._textureCoord.renderX=this._textureCoord.x,this._textureCoord.renderY=this._textureCoord.y,b=b||a._textureLoaded){var c=this._node.getColor();(255!==c.r||255!==c.g||255!==c.b)&&this._updateColor()}},a.updateTransform=function(){var a=this,b=this._node;if(b.dirty){var c=b._parent;!b._visible||c&&c!==b._batchNode&&c._shouldBeHidden?b._shouldBeHidden=!0:(b._shouldBeHidden=!1,c&&c!==b._batchNode?b._transformToBatch=cc.affineTransformConcat(a.getNodeToParentTransform(),c._transformToBatch):b._transformToBatch=a.getNodeToParentTransform()),b._recursiveDirty=!1,b.dirty=!1}b._hasChildren&&b._arrayMakeObjectsPerformSelector(b._children,cc.Node._stateCallbackType.updateTransform)},a._spriteFrameLoadedCallback=function(a){var b=this;b.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize()),b._renderCmd._updateColor(),b.dispatchEvent("load")},a._textureLoadedCallback=function(a){var b=this;if(!b._textureLoaded){b._textureLoaded=!0;var c=b._rect,d=this._renderCmd;c?cc._rectEqualToZero(c)&&(c.width=a.width,c.height=a.height):c=cc.rect(0,0,a.width,a.height),b.texture=a,b.setTextureRect(c,b._rectRotated);var e=d._displayedColor;(255!==e.r||255!==e.g||255!==e.b)&&d._updateColor(),b.setBatchNode(b._batchNode),b.dispatchEvent("load")}},a._setTextureCoords=function(a,b){void 0===b&&(b=!0);var c=this._textureCoord,d=b?cc.contentScaleFactor():1;c.renderX=c.x=0|a.x*d,c.renderY=c.y=0|a.y*d,c.width=0|a.width*d,c.height=0|a.height*d,c.validRect=!(0===c.width||0===c.height||c.x<0||c.y<0)},cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas=function(a,b,c){if(!a)return null;if(!b)return a;c=null==c?!0:c;var d=document.createElement("canvas");d.width=b.width,d.height=b.height;var e=d.getContext("2d");return e.translate(d.width/2,d.height/2),c?e.rotate(-1.5707963267948966):e.rotate(1.5707963267948966),e.drawImage(a,b.x,b.y,b.height,b.width,-b.height/2,-b.width/2,b.height,b.width),d}}(),cc.BakeSprite=cc.Sprite.extend({_cacheCanvas:null,_cacheContext:null,ctor:function(){cc.Sprite.prototype.ctor.call(this);var a=document.createElement("canvas");a.width=a.height=10,this._cacheCanvas=a,this._cacheContext=new cc.CanvasContextWrapper(a.getContext("2d"));var b=new cc.Texture2D;b.initWithElement(a),b.handleLoadedTexture(),this.setTexture(b)},getCacheContext:function(){return this._cacheContext},getCacheCanvas:function(){return this._cacheCanvas},resetCanvasSize:function(a,b){var c=this._cacheCanvas,d=this._cacheContext,e=d._context.strokeStyle,f=d._context.fillStyle;void 0===b&&(b=a.height,a=a.width),c.width=a,c.height=b,e!==d._context.strokeStyle&&(d._context.strokeStyle=e),f!==d._context.fillStyle&&(d._context.fillStyle=f),this.getTexture().handleLoadedTexture(),this.setTextureRect(cc.rect(0,0,a,b),!1,null,!1)}}),cc.AnimationFrame=cc.Class.extend({_spriteFrame:null,_delayPerUnit:0,_userInfo:null,ctor:function(a,b,c){this._spriteFrame=a||null,this._delayPerUnit=b||0,this._userInfo=c||null},clone:function(){var a=new cc.AnimationFrame;return a.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo),a},copyWithZone:function(a){return cc.clone(this)},copy:function(a){var b=new cc.AnimationFrame;return b.initWithSpriteFrame(this._spriteFrame.clone(),this._delayPerUnit,this._userInfo),b},initWithSpriteFrame:function(a,b,c){return this._spriteFrame=a,this._delayPerUnit=b,this._userInfo=c,!0},getSpriteFrame:function(){return this._spriteFrame},setSpriteFrame:function(a){this._spriteFrame=a},getDelayUnits:function(){return this._delayPerUnit},setDelayUnits:function(a){this._delayPerUnit=a},getUserInfo:function(){return this._userInfo},setUserInfo:function(a){this._userInfo=a}}),cc.AnimationFrame.create=function(a,b,c){return new cc.AnimationFrame(a,b,c)},cc.Animation=cc.Class.extend({_frames:null,_loops:0,_restoreOriginalFrame:!1,_duration:0,_delayPerUnit:0,_totalDelayUnits:0,ctor:function(a,b,c){if(this._frames=[],void 0===a)this.initWithSpriteFrames(null,0);else{ +var d=a[0];d&&(d instanceof cc.SpriteFrame?this.initWithSpriteFrames(a,b,c):d instanceof cc.AnimationFrame&&this.initWithAnimationFrames(a,b,c))}},getFrames:function(){return this._frames},setFrames:function(a){this._frames=a},addSpriteFrame:function(a){var b=new cc.AnimationFrame;b.initWithSpriteFrame(a,1,null),this._frames.push(b),this._totalDelayUnits++},addSpriteFrameWithFile:function(a){var b=cc.textureCache.addImage(a),c=cc.rect(0,0,0,0);c.width=b.width,c.height=b.height;var d=new cc.SpriteFrame(b,c);this.addSpriteFrame(d)},addSpriteFrameWithTexture:function(a,b){var c=new cc.SpriteFrame(a,b);this.addSpriteFrame(c)},initWithAnimationFrames:function(a,b,c){cc.arrayVerifyType(a,cc.AnimationFrame),this._delayPerUnit=b,this._loops=void 0===c?1:c,this._totalDelayUnits=0;var d=this._frames;d.length=0;for(var e=0;ea.getPixelsWide()&&cc.error(cc._LogInfos.RectWidth,a.url),g>a.getPixelsHigh()&&cc.error(cc._LogInfos.RectHeight,a.url)}return this._offsetInPixels.x=d.x,this._offsetInPixels.y=d.y,cc._pointPixelsToPointsOut(d,this._offset),this._originalSizeInPixels.width=e.width,this._originalSizeInPixels.height=e.height,cc._sizePixelsToPointsOut(e,this._originalSize),this._rotated=c,!0}}),cc.EventHelper.prototype.apply(cc.SpriteFrame.prototype),cc.SpriteFrame.create=function(a,b,c,d,e){return new cc.SpriteFrame(a,b,c,d,e)},cc.SpriteFrame.createWithTexture=cc.SpriteFrame.create,cc.SpriteFrame._frameWithTextureForCanvas=function(a,b,c,d,e){var f=new cc.SpriteFrame;return f._texture=a,f._rectInPixels=b,f._rect=cc.rectPixelsToPoints(b),f._offsetInPixels.x=d.x,f._offsetInPixels.y=d.y,cc._pointPixelsToPointsOut(f._offsetInPixels,f._offset),f._originalSizeInPixels.width=e.width,f._originalSizeInPixels.height=e.height,cc._sizePixelsToPointsOut(f._originalSizeInPixels,f._originalSize),f._rotated=c,f},cc.spriteFrameCache={_CCNS_REG1:/^\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*$/,_CCNS_REG2:/^\s*\{\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*,\s*\{\s*([\-]?\d+[.]?\d*)\s*,\s*([\-]?\d+[.]?\d*)\s*\}\s*\}\s*$/,_spriteFrames:{},_spriteFramesAliases:{},_frameConfigCache:{},_rectFromString:function(a){var b=this._CCNS_REG2.exec(a);return b?cc.rect(parseFloat(b[1]),parseFloat(b[2]),parseFloat(b[3]),parseFloat(b[4])):cc.rect(0,0,0,0)},_pointFromString:function(a){var b=this._CCNS_REG1.exec(a);return b?cc.p(parseFloat(b[1]),parseFloat(b[2])):cc.p(0,0)},_sizeFromString:function(a){var b=this._CCNS_REG1.exec(a);return b?cc.size(parseFloat(b[1]),parseFloat(b[2])):cc.size(0,0)},_getFrameConfig:function(a){var b=cc.loader.getRes(a);return cc.assert(b,cc._LogInfos.spriteFrameCache__getFrameConfig_2,a),cc.loader.release(a),b._inited?(this._frameConfigCache[a]=b,b):(this._frameConfigCache[a]=this._parseFrameConfig(b),this._frameConfigCache[a])},_getFrameConfigByJsonObject:function(a,b){return cc.assert(b,cc._LogInfos.spriteFrameCache__getFrameConfig_2,a),this._frameConfigCache[a]=this._parseFrameConfig(b),this._frameConfigCache[a]},_parseFrameConfig:function(a){var b=a.frames,c=a.metadata||a.meta,d={},e={},f=0;if(c){var g=c.format;f=g.length<=1?parseInt(g):g,e.image=c.textureFileName||c.textureFileName||c.image}for(var h in b){var i=b[h];if(i){var j={};if(0==f){j.rect=cc.rect(i.x,i.y,i.width,i.height),j.rotated=!1,j.offset=cc.p(i.offsetX,i.offsetY);var k=i.originalWidth,l=i.originalHeight;k&&l||cc.log(cc._LogInfos.spriteFrameCache__getFrameConfig),k=Math.abs(k),l=Math.abs(l),j.size=cc.size(k,l)}else if(1==f||2==f)j.rect=this._rectFromString(i.frame),j.rotated=i.rotated||!1,j.offset=this._pointFromString(i.offset),j.size=this._sizeFromString(i.sourceSize);else if(3==f){var m=this._sizeFromString(i.spriteSize),n=this._rectFromString(i.textureRect);m&&(n=cc.rect(n.x,n.y,m.width,m.height)),j.rect=n,j.rotated=i.textureRotated||!1,j.offset=this._pointFromString(i.spriteOffset),j.size=this._sizeFromString(i.spriteSourceSize),j.aliases=i.aliases}else{var o=i.frame,p=i.sourceSize;h=i.filename||h,j.rect=cc.rect(o.x,o.y,o.w,o.h),j.rotated=i.rotated||!1,j.offset=cc.p(0,0),j.size=cc.size(p.w,p.h)}d[h]=j}}return{_inited:!0,frames:d,meta:e}},_addSpriteFramesByObject:function(a,b,c){if(cc.assert(a,cc._LogInfos.spriteFrameCache_addSpriteFrames_2),b&&b.frames){var d=this._frameConfigCache[a]||this._getFrameConfigByJsonObject(a,b);this._createSpriteFrames(a,d,c)}},_createSpriteFrames:function(a,b,c){var d=b.frames,e=b.meta;if(c)c instanceof cc.Texture2D||(cc.isString(c)?c=cc.textureCache.addImage(c):cc.assert(0,cc._LogInfos.spriteFrameCache_addSpriteFrames_3));else{var f=cc.path.changeBasename(a,e.image||".png");c=cc.textureCache.addImage(f)}var g=this._spriteFramesAliases,h=this._spriteFrames;for(var i in d){var j=d[i],k=h[i];if(!k){k=new cc.SpriteFrame(c,j.rect,j.rotated,j.offset,j.size);var l=j.aliases;if(l)for(var m=0,n=l.length;n>m;m++){var o=l[m];g[o]&&cc.log(cc._LogInfos.spriteFrameCache_addSpriteFrames,o),g[o]=i}if(cc._renderType===cc.game.RENDER_TYPE_CANVAS&&k.isRotated()){var p=k.getTexture();if(p.isLoaded()){var q=k.getTexture().getHtmlElementObj();q=cc.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(q,k.getRectInPixels());var r=new cc.Texture2D;r.initWithElement(q),r.handleLoadedTexture(),k.setTexture(r);var s=k._rect;k.setRect(cc.rect(0,0,s.width,s.height))}}h[i]=k}}},addSpriteFrames:function(a,b){cc.assert(a,cc._LogInfos.spriteFrameCache_addSpriteFrames_2);var c=this._frameConfigCache[a]||cc.loader.getRes(a);if(c&&c.frames){var d=this._frameConfigCache[a]||this._getFrameConfig(a);this._createSpriteFrames(a,d,b)}},_checkConflict:function(a){var b=a.frames;for(var c in b)this._spriteFrames[c]&&cc.log(cc._LogInfos.spriteFrameCache__checkConflict,c)},addSpriteFrame:function(a,b){this._spriteFrames[b]=a},removeSpriteFrames:function(){this._spriteFrames={},this._spriteFramesAliases={}},removeSpriteFrameByName:function(a){a&&(this._spriteFramesAliases[a]&&delete this._spriteFramesAliases[a],this._spriteFrames[a]&&delete this._spriteFrames[a])},removeSpriteFramesFromFile:function(a){var b=this,c=b._spriteFrames,d=b._spriteFramesAliases,e=b._frameConfigCache[a];if(e){var f=e.frames;for(var g in f)if(c[g]){delete c[g];for(var h in d)d[h]===g&&delete d[h]}}},removeSpriteFramesFromTexture:function(a){var b=this,c=b._spriteFrames,d=b._spriteFramesAliases;for(var e in c){var f=c[e];if(f&&f.getTexture()===a){delete c[e];for(var g in d)d[g]===e&&delete d[g]}}},getSpriteFrame:function(a){var b=this,c=b._spriteFrames[a];if(!c){var d=b._spriteFramesAliases[a];d&&(c=b._spriteFrames[d.toString()],c||delete b._spriteFramesAliases[a])}return c},_clear:function(){this._spriteFrames={},this._spriteFramesAliases={},this._frameConfigCache={}}},cc.g_NumberOfDraws=0,cc.GLToClipTransform=function(a){cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,a);var b=new cc.math.Matrix4;cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW,b),a.multiply(b)},cc.Director=cc.Class.extend({_landscape:!1,_nextDeltaTimeZero:!1,_paused:!1,_purgeDirectorInNextLoop:!1,_sendCleanupToScene:!1,_animationInterval:0,_oldAnimationInterval:0,_projection:0,_contentScaleFactor:1,_deltaTime:0,_winSizeInPoints:null,_lastUpdate:null,_nextScene:null,_notificationNode:null,_openGLView:null,_scenesStack:null,_projectionDelegate:null,_runningScene:null,_totalFrames:0,_secondsPerFrame:0,_dirtyRegion:null,_scheduler:null,_actionManager:null,_eventProjectionChanged:null,_eventAfterUpdate:null,_eventAfterVisit:null,_eventAfterDraw:null,ctor:function(){var a=this;a._lastUpdate=Date.now(),cc.eventManager.addCustomListener(cc.game.EVENT_SHOW,function(){a._lastUpdate=Date.now()})},init:function(){return this._oldAnimationInterval=this._animationInterval=1/cc.defaultFPS,this._scenesStack=[],this._projection=cc.Director.PROJECTION_DEFAULT,this._projectionDelegate=null,this._totalFrames=0,this._lastUpdate=Date.now(),this._paused=!1,this._purgeDirectorInNextLoop=!1,this._winSizeInPoints=cc.size(0,0),this._openGLView=null,this._contentScaleFactor=1,this._scheduler=new cc.Scheduler,cc.ActionManager?(this._actionManager=new cc.ActionManager,this._scheduler.scheduleUpdate(this._actionManager,cc.Scheduler.PRIORITY_SYSTEM,!1)):this._actionManager=null,this._eventAfterUpdate=new cc.EventCustom(cc.Director.EVENT_AFTER_UPDATE),this._eventAfterUpdate.setUserData(this),this._eventAfterVisit=new cc.EventCustom(cc.Director.EVENT_AFTER_VISIT),this._eventAfterVisit.setUserData(this),this._eventAfterDraw=new cc.EventCustom(cc.Director.EVENT_AFTER_DRAW),this._eventAfterDraw.setUserData(this),this._eventProjectionChanged=new cc.EventCustom(cc.Director.EVENT_PROJECTION_CHANGED),this._eventProjectionChanged.setUserData(this),!0},calculateDeltaTime:function(){var a=Date.now();this._nextDeltaTimeZero?(this._deltaTime=0,this._nextDeltaTimeZero=!1):this._deltaTime=(a-this._lastUpdate)/1e3,cc.game.config[cc.game.CONFIG_KEY.debugMode]>0&&this._deltaTime>.2&&(this._deltaTime=1/60),this._lastUpdate=a},convertToGL:null,convertToUI:null,drawScene:function(){var a=cc.renderer;this.calculateDeltaTime(),this._paused||(this._scheduler.update(this._deltaTime),cc.eventManager.dispatchEvent(this._eventAfterUpdate)),a.clear(),this._nextScene&&this.setNextScene(),this._beforeVisitScene&&this._beforeVisitScene(),this._runningScene&&(a.childrenOrderDirty===!0?(cc.renderer.clearRenderCommands(),this._runningScene._renderCmd._curLevel=0,this._runningScene.visit(),a.resetFlag()):a.transformDirty()===!0&&a.transform()),this._notificationNode&&this._notificationNode.visit(),cc.eventManager.dispatchEvent(this._eventAfterVisit),cc.g_NumberOfDraws=0,this._afterVisitScene&&this._afterVisitScene(),a.rendering(cc._renderContext),this._totalFrames++,cc.eventManager.dispatchEvent(this._eventAfterDraw),this._calculateMPF()},_beforeVisitScene:null,_afterVisitScene:null,end:function(){this._purgeDirectorInNextLoop=!0},getContentScaleFactor:function(){return this._contentScaleFactor},getNotificationNode:function(){return this._notificationNode},getWinSize:function(){return cc.size(this._winSizeInPoints)},getWinSizeInPixels:function(){return cc.size(this._winSizeInPoints.width*this._contentScaleFactor,this._winSizeInPoints.height*this._contentScaleFactor)},getVisibleSize:null,getVisibleOrigin:null,getZEye:null,pause:function(){this._paused||(this._oldAnimationInterval=this._animationInterval,this.setAnimationInterval(.25),this._paused=!0)},popScene:function(){cc.assert(this._runningScene,cc._LogInfos.Director_popScene),this._scenesStack.pop();var a=this._scenesStack.length;0===a?this.end():(this._sendCleanupToScene=!0,this._nextScene=this._scenesStack[a-1])},purgeCachedData:function(){cc.animationCache._clear(),cc.spriteFrameCache._clear(),cc.textureCache._clear()},purgeDirector:function(){this.getScheduler().unscheduleAll(),cc.eventManager&&cc.eventManager.setEnabled(!1),this._runningScene&&(this._runningScene.onExitTransitionDidStart(),this._runningScene.onExit(),this._runningScene.cleanup()),this._runningScene=null,this._nextScene=null,this._scenesStack.length=0,this.stopAnimation(),this.purgeCachedData(),cc.checkGLErrorDebug()},pushScene:function(a){cc.assert(a,cc._LogInfos.Director_pushScene),this._sendCleanupToScene=!1,this._scenesStack.push(a),this._nextScene=a},runScene:function(a){if(cc.assert(a,cc._LogInfos.Director_pushScene),this._runningScene){var b=this._scenesStack.length;0===b?(this._sendCleanupToScene=!0,this._scenesStack[b]=a,this._nextScene=a):(this._sendCleanupToScene=!0,this._scenesStack[b-1]=a,this._nextScene=a)}else this.pushScene(a),this.startAnimation()},resume:function(){this._paused&&(this.setAnimationInterval(this._oldAnimationInterval),this._lastUpdate=Date.now(),this._lastUpdate||cc.log(cc._LogInfos.Director_resume),this._paused=!1,this._deltaTime=0)},setContentScaleFactor:function(a){a!==this._contentScaleFactor&&(this._contentScaleFactor=a)},setDepthTest:null,setClearColor:null,setDefaultValues:function(){},setNextDeltaTimeZero:function(a){this._nextDeltaTimeZero=a},setNextScene:function(){var a=!1,b=!1;if(cc.TransitionScene&&(a=this._runningScene?this._runningScene instanceof cc.TransitionScene:!1,b=this._nextScene?this._nextScene instanceof cc.TransitionScene:!1),!b){var c=this._runningScene;c&&(c.onExitTransitionDidStart(),c.onExit()),this._sendCleanupToScene&&c&&c.cleanup()}this._runningScene=this._nextScene,cc.renderer.childrenOrderDirty=!0,this._nextScene=null,a||null===this._runningScene||(this._runningScene.onEnter(),this._runningScene.onEnterTransitionDidFinish())},setNotificationNode:function(a){cc.renderer.childrenOrderDirty=!0,this._notificationNode&&(this._notificationNode.onExitTransitionDidStart(),this._notificationNode.onExit(),this._notificationNode.cleanup()),this._notificationNode=a,a&&(this._notificationNode.onEnter(),this._notificationNode.onEnterTransitionDidFinish())},getDelegate:function(){return this._projectionDelegate},setDelegate:function(a){this._projectionDelegate=a},setOpenGLView:null,setProjection:null,setViewport:null,getOpenGLView:null,getProjection:null,setAlphaBlending:null,isSendCleanupToScene:function(){return this._sendCleanupToScene},getRunningScene:function(){return this._runningScene},getAnimationInterval:function(){return this._animationInterval},isDisplayStats:function(){return cc.profiler?cc.profiler.isShowingStats():!1},setDisplayStats:function(a){cc.profiler&&(a?cc.profiler.showStats():cc.profiler.hideStats())},getSecondsPerFrame:function(){return this._secondsPerFrame},isNextDeltaTimeZero:function(){return this._nextDeltaTimeZero},isPaused:function(){return this._paused},getTotalFrames:function(){return this._totalFrames},popToRootScene:function(){this.popToSceneStackLevel(1)},popToSceneStackLevel:function(a){cc.assert(this._runningScene,cc._LogInfos.Director_popToSceneStackLevel_2);var b=this._scenesStack,c=b.length;if(0===a)return void this.end();if(!(a>=c)){for(;c>a;){var d=b.pop();d.running&&(d.onExitTransitionDidStart(),d.onExit()),d.cleanup(),c--}this._nextScene=b[b.length-1],this._sendCleanupToScene=!0}},getScheduler:function(){return this._scheduler},setScheduler:function(a){this._scheduler!==a&&(this._scheduler=a)},getActionManager:function(){return this._actionManager},setActionManager:function(a){this._actionManager!==a&&(this._actionManager=a)},getDeltaTime:function(){return this._deltaTime},_calculateMPF:function(){var a=Date.now();this._secondsPerFrame=(a-this._lastUpdate)/1e3}}),cc.Director.EVENT_PROJECTION_CHANGED="director_projection_changed",cc.Director.EVENT_AFTER_UPDATE="director_after_update",cc.Director.EVENT_AFTER_VISIT="director_after_visit",cc.Director.EVENT_AFTER_DRAW="director_after_draw",cc.DisplayLinkDirector=cc.Director.extend({invalid:!1,startAnimation:function(){this._nextDeltaTimeZero=!0,this.invalid=!1},mainLoop:function(){this._purgeDirectorInNextLoop?(this._purgeDirectorInNextLoop=!1,this.purgeDirector()):this.invalid||this.drawScene()},stopAnimation:function(){this.invalid=!0},setAnimationInterval:function(a){this._animationInterval=a,this.invalid||(this.stopAnimation(),this.startAnimation())}}),cc.Director.sharedDirector=null,cc.Director.firstUseDirector=!0,cc.Director._getInstance=function(){return cc.Director.firstUseDirector&&(cc.Director.firstUseDirector=!1,cc.Director.sharedDirector=new cc.DisplayLinkDirector,cc.Director.sharedDirector.init()),cc.Director.sharedDirector},cc.defaultFPS=60,cc.Director.PROJECTION_2D=0,cc.Director.PROJECTION_3D=1,cc.Director.PROJECTION_CUSTOM=3,cc.Director.PROJECTION_DEFAULT=cc.Director.PROJECTION_3D,cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_CANVAS){var a=cc.Director.prototype;a.getProjection=function(a){return this._projection},a.setProjection=function(a){this._projection=a,cc.eventManager.dispatchEvent(this._eventProjectionChanged)},a.setDepthTest=function(){},a.setClearColor=function(a){cc.renderer._clearColor=a,cc.renderer._clearFillStyle="rgb("+a.r+","+a.g+","+a.b+")"},a.setOpenGLView=function(a){this._winSizeInPoints.width=cc._canvas.width,this._winSizeInPoints.height=cc._canvas.height,this._openGLView=a||cc.view,cc.eventManager&&cc.eventManager.setEnabled(!0)},a.getVisibleSize=function(){return this.getWinSize()},a.getVisibleOrigin=function(){return cc.p(0,0)}}else cc.Director._fpsImage=new Image,cc.Director._fpsImage.addEventListener("load",function(){cc.Director._fpsImageLoaded=!0}),cc._fpsImage&&(cc.Director._fpsImage.src=cc._fpsImage)}),cc.PRIORITY_NON_SYSTEM=cc.PRIORITY_SYSTEM+1,cc.ListEntry=function(a,b,c,d,e,f,g){this.prev=a,this.next=b,this.callback=c,this.target=d,this.priority=e,this.paused=f,this.markedForDeletion=g},cc.HashUpdateEntry=function(a,b,c,d,e){this.list=a,this.entry=b,this.target=c,this.callback=d,this.hh=e},cc.HashTimerEntry=cc.hashSelectorEntry=function(a,b,c,d,e,f,g){var h=this;h.timers=a,h.target=b,h.timerIndex=c,h.currentTimer=d,h.currentTimerSalvaged=e,h.paused=f,h.hh=g},cc.Timer=cc.Class.extend({_scheduler:null,_elapsed:0,_runForever:!1,_useDelay:!1,_timesExecuted:0,_repeat:0,_delay:0,_interval:0,getInterval:function(){return this._interval},setInterval:function(a){this._interval=a},setupTimerWithInterval:function(a,b,c){this._elapsed=-1,this._interval=a,this._delay=c,this._useDelay=this._delay>0,this._repeat=b,this._runForever=this._repeat===cc.REPEAT_FOREVER},trigger:function(){return 0},cancel:function(){return 0},ctor:function(){this._scheduler=null,this._elapsed=-1,this._runForever=!1,this._useDelay=!1,this._timesExecuted=0,this._repeat=0,this._delay=0,this._interval=0},update:function(a){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=a,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))}}),cc.TimerTargetSelector=cc.Timer.extend({_target:null,_selector:null,ctor:function(){this._target=null,this._selector=null},initWithSelector:function(a,b,c,d,e,f){return this._scheduler=a,this._target=c,this._selector=b,this.setupTimerWithInterval(d,e,f),!0},getSelector:function(){return this._selector},trigger:function(){this._target&&this._selector&&this._target.call(this._selector,this._elapsed)},cancel:function(){this._scheduler.unschedule(this._selector,this._target)}}),cc.TimerTargetCallback=cc.Timer.extend({_target:null,_callback:null,_key:null,ctor:function(){this._target=null,this._callback=null},initWithCallback:function(a,b,c,d,e,f,g){return this._scheduler=a,this._target=c,this._callback=b,this._key=d,this.setupTimerWithInterval(e,f,g),!0},getCallback:function(){return this._callback},getKey:function(){return this._key},trigger:function(){this._callback&&this._callback.call(this._target,this._elapsed)},cancel:function(){this._scheduler.unschedule(this._callback,this._target)}}),cc.Scheduler=cc.Class.extend({_timeScale:1,_updatesNegList:null,_updates0List:null,_updatesPosList:null,_hashForTimers:null,_arrayForTimers:null,_hashForUpdates:null,_currentTarget:null,_currentTargetSalvaged:!1,_updateHashLocked:!1,ctor:function(){this._timeScale=1,this._updatesNegList=[],this._updates0List=[],this._updatesPosList=[],this._hashForUpdates={},this._hashForTimers={},this._currentTarget=null,this._currentTargetSalvaged=!1,this._updateHashLocked=!1,this._arrayForTimers=[]},_schedulePerFrame:function(a,b,c,d){var e=this._hashForUpdates[b.__instanceId];if(e&&e.entry){if(e.entry.priority===c)return e.entry.markedForDeletion=!1,void(e.entry.paused=d);if(this._updateHashLocked)return cc.log("warning: you CANNOT change update priority in scheduled function"),e.entry.markedForDeletion=!1,void(e.entry.paused=d);this.unscheduleUpdate(b)}0===c?this._appendIn(this._updates0List,a,b,d):0>c?this._priorityIn(this._updatesNegList,a,b,c,d):this._priorityIn(this._updatesPosList,a,b,c,d)},_removeHashElement:function(a){delete this._hashForTimers[a.target.__instanceId],cc.arrayRemoveObject(this._arrayForTimers,a),a.Timer=null,a.target=null,a=null},_removeUpdateFromHash:function(a){var b=this,c=b._hashForUpdates[a.target.__instanceId];c&&(cc.arrayRemoveObject(c.list,c.entry),delete b._hashForUpdates[c.target.__instanceId],c.entry=null,c.target=null)},_priorityIn:function(a,b,c,d,e){var f=this,g=new cc.ListEntry(null,null,b,c,d,e,!1);if(a){for(var h=a.length-1,i=0;h>=i;i++)if(db;b++)e=c[b],e.paused||e.markedForDeletion||e.callback(a);for(b=0,c=this._updates0List,d=c.length;d>b;b++)e=c[b],e.paused||e.markedForDeletion||e.callback(a);for(b=0,c=this._updatesPosList,d=c.length;d>b;b++)e=c[b],e.paused||e.markedForDeletion||e.callback(a);var f,g=this._arrayForTimers;for(b=0;bf;f++){var h=e[f];if(this._getUnscheduleMark(a,h))return h!==d.currentTimer||d.currentTimerSalvaged||(d.currentTimerSalvaged=!0),e.splice(f,1),d.timerIndex>=f&&d.timerIndex--,void(0===e.length&&(c._currentTarget===d?c._currentTargetSalvaged=!0:c._removeHashElement(d)))}}},unscheduleUpdate:function(a){if(null!=a){var b=this._hashForUpdates[a.__instanceId];b&&(this._updateHashLocked?b.entry.markedForDeletion=!0:this._removeUpdateFromHash(b.entry))}},unscheduleAllForTarget:function(a){if(null!=a){var b=this._hashForTimers[a.__instanceId];b&&(b.timers.indexOf(b.currentTimer)>-1&&!b.currentTimerSalvaged&&(b.currentTimerSalvaged=!0), +b.timers.length=0,this._currentTarget===b?this._currentTargetSalvaged=!0:this._removeHashElement(b)),this.unscheduleUpdate(a)}},unscheduleAll:function(){this.unscheduleAllWithMinPriority(cc.Scheduler.PRIORITY_SYSTEM)},unscheduleAllWithMinPriority:function(a){var b,c,d=this._arrayForTimers;for(b=d.length-1;b>=0;b--)c=d[b],this.unscheduleAllForTarget(c.target);var e,f=0;if(0>a)for(b=0;b=a&&this.unscheduleUpdate(e.target),f==this._updatesNegList.length&&b++;if(0>=a)for(b=0;b=a&&this.unscheduleUpdate(e.target),f==this._updatesPosList.length&&b++},isScheduled:function(a,b){cc.assert(a,"Argument key must not be empty"),cc.assert(b,"Argument target must be non-nullptr");var c=this._hashForUpdates[b.__instanceId];if(!c)return!1;if(null==c.timers)return!1;for(var d=c.timers,e=0;ec;c++)b=g[c],b&&(b.paused=!0,e.push(b.target));var h;if(0>a)for(c=0;c=a&&(h.paused=!0,e.push(h.target));if(0>=a)for(c=0;c=a&&(h.paused=!0,e.push(h.target));return e},resumeTargets:function(a){if(a)for(var b=0;b"},getLineHeight:function(){return!this._lineHeight||this._lineHeight.charAt?this._renderCmd._getFontClientHeight():this._lineHeight||this._renderCmd._getFontClientHeight()},setLineHeight:function(a){this._lineHeight=a},getString:function(){return this._string},getHorizontalAlignment:function(){return this._hAlignment},getVerticalAlignment:function(){return this._vAlignment},getDimensions:function(){return cc.size(this._dimensions)},getFontSize:function(){return this._fontSize},getFontName:function(){return this._fontName},initWithStringAndTextDefinition:function(a,b){return this._updateWithTextDefinition(b,!1),this.string=a,!0},setTextDefinition:function(a){a&&this._updateWithTextDefinition(a,!0)},getTextDefinition:function(){return this._prepareTextDefinition(!1)},enableShadow:function(a,b,c,d){null!=a.r&&null!=a.g&&null!=a.b&&null!=a.a?this._enableShadow(a,b,c):this._enableShadowNoneColor(a,b,c,d)},_enableShadowNoneColor:function(a,b,c,d){c=c||.5,!1===this._shadowEnabled&&(this._shadowEnabled=!0);var e=this._shadowOffset;(e&&e.x!==a||e._y!==b)&&(e.x=a,e.y=b),this._shadowOpacity!==c&&(this._shadowOpacity=c),this._renderCmd._setColorsString(),this._shadowBlur!==d&&(this._shadowBlur=d),this._setUpdateTextureDirty()},_enableShadow:function(a,b,c){this._shadowColor||(this._shadowColor=cc.color(255,255,255,128)),this._shadowColor.r=a.r,this._shadowColor.g=a.g,this._shadowColor.b=a.b;var d,e,f,g;d=b.width||b.x||0,e=b.height||b.y||0,f=null!=a.a?a.a/255:.5,g=c,this._enableShadowNoneColor(d,e,f,g)},_getShadowOffsetX:function(){return this._shadowOffset.x},_setShadowOffsetX:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0),this._shadowOffset.x!==a&&(this._shadowOffset.x=a,this._setUpdateTextureDirty())},_getShadowOffsetY:function(){return this._shadowOffset._y},_setShadowOffsetY:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0),this._shadowOffset._y!==a&&(this._shadowOffset._y=a,this._setUpdateTextureDirty())},_getShadowOffset:function(){return cc.p(this._shadowOffset.x,this._shadowOffset.y)},_setShadowOffset:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0),(this._shadowOffset.x!==a.x||this._shadowOffset.y!==a.y)&&(this._shadowOffset.x=a.x,this._shadowOffset.y=a.y,this._setUpdateTextureDirty())},_getShadowOpacity:function(){return this._shadowOpacity},_setShadowOpacity:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0),this._shadowOpacity!==a&&(this._shadowOpacity=a,this._renderCmd._setColorsString(),this._setUpdateTextureDirty())},_getShadowBlur:function(){return this._shadowBlur},_setShadowBlur:function(a){!1===this._shadowEnabled&&(this._shadowEnabled=!0),this._shadowBlur!==a&&(this._shadowBlur=a,this._setUpdateTextureDirty())},disableShadow:function(){this._shadowEnabled&&(this._shadowEnabled=!1,this._setUpdateTextureDirty())},enableStroke:function(a,b){this._strokeEnabled===!1&&(this._strokeEnabled=!0);var c=this._strokeColor;(c.r!==a.r||c.g!==a.g||c.b!==a.b)&&(c.r=a.r,c.g=a.g,c.b=a.b,this._renderCmd._setColorsString()),this._strokeSize!==b&&(this._strokeSize=b||0),this._setUpdateTextureDirty()},_getStrokeStyle:function(){return this._strokeColor},_setStrokeStyle:function(a){this._strokeEnabled===!1&&(this._strokeEnabled=!0);var b=this._strokeColor;(b.r!==a.r||b.g!==a.g||b.b!==a.b)&&(b.r=a.r,b.g=a.g,b.b=a.b,this._renderCmd._setColorsString(),this._setUpdateTextureDirty())},_getLineWidth:function(){return this._strokeSize},_setLineWidth:function(a){this._strokeEnabled===!1&&(this._strokeEnabled=!0),this._strokeSize!==a&&(this._strokeSize=a||0,this._setUpdateTextureDirty())},disableStroke:function(){this._strokeEnabled&&(this._strokeEnabled=!1,this._setUpdateTextureDirty())},setFontFillColor:function(a){var b=this._textFillColor;(b.r!==a.r||b.g!==a.g||b.b!==a.b)&&(b.r=a.r,b.g=a.g,b.b=a.b,this._renderCmd._setColorsString(),this._needUpdateTexture=!0)},_getFillStyle:function(){return this._textFillColor},_updateWithTextDefinition:function(a,b){a.fontDimensions?(this._dimensions.width=a.boundingWidth,this._dimensions.height=a.boundingHeight):(this._dimensions.width=0,this._dimensions.height=0),this._hAlignment=a.textAlign,this._vAlignment=a.verticalAlign,this._fontName=a.fontName,this._fontSize=a.fontSize||12,a.lineHeight?this._lineHeight=a.lineHeight:this._lineHeight=this._fontSize,this._renderCmd._setFontStyle(a),a.shadowEnabled&&this.enableShadow(a.shadowOffsetX,a.shadowOffsetY,a.shadowOpacity,a.shadowBlur),a.strokeEnabled&&this.enableStroke(a.strokeStyle,a.lineWidth),this.setFontFillColor(a.fillStyle),b&&this._renderCmd._updateTexture();var c=cc.Node._dirtyFlags;this._renderCmd.setDirtyFlag(c.colorDirty|c.opacityDirty|c.textDirty)},_prepareTextDefinition:function(a){var b=new cc.FontDefinition;if(a?(b.fontSize=this._fontSize,b.boundingWidth=cc.contentScaleFactor()*this._dimensions.width,b.boundingHeight=cc.contentScaleFactor()*this._dimensions.height):(b.fontSize=this._fontSize,b.boundingWidth=this._dimensions.width,b.boundingHeight=this._dimensions.height),b.fontName=this._fontName,b.textAlign=this._hAlignment,b.verticalAlign=this._vAlignment,this._strokeEnabled){b.strokeEnabled=!0;var c=this._strokeColor;b.strokeStyle=cc.color(c.r,c.g,c.b),b.lineWidth=this._strokeSize}else b.strokeEnabled=!1;this._shadowEnabled?(b.shadowEnabled=!0,b.shadowBlur=this._shadowBlur,b.shadowOpacity=this._shadowOpacity,b.shadowOffsetX=(a?cc.contentScaleFactor():1)*this._shadowOffset.x,b.shadowOffsetY=(a?cc.contentScaleFactor():1)*this._shadowOffset.y):b._shadowEnabled=!1;var d=this._textFillColor;return b.fillStyle=cc.color(d.r,d.g,d.b),b},setString:function(a){a=String(a),this._originalText!==a&&(this._originalText=a+"",this._updateString(),this._setUpdateTextureDirty(),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty))},_updateString:function(){this._string&&""!==this._string||this._string===this._originalText||(cc.renderer.childrenOrderDirty=!0),this._string=this._originalText},setHorizontalAlignment:function(a){a!==this._hAlignment&&(this._hAlignment=a,this._setUpdateTextureDirty())},setVerticalAlignment:function(a){a!==this._vAlignment&&(this._vAlignment=a,this._setUpdateTextureDirty())},setDimensions:function(a,b){var c;void 0===b?(c=a.width,b=a.height):c=a,(c!==this._dimensions.width||b!==this._dimensions.height)&&(this._dimensions.width=c,this._dimensions.height=b,this._updateString(),this._setUpdateTextureDirty())},_getBoundingWidth:function(){return this._dimensions.width},_setBoundingWidth:function(a){a!==this._dimensions.width&&(this._dimensions.width=a,this._updateString(),this._setUpdateTextureDirty())},_getBoundingHeight:function(){return this._dimensions.height},_setBoundingHeight:function(a){a!==this._dimensions.height&&(this._dimensions.height=a,this._updateString(),this._setUpdateTextureDirty())},setFontSize:function(a){this._fontSize!==a&&(this._fontSize=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},setFontName:function(a){this._fontName&&this._fontName!==a&&(this._fontName=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},_getFont:function(){return this._renderCmd._getFontStyle()},_setFont:function(a){var b=cc.LabelTTF._fontStyleRE.exec(a);b&&(this._fontSize=parseInt(b[1]),this._fontName=b[2],this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},getContentSize:function(){return this._needUpdateTexture&&this._renderCmd._updateTTF(),cc.Sprite.prototype.getContentSize.call(this)},_getWidth:function(){return this._needUpdateTexture&&this._renderCmd._updateTTF(),cc.Sprite.prototype._getWidth.call(this)},_getHeight:function(){return this._needUpdateTexture&&this._renderCmd._updateTTF(),cc.Sprite.prototype._getHeight.call(this)},setTextureRect:function(a,b,c){cc.Sprite.prototype.setTextureRect.call(this,a,b,c,!1)},setDrawMode:function(a){this._onCacheCanvasMode=a},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.LabelTTF.WebGLRenderCmd(this):this._onCacheCanvasMode?new cc.LabelTTF.CacheCanvasRenderCmd(this):new cc.LabelTTF.CanvasRenderCmd(this)},_setFontStyle:function(a){this._fontStyle!==a&&(this._fontStyle=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},_getFontStyle:function(){return this._fontStyle},_setFontWeight:function(a){this._fontWeight!==a&&(this._fontWeight=a,this._renderCmd._setFontStyle(this._fontName,this._fontSize,this._fontStyle,this._fontWeight),this._setUpdateTextureDirty())},_getFontWeight:function(){return this._fontWeight}}),cc.assert(cc.isFunction(cc._tmp.PrototypeLabelTTF),cc._LogInfos.MissingFile,"LabelTTFPropertyDefine.js"),cc._tmp.PrototypeLabelTTF(),delete cc._tmp.PrototypeLabelTTF,cc.LabelTTF._fontStyleRE=/^(\d+)px\s+['"]?([\w\s\d]+)['"]?$/,cc.LabelTTF.create=function(a,b,c,d,e,f){return new cc.LabelTTF(a,b,c,d,e,f)},cc.LabelTTF.createWithFontDefinition=cc.LabelTTF.create,cc.USE_LA88_LABELS?cc.LabelTTF._SHADER_PROGRAM=cc.SHADER_POSITION_TEXTURECOLOR:cc.LabelTTF._SHADER_PROGRAM=cc.SHADER_POSITION_TEXTUREA8COLOR,cc.LabelTTF.__labelHeightDiv=document.createElement("div"),cc.LabelTTF.__labelHeightDiv.style.fontFamily="Arial",cc.LabelTTF.__labelHeightDiv.style.position="absolute",cc.LabelTTF.__labelHeightDiv.style.left="-100px",cc.LabelTTF.__labelHeightDiv.style.top="-100px",cc.LabelTTF.__labelHeightDiv.style.lineHeight="normal",document.body?document.body.appendChild(cc.LabelTTF.__labelHeightDiv):window.addEventListener("load",function(){this.removeEventListener("load",arguments.callee,!1),document.body.appendChild(cc.LabelTTF.__labelHeightDiv)},!1),cc.LabelTTF.__getFontHeightByDiv=function(a,b){if(a instanceof cc.FontDefinition){var c=a,d=cc.LabelTTF.__fontHeightCache[c._getCanvasFontStr()];if(d>0)return d;var e=cc.LabelTTF.__labelHeightDiv;return e.innerHTML="ajghl~!",e.style.fontFamily=c.fontName,e.style.fontSize=c.fontSize+"px",e.style.fontStyle=c.fontStyle,e.style.fontWeight=c.fontWeight,d=e.clientHeight,cc.LabelTTF.__fontHeightCache[c._getCanvasFontStr()]=d,e.innerHTML="",d}var d=cc.LabelTTF.__fontHeightCache[a+"."+b];if(d>0)return d;var e=cc.LabelTTF.__labelHeightDiv;return e.innerHTML="ajghl~!",e.style.fontFamily=a,e.style.fontSize=b+"px",d=e.clientHeight,cc.LabelTTF.__fontHeightCache[a+"."+b]=d,e.innerHTML="",d},cc.LabelTTF.__fontHeightCache={},cc.LabelTTF._textAlign=["left","center","right"],cc.LabelTTF._textBaseline=["top","middle","bottom"],cc.LabelTTF.wrapInspection=!0,cc.LabelTTF._wordRex=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)/,cc.LabelTTF._symbolRex=/^[!,.:;}\]%\?>、‘“》?。,!]/,cc.LabelTTF._lastWordRex=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+|\S)$/,cc.LabelTTF._lastEnglish=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]+$/,cc.LabelTTF._firsrEnglish=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôû]/,function(){cc.LabelTTF.RenderCmd=function(){this._fontClientHeight=18,this._fontStyleStr="",this._shadowColorStr="rgba(128, 128, 128, 0.5)",this._strokeColorStr="",this._fillColorStr="rgba(255,255,255,1)",this._labelCanvas=null,this._labelContext=null,this._lineWidths=[],this._strings=[],this._isMultiLine=!1,this._status=[],this._renderingIndex=0};var a=cc.LabelTTF.RenderCmd.prototype;a.constructor=cc.LabelTTF.RenderCmd,a._setFontStyle=function(a,b,c,d){a instanceof cc.FontDefinition?(this._fontStyleStr=a._getCanvasFontStr(),this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(a)):(this._fontStyleStr=c+" "+d+" "+b+"px '"+a+"'",this._fontClientHeight=cc.LabelTTF.__getFontHeightByDiv(a,b))},a._getFontStyle=function(){return this._fontStyleStr},a._getFontClientHeight=function(){return this._fontClientHeight},a._updateColor=function(){this._setColorsString(),this._updateTexture()},a._setColorsString=function(){var a=this._displayedColor,b=this._node,c=b._shadowColor||this._displayedColor,d=b._strokeColor,e=b._textFillColor,f=a.r/255,g=a.g/255,h=a.b/255;this._shadowColorStr="rgba("+(0|f*c.r)+","+(0|g*c.g)+","+(0|h*c.b)+","+b._shadowOpacity+")",this._fillColorStr="rgba("+(0|f*e.r)+","+(0|g*e.g)+","+(0|h*e.b)+", 1)",this._strokeColorStr="rgba("+(0|f*d.r)+","+(0|g*d.g)+","+(0|h*d.b)+", 1)"},a._updateTTF=function(){var a,b,c=this._node,d=c._dimensions.width,e=this._lineWidths;if(e.length=0,this._isMultiLine=!1,this._measureConfig(),0!==d)for(this._strings=c._string.split("\n"),a=0;aa;a++)e.push(this._measure(this._strings[a]));this._strings.length>1&&(this._isMultiLine=!0);var f,g=0,h=0;if(c._strokeEnabled&&(g=h=2*c._strokeSize),c._shadowEnabled){var i=c._shadowOffset;g+=2*Math.abs(i.x),h+=2*Math.abs(i.y)}f=0===d?this._isMultiLine?cc.size(Math.ceil(Math.max.apply(Math,e)+g),Math.ceil(this._fontClientHeight*this._strings.length+h)):cc.size(Math.ceil(this._measure(c._string)+g),Math.ceil(this._fontClientHeight+h)):0===c._dimensions.height?this._isMultiLine?cc.size(Math.ceil(d+g),Math.ceil(c.getLineHeight()*this._strings.length+h)):cc.size(Math.ceil(d+g),Math.ceil(c.getLineHeight()+h)):cc.size(Math.ceil(d+g),Math.ceil(c._dimensions.height+h)),"normal"!==c._getFontStyle()&&(f.width=Math.ceil(f.width+.3*c._fontSize)),c.setContentSize(f),c._strokeShadowOffsetX=g,c._strokeShadowOffsetY=h;var j=c._anchorPoint;this._anchorPointInPoints.x=.5*g+(f.width-g)*j.x,this._anchorPointInPoints.y=.5*h+(f.height-h)*j.y},a._saveStatus=function(){var a=this._node,b=a._strokeShadowOffsetX,c=a._strokeShadowOffsetY,d=a._contentSize.height-c,e=a._vAlignment,f=a._hAlignment,g=.5*b,h=d+.5*c,i=0,j=0,k=[],l=a._contentSize.width-b,m=a.getLineHeight(),n=(m-this._fontClientHeight)/2;if(i+=f===cc.TEXT_ALIGNMENT_RIGHT?l:f===cc.TEXT_ALIGNMENT_CENTER?l/2:0,this._isMultiLine){var o=this._strings.length;e===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM?j=m-2*n+d-m*o:e===cc.VERTICAL_TEXT_ALIGNMENT_CENTER&&(j=(m-2*n)/2+(d-m*o)/2);for(var p=0;o>p;p++){var q=-d+(m*p+n)+j;k.push(q)}}else e===cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM||(j-=e===cc.VERTICAL_TEXT_ALIGNMENT_TOP?d:.5*d),k.push(j);var r={contextTransform:cc.p(g,h),xOffset:i,OffsetYArray:k};this._status.push(r)},a._drawTTFInCanvas=function(a){if(a){var b=this._status.pop();a.setTransform(1,0,0,1,b.contextTransform.x,b.contextTransform.y);var c=b.xOffset,d=b.OffsetYArray;this.drawLabels(a,c,d)}},a._checkWarp=function(a,b,c){var d=a[b],e=this._measure(d);if(e>c&&d.length>1){for(var f,g=d.length*(c/e)|0,h=d.substr(g),i=e-this._measure(h),j=0,k=0;i>c&&k++<100;)g*=c/i,g=0|g,h=d.substr(g),i=e-this._measure(h);for(k=0;c>i&&k++<100;){if(h){var l=cc.LabelTTF._wordRex.exec(h);j=l?l[0].length:1,f=h}g+=j,h=d.substr(g),i=e-this._measure(h)}g-=j,0===g&&(g=1,f=f.substr(1));var m,n=d.substr(0,g);cc.LabelTTF.wrapInspection&&cc.LabelTTF._symbolRex.test(f||h)&&(m=cc.LabelTTF._lastWordRex.exec(n),g-=m?m[0].length:0,f=d.substr(g),n=d.substr(0,g)),cc.LabelTTF._firsrEnglish.test(f)&&(m=cc.LabelTTF._lastEnglish.exec(n),m&&n!==m[0]&&(g-=m[0].length,f=d.substr(g),n=d.substr(0,g))),a[b]=f||h,a.splice(b,0,n)}},a.updateStatus=function(){var a=cc.Node._dirtyFlags,b=this._dirtyFlag;cc.Node.RenderCmd.prototype.updateStatus.call(this),b&a.textDirty&&this._updateTexture(),this._dirtyFlag&a.transformDirty&&(this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty^this._dirtyFlag)},a._syncStatus=function(a){var b=cc.Node._dirtyFlags,c=this._dirtyFlag;cc.Node.RenderCmd.prototype._syncStatus.call(this,a),c&b.textDirty&&this._updateTexture(),(cc._renderType===cc.game.RENDER_TYPE_WEBGL||c&b.transformDirty)&&this.transform(a)},a.drawLabels=function(a,b,c){var d=this._node;if(d._shadowEnabled){var e=d._shadowOffset;a.shadowColor=this._shadowColorStr,a.shadowOffsetX=e.x,a.shadowOffsetY=-e.y,a.shadowBlur=d._shadowBlur}var f=d._hAlignment,g=d._vAlignment,h=d._strokeSize;a.font!==this._fontStyleStr&&(a.font=this._fontStyleStr),a.fillStyle=this._fillColorStr;var i=d._strokeEnabled;i&&(a.lineWidth=2*h,a.strokeStyle=this._strokeColorStr),a.textBaseline=cc.LabelTTF._textBaseline[g],a.textAlign=cc.LabelTTF._textAlign[f];for(var j=this._strings.length,k=0;j>k;k++){var l=this._strings[k];i&&a.strokeText(l,b,c[k]),a.fillText(l,b,c[k])}cc.g_NumberOfDraws++}}(),function(){cc.LabelTTF.CacheRenderCmd=function(a){cc.LabelTTF.RenderCmd.call(this,a);var b=this._labelCanvas=document.createElement("canvas");b.width=1,b.height=1,this._labelContext=b.getContext("2d")},cc.LabelTTF.CacheRenderCmd.prototype=Object.create(cc.LabelTTF.RenderCmd.prototype),cc.inject(cc.LabelTTF.RenderCmd.prototype,cc.LabelTTF.CacheRenderCmd.prototype);var a=cc.LabelTTF.CacheRenderCmd.prototype;a.constructor=cc.LabelTTF.CacheRenderCmd,a._updateTexture=function(){this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.textDirty^this._dirtyFlag;var a=this._node,b=a._contentSize;this._updateTTF();var c=b.width,d=b.height,e=this._labelContext,f=this._labelCanvas;if(!a._texture){var g=new cc.Texture2D;g.initWithElement(this._labelCanvas),a.setTexture(g)}if(0===a._string.length)return f.width=1,f.height=b.height||1,a._texture&&a._texture.handleLoadedTexture(),a.setTextureRect(cc.rect(0,0,1,b.height)),!0;e.font=this._fontStyleStr;var h=f.width===c&&f.height===d;return f.width=c,f.height=d,h&&e.clearRect(0,0,c,d),this._saveStatus(),this._drawTTFInCanvas(e),a._texture&&a._texture.handleLoadedTexture(),a.setTextureRect(cc.rect(0,0,c,d)),!0},a._measureConfig=function(){this._labelContext.font=this._fontStyleStr},a._measure=function(a){return this._labelContext.measureText(a).width}}(),function(){cc.LabelTTF.CacheCanvasRenderCmd=function(a){cc.Sprite.CanvasRenderCmd.call(this,a),cc.LabelTTF.CacheRenderCmd.call(this)};var a=cc.LabelTTF.CacheCanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype);cc.inject(cc.LabelTTF.CacheRenderCmd.prototype,a),a.constructor=cc.LabelTTF.CacheCanvasRenderCmd}(),function(){cc.LabelTTF.CanvasRenderCmd=function(a){cc.Sprite.CanvasRenderCmd.call(this,a),cc.LabelTTF.RenderCmd.call(this)},cc.LabelTTF.CanvasRenderCmd.prototype=Object.create(cc.Sprite.CanvasRenderCmd.prototype),cc.inject(cc.LabelTTF.RenderCmd.prototype,cc.LabelTTF.CanvasRenderCmd.prototype);var a=cc.LabelTTF.CanvasRenderCmd.prototype;a.constructor=cc.LabelTTF.CanvasRenderCmd,a._measureConfig=function(){},a._measure=function(a){var b=cc._renderContext.getContext();return b.font=this._fontStyleStr,b.measureText(a).width},a._updateTexture=function(){this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.textDirty^this._dirtyFlag;var a=this._node,b=a._contentSize;this._updateTTF();var c=b.width,d=b.height;return 0===a._string.length?(a.setTextureRect(cc.rect(0,0,1,b.height)),!0):(this._saveStatus(),a.setTextureRect(cc.rect(0,0,c,d)),!0)},a.rendering=function(a){var b=cc.view.getScaleX(),c=cc.view.getScaleY(),d=a||cc._renderContext,e=d.getContext();if(e){var f=this._node;if(d.computeRealOffsetY(),!(this._status.length<=0)){var g=this._renderingIndex>=this._status.length?this._renderingIndex-this._status.length:this._renderingIndex,h=this._status[g];this._renderingIndex=g+1;var i=f._rect.height,j=f._offsetPosition.x,k=-f._offsetPosition.y-i,l=this._displayedOpacity/255;d.setTransform(this._worldTransform,b,c),d.setCompositeOperation(this._blendFuncStr),d.setGlobalAlpha(l),d.save(),f._flippedX&&(j=-j-f._rect.width,e.scale(-1,1)),f._flippedY&&(k=f._offsetPosition.y,e.scale(1,-1));for(var m=h.xOffset+h.contextTransform.x+j*b,n=[],o=this._strings.length,p=0;o>p;p++)n.push(h.OffsetYArray[p]+h.contextTransform.y+k*c);this.drawLabels(e,m,n),d.restore()}}}}();var cc=cc||{};cc._tmp=cc._tmp||{},cc.associateWithNative=function(a,b){},cc.KEY={none:0,back:6,menu:18,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,select:41,insert:45,Delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,num0:96,num1:97,num2:98,num3:99,num4:100,num5:101,num6:102,num7:103,num8:104,num9:105,"*":106,"+":107,"-":109,numdel:110,"/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,";":186,semicolon:186,equal:187,"=":187,",":188,comma:188,dash:189,".":190,period:190,forwardslash:191,grave:192,"[":219,openbracket:219,backslash:220,"]":221,closebracket:221,quote:222,dpadLeft:1e3,dpadRight:1001,dpadUp:1003,dpadDown:1004,dpadCenter:1005},cc.FMT_JPG=0,cc.FMT_PNG=1,cc.FMT_TIFF=2,cc.FMT_RAWDATA=3,cc.FMT_WEBP=4,cc.FMT_UNKNOWN=5,cc.getImageFormatByData=function(a){return a.length>8&&137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]&&13===a[4]&&10===a[5]&&26===a[6]&&10===a[7]?cc.FMT_PNG:a.length>2&&(73===a[0]&&73===a[1]||77===a[0]&&77===a[1]||255===a[0]&&216===a[1])?cc.FMT_TIFF:cc.FMT_UNKNOWN},cc.inherits=function(a,b){function c(){}c.prototype=b.prototype,a.superClass_=b.prototype,a.prototype=new c,a.prototype.constructor=a},cc.base=function(a,b,c){var d=arguments.callee.caller;if(d.superClass_)return ret=d.superClass_.constructor.apply(a,Array.prototype.slice.call(arguments,1)),ret;for(var e=Array.prototype.slice.call(arguments,2),f=!1,g=a.constructor;g;g=g.superClass_&&g.superClass_.constructor)if(g.prototype[b]===d)f=!0;else if(f)return g.prototype[b].apply(a,e);if(a[b]===d)return a.constructor.prototype[b].apply(a,e);throw Error("cc.base called from a method of one name to a method of a different name")},cc.rendererCanvas={childrenOrderDirty:!0,_transformNodePool:[],_renderCmds:[],_isCacheToCanvasOn:!1,_cacheToCanvasCmds:{},_cacheInstanceIds:[],_currentID:0,_clearColor:cc.color(),_clearFillStyle:"rgb(0, 0, 0)",getRenderCmd:function(a){return a._createRenderCmd()},rendering:function(a){var b,c,d=this._renderCmds,e=cc.view.getScaleX(),f=cc.view.getScaleY(),g=a||cc._renderContext;for(g.computeRealOffsetY(),b=0,c=d.length;c>b;b++)d[b].rendering(g,e,f)},_renderingToCacheCanvas:function(a,b,c,d){a||cc.log("The context of RenderTexture is invalid."),c=cc.isUndefined(c)?1:c,d=cc.isUndefined(d)?1:d,b=b||this._currentID;var e,f,g=this._cacheToCanvasCmds[b];for(a.computeRealOffsetY(),e=0,f=g.length;f>e;e++)g[e].rendering(a,c,d);g.length=0;var h=this._cacheInstanceIds;delete this._cacheToCanvasCmds[b],cc.arrayRemoveObject(h,b),0===h.length?this._isCacheToCanvasOn=!1:this._currentID=h[h.length-1]},_turnToCacheMode:function(a){this._isCacheToCanvasOn=!0,a=a||0,this._cacheToCanvasCmds[a]=[],-1===this._cacheInstanceIds.indexOf(a)&&this._cacheInstanceIds.push(a),this._currentID=a},_turnToNormalMode:function(){this._isCacheToCanvasOn=!1},resetFlag:function(){this.childrenOrderDirty=!1,this._transformNodePool.length=0},transform:function(){var a=this._transformNodePool;a.sort(this._sortNodeByLevelAsc);for(var b=0,c=a.length;c>b;b++)0!==a[b]._dirtyFlag&&a[b].updateStatus();a.length=0},transformDirty:function(){return this._transformNodePool.length>0},_sortNodeByLevelAsc:function(a,b){return a._curLevel-b._curLevel},pushDirtyNode:function(a){this._transformNodePool.push(a)},clear:function(){var a=cc._canvas,b=cc._renderContext,c=b.getContext();c.setTransform(1,0,0,1,0,0),c.clearRect(0,0,a.width,a.height),(0!==this._clearColor.r||0!==this._clearColor.g||0!==this._clearColor.b)&&(b.setFillStyle(this._clearFillStyle),b.setGlobalAlpha(this._clearColor.a),c.fillRect(0,0,a.width,a.height))},clearRenderCommands:function(){this._renderCmds.length=0,this._cacheInstanceIds.length=0,this._isCacheToCanvasOn=!1},pushRenderCommand:function(a){if(a._needDraw)if(this._isCacheToCanvasOn){var b=this._currentID,c=this._cacheToCanvasCmds,d=c[b];-1===d.indexOf(a)&&d.push(a)}else-1===this._renderCmds.indexOf(a)&&this._renderCmds.push(a)}},function(){cc.CanvasContextWrapper=function(a){this._context=a,this._saveCount=0,this._currentAlpha=a.globalAlpha,this._currentCompositeOperation=a.globalCompositeOperation,this._currentFillStyle=a.fillStyle,this._currentStrokeStyle=a.strokeStyle,this._offsetX=0,this._offsetY=0,this._realOffsetY=this.height,this._armatureMode=0};var a=cc.CanvasContextWrapper.prototype;a.resetCache=function(){var a=this._context;this._currentAlpha=a.globalAlpha,this._currentCompositeOperation=a.globalCompositeOperation,this._currentFillStyle=a.fillStyle,this._currentStrokeStyle=a.strokeStyle,this._realOffsetY=this._context.canvas.height+this._offsetY},a.setOffset=function(a,b){this._offsetX=a,this._offsetY=b,this._realOffsetY=this._context.canvas.height+this._offsetY},a.computeRealOffsetY=function(){this._realOffsetY=this._context.canvas.height+this._offsetY},a.setViewScale=function(a,b){this._scaleX=a,this._scaleY=b},a.getContext=function(){return this._context},a.save=function(){this._context.save(),this._saveCount++},a.restore=function(){this._context.restore(),this._saveCount--},a.setGlobalAlpha=function(a){this._saveCount>0?this._context.globalAlpha=a:this._currentAlpha!==a&&(this._currentAlpha=a,this._context.globalAlpha=a)},a.setCompositeOperation=function(a){this._saveCount>0?this._context.globalCompositeOperation=a:this._currentCompositeOperation!==a&&(this._currentCompositeOperation=a,this._context.globalCompositeOperation=a)},a.setFillStyle=function(a){this._saveCount>0?this._context.fillStyle=a:this._currentFillStyle!==a&&(this._currentFillStyle=a,this._context.fillStyle=a); +},a.setStrokeStyle=function(a){this._saveCount>0?this._context.strokeStyle=a:this._currentStrokeStyle!==a&&(this._currentStrokeStyle=a,this._context.strokeStyle=a)},a.setTransform=function(a,b,c){this._armatureMode>0?(this.restore(),this.save(),this._context.transform(a.a,-a.b,-a.c,a.d,a.tx*b,-(a.ty*c))):this._context.setTransform(a.a,-a.b,-a.c,a.d,this._offsetX+a.tx*b,this._realOffsetY-a.ty*c)},a._switchToArmatureMode=function(a,b,c,d){a?(this._armatureMode++,this._context.setTransform(b.a,b.c,b.b,b.d,this._offsetX+b.tx*c,this._realOffsetY-b.ty*d),this.save()):(this._armatureMode--,this.restore())}}(),cc.profiler=function(){var a=_showFPS=!1,b=_frameRate=_lastSPF=_accumDt=0,c=_afterVisitListener=_FPSLabel=_SPFLabel=_drawsLabel=null,d=.6,e=10,f=[0,10,20,30],g=[0,0,0,0],h=3,j=0,k=0,l=function(){var a=0,b=cc.winSize.width,c=cc.winSize.height,d=cc.DIRECTOR_STATS_POSITION;a=b>c?0|c/320*24:0|b/320*24,_FPSLabel=new cc.LabelTTF("000.0","Arial",a),_SPFLabel=new cc.LabelTTF("0.000","Arial",a),_drawsLabel=new cc.LabelTTF("0000","Arial",a),_drawsLabel.setPosition(_drawsLabel.width/2+d.x,5*_drawsLabel.height/2+d.y),_SPFLabel.setPosition(_SPFLabel.width/2+d.x,3*_SPFLabel.height/2+d.y),_FPSLabel.setPosition(_FPSLabel.width/2+d.x,_FPSLabel.height/2+d.y)},m=function(a){var b,c=i=f.length-1,l=0;for(j++,k+=a;i>=0;i--)if(a>=f[i]){g[i]++;break}if(j>=e){for(l=k/e,i=c;i>0;i--)if(b=g[i]/e,b>=d&&l>=f[i]){i!=h&&(h=i,p.onFrameRateChange&&p.onFrameRateChange(l.toFixed(2)));break}for(_changeCount=0,j=0,k=0,i=c;i>0;i--)g[i]=0}},n=function(){_lastSPF=cc.director.getSecondsPerFrame(),b++,_accumDt+=cc.director.getDeltaTime(),_accumDt>cc.DIRECTOR_FPS_INTERVAL&&(_frameRate=b/_accumDt,b=0,_accumDt=0,p.onFrameRateChange&&m(_frameRate),_showFPS&&(_SPFLabel.string=_lastSPF.toFixed(3),_FPSLabel.string=_frameRate.toFixed(1),_drawsLabel.string=(0|cc.g_NumberOfDraws).toString())),_showFPS&&(_FPSLabel.visit(),_SPFLabel.visit(),_drawsLabel.visit())},o=function(){_FPSLabel._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),_SPFLabel._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty),_drawsLabel._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},p={onFrameRateChange:null,getSecondsPerFrame:function(){return _lastSPF},getFrameRate:function(){return _frameRate},setProfileDuration:function(a){!isNaN(a)&&a>0&&(e=a/cc.DIRECTOR_FPS_INTERVAL)},resumeProfiling:function(){cc.eventManager.addListener(_afterVisitListener,1)},stopProfiling:function(){cc.eventManager.removeListener(_afterVisitListener)},isShowingStats:function(){return _showFPS},showStats:function(){a||this.init(),cc.LabelTTF&&!_FPSLabel&&l(),_FPSLabel&&(_showFPS=!0)},hideStats:function(){_showFPS=!1},init:function(){a||(_afterVisitListener=cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_VISIT,n),c=cc.eventManager.addCustomListener(cc.Director.EVENT_PROJECTION_CHANGED,o),a=!0)}};return p}();cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.DirectorDelegate=cc.Class.extend({updateProjection:function(){}});var a=cc.Director.prototype,b=function(a){if(a&&a._renderCmd){a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty);var c,d=a._children;for(c=0;c-1},getValue:function(a,b){this._inited||this._init();var c=this._valueDict;return c[a]?c[a]:b},setValue:function(a,b){this._valueDict[a]=b},dumpInfo:function(){0===cc.ENABLE_GL_STATE_CACHE&&(cc.log(""),cc.log(cc._LogInfos.configuration_dumpInfo),cc.log(""))},gatherGPUInfo:function(){if(cc._renderType!==cc.game.RENDER_TYPE_CANVAS){this._inited||this._init();var a=cc._renderContext,b=this._valueDict;b["gl.vendor"]=a.getParameter(a.VENDOR),b["gl.renderer"]=a.getParameter(a.RENDERER),b["gl.version"]=a.getParameter(a.VERSION),this._GlExtensions="";for(var c=a.getSupportedExtensions(),d=0;db;b++)d[b].rendering(e)},_turnToCacheMode:function(a){this._isCacheToBufferOn=!0,a=a||0,this._cacheToBufferCmds[a]=[],this._cacheInstanceIds.push(a),this._currentID=a},_turnToNormalMode:function(){this._isCacheToBufferOn=!1},_renderingToBuffer:function(a){a=a||this._currentID;var b,c,d=this._cacheToBufferCmds[a],e=cc._renderContext,f=this._cacheInstanceIds;for(b=0,c=d.length;c>b;b++)d[b].rendering(e);d.length=0,delete this._cacheToBufferCmds[a],cc.arrayRemoveObject(f,a),0===f.length?this._isCacheToBufferOn=!1:this._currentID=f[f.length-1]},resetFlag:function(){this.childrenOrderDirty=!1,this._transformNodePool.length=0},transform:function(){var a=this._transformNodePool;a.sort(this._sortNodeByLevelAsc);for(var b=0,c=a.length;c>b;b++)a[b].updateStatus();a.length=0},transformDirty:function(){return this._transformNodePool.length>0},_sortNodeByLevelAsc:function(a,b){return a._curLevel-b._curLevel},pushDirtyNode:function(a){this._transformNodePool.push(a)},clearRenderCommands:function(){this._renderCmds.length=0},clear:function(){var a=cc._renderContext;a.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a),a.clear(a.COLOR_BUFFER_BIT|a.DEPTH_BUFFER_BIT)},setDepthTest:function(a){var b=cc._renderContext;a?(b.clearDepth(1),b.enable(b.DEPTH_TEST),b.depthFunc(b.LEQUAL)):b.disable(b.DEPTH_TEST)},pushRenderCommand:function(a){if(a._needDraw)if(this._isCacheToBufferOn){var b=this._currentID,c=this._cacheToBufferCmds,d=c[b];-1===d.indexOf(a)&&d.push(a)}else-1===this._renderCmds.indexOf(a)&&this._renderCmds.push(a)}},function(){cc.Node.WebGLRenderCmd=function(a){cc.Node.RenderCmd.call(this,a);var b=new cc.math.Matrix4,c=b.mat;c[2]=c[3]=c[6]=c[7]=c[8]=c[9]=c[11]=c[14]=0,c[10]=c[15]=1,this._transform4x4=b,this._stackMatrix=new cc.math.Matrix4,this._shaderProgram=null,this._camera=null};var a=cc.Node.WebGLRenderCmd.prototype=Object.create(cc.Node.RenderCmd.prototype);a.constructor=cc.Node.WebGLRenderCmd,a._updateColor=function(){},a.visit=function(a){var b=this._node;if(b._visible){a=a||this.getParentRenderCmd(),b._parent&&b._parent._renderCmd&&(this._curLevel=b._parent._renderCmd._curLevel+1);var c=cc.current_stack;c.stack.push(c.top),this._syncStatus(a),c.top=this._stackMatrix,this.visitChildren(),c.top=c.stack.pop()}},a.transform=function(a,b){var c=this._transform4x4,d=this._stackMatrix,e=this._node;a=a||this.getParentRenderCmd();var f=a?a._stackMatrix:cc.current_stack.top,g=this.getNodeToParentTransform();this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.transformDirty^this._dirtyFlag;var h=c.mat;if(h[0]=g.a,h[4]=g.c,h[12]=g.tx,h[1]=g.b,h[5]=g.d,h[13]=g.ty,h[14]=e._vertexZ,cc.kmMat4Multiply(d,f,c),null!==e._camera&&(null===e.grid||!e.grid.isActive())){var i=this._anchorPointInPoints.x,j=this._anchorPointInPoints.y,k=0!==i||0!==j;if(k){cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(i=0|i,j=0|j);var l=cc.math.Matrix4.createByTranslation(i,j,0,c);d.multiply(l),e._camera._locateForRenderer(d),l=cc.math.Matrix4.createByTranslation(-i,-j,0,l),d.multiply(l),c.identity()}else e._camera._locateForRenderer(d)}if(b&&e._children&&0!==e._children.length){var m,n,o=e._children;for(m=0,n=o.length;n>m;m++)o[m]._renderCmd.transform(this,b)}},a.setShaderProgram=function(a){this._shaderProgram=a},a.getShaderProgram=function(){return this._shaderProgram}}(),function(){cc.Layer.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a)};var a=cc.Layer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Layer.WebGLRenderCmd,a.bake=function(){},a.unbake=function(){},a._bakeForAddChild=function(){}}(),function(){cc.LayerColor.WebGLRenderCmd=function(a){cc.Layer.WebGLRenderCmd.call(this,a),this._needDraw=!0;var b=this;b._squareVerticesAB=new ArrayBuffer(32),b._squareColorsAB=new ArrayBuffer(16);var c=b._squareVerticesAB,d=b._squareColorsAB,e=cc.Vertex2F.BYTES_PER_ELEMENT,f=cc.Color.BYTES_PER_ELEMENT;b._squareVertices=[new cc.Vertex2F(0,0,c,0),new cc.Vertex2F(0,0,c,e),new cc.Vertex2F(0,0,c,2*e),new cc.Vertex2F(0,0,c,3*e)],b._squareColors=[cc.color(0,0,0,255,d,0),cc.color(0,0,0,255,d,f),cc.color(0,0,0,255,d,2*f),cc.color(0,0,0,255,d,3*f)],b._verticesFloat32Buffer=cc._renderContext.createBuffer(),b._colorsUint8Buffer=cc._renderContext.createBuffer()};var a=cc.LayerColor.WebGLRenderCmd.prototype=Object.create(cc.Layer.WebGLRenderCmd.prototype);a.constructor=cc.LayerColor.WebGLRenderCmd,a.rendering=function(a){var b=a||cc._renderContext,c=this._node;this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR),cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst),b.bindBuffer(b.ARRAY_BUFFER,this._verticesFloat32Buffer),b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,0,0),b.bindBuffer(b.ARRAY_BUFFER,this._colorsUint8Buffer),b.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,b.UNSIGNED_BYTE,!0,0,0),b.drawArrays(b.TRIANGLE_STRIP,0,this._squareVertices.length)},a._updateSquareVertices=function(a,b){var c=this._squareVertices;void 0===b?(c[1].x=a.width,c[2].y=a.height,c[3].x=a.width,c[3].y=a.height):(c[1].x=a,c[2].y=b,c[3].x=a,c[3].y=b),this._bindLayerVerticesBufferData()},a._updateSquareVerticesWidth=function(a){var b=this._squareVertices;b[1].x=a,b[3].x=a,this._bindLayerVerticesBufferData()},a._updateSquareVerticesHeight=function(a){var b=this._squareVertices;b[2].y=a,b[3].y=a,this._bindLayerVerticesBufferData()},a._updateColor=function(){for(var a=this._displayedColor,b=this._displayedOpacity,c=this._squareColors,d=0;4>d;d++)c[d].r=a.r,c[d].g=a.g,c[d].b=a.b,c[d].a=b;this._bindLayerColorsBufferData()},a._bindLayerVerticesBufferData=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._verticesFloat32Buffer),a.bufferData(a.ARRAY_BUFFER,this._squareVerticesAB,a.STATIC_DRAW)},a._bindLayerColorsBufferData=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._colorsUint8Buffer),a.bufferData(a.ARRAY_BUFFER,this._squareColorsAB,a.STATIC_DRAW)},a.updateBlendFunc=function(a){}}(),function(){cc.LayerGradient.WebGLRenderCmd=function(a){cc.LayerColor.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._clipRect=new cc.Rect,this._clippingRectDirty=!1};var a=cc.LayerGradient.WebGLRenderCmd.prototype=Object.create(cc.LayerColor.WebGLRenderCmd.prototype);cc.inject(cc.LayerGradient.RenderCmd,a),a.constructor=cc.LayerGradient.WebGLRenderCmd,a._syncStatus=function(a){var b=cc.Node._dirtyFlags,c=this._dirtyFlag,d=a?a._node:null;d&&d._cascadeColorEnabled&&a._dirtyFlag&b.colorDirty&&(c|=b.colorDirty),d&&d._cascadeOpacityEnabled&&a._dirtyFlag&b.opacityDirty&&(c|=b.opacityDirty),a&&a._dirtyFlag&b.transformDirty&&(c|=b.transformDirty);var e=c&b.colorDirty,f=c&b.opacityDirty;this._dirtyFlag=c,e&&this._syncDisplayColor(),f&&this._syncDisplayOpacity(),this.transform(a),(e||f||c&b.gradientDirty)&&this._updateColor()},a._updateColor=function(){this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.gradientDirty^this._dirtyFlag;var a=this._node,b=a._colorStops;if(b&&!(b.length<2)){this._clippingRectDirty=!0;var c,d=b.length,e=2*d,f=a._contentSize;this._squareVerticesAB=new ArrayBuffer(8*e),this._squareColorsAB=new ArrayBuffer(4*e);var g=this._squareVertices,h=this._squareColors;g.length=0,h.length=0;var i=this._squareVerticesAB,j=this._squareColorsAB,k=cc.Vertex2F.BYTES_PER_ELEMENT,l=cc.Color.BYTES_PER_ELEMENT;for(c=0;e>c;c++)g.push(new cc.Vertex2F(0,0,i,k*c)),h.push(cc.color(0,0,0,255,j,l*c));var m=Math.PI+cc.pAngleSigned(cc.p(0,-1),a._alongVector),n=cc.p(f.width/2,f.height/2),o=Math.round(cc.radiansToDegrees(m)),p=cc.affineTransformMake(1,0,0,1,n.x,n.y);p=cc.affineTransformRotate(p,m);var q,r;90>o?(q=cc.p(-n.x,n.y),r=cc.p(n.x,n.y)):180>o?(q=cc.p(n.x,n.y),r=cc.p(n.x,-n.y)):270>o?(q=cc.p(n.x,-n.y),r=cc.p(-n.x,-n.y)):(q=cc.p(-n.x,-n.y),r=cc.p(-n.x,n.y));var s=Math.sin(m),t=Math.cos(m),u=Math.abs((q.x*t-q.y*s)/n.x),v=Math.abs((r.x*s+r.y*t)/n.y);for(p=cc.affineTransformScale(p,u,v),c=0;d>c;c++){var w=b[c],x=w.p*f.height,y=cc.pointApplyAffineTransform(-n.x,x-n.y,p);g[2*c].x=y.x,g[2*c].y=y.y;var z=cc.pointApplyAffineTransform(f.width-n.x,x-n.y,p);g[2*c+1].x=z.x,g[2*c+1].y=z.y}var A=this._displayedOpacity/255;for(c=0;d>c;c++){var B=b[c].color,C=h[2*c],D=h[2*c+1];C.r=B.r,C.g=B.g,C.b=B.b,C.a=B.a*A,D.r=B.r,D.g=B.g,D.b=B.b,D.a=B.a*A}this._bindLayerVerticesBufferData(),this._bindLayerColorsBufferData()}},a.rendering=function(a){var b=a||cc._renderContext,c=this._node,d=this._getClippingRect();b.enable(b.SCISSOR_TEST),cc.view.setScissorInPoints(d.x,d.y,d.width,d.height),this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR),cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst),b.bindBuffer(b.ARRAY_BUFFER,this._verticesFloat32Buffer),b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,0,0),b.bindBuffer(b.ARRAY_BUFFER,this._colorsUint8Buffer),b.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,b.UNSIGNED_BYTE,!0,0,0),b.drawArrays(b.TRIANGLE_STRIP,0,this._squareVertices.length),b.disable(b.SCISSOR_TEST)},a._getClippingRect=function(){if(this._clippingRectDirty){var a=this._node,b=cc.rect(0,0,a._contentSize.width,a._contentSize.height),c=a.getNodeToWorldTransform();this._clipRect=cc._rectApplyAffineTransformIn(b,c)}return this._clipRect}}(),function(){cc.Sprite.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._quad=new cc.V3F_C4B_T2F_Quad,this._quadWebBuffer=cc._renderContext.createBuffer(),this._quadDirty=!0,this._dirty=!1,this._recursiveDirty=!1};var a=cc.Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.Sprite.WebGLRenderCmd,a.updateBlendFunc=function(a){},a.setDirtyFlag=function(a){cc.Node.WebGLRenderCmd.prototype.setDirtyFlag.call(this,a),this._dirty=!0},a.setDirtyRecursively=function(a){this._recursiveDirty=a,this._dirty=a;for(var b,c=this._node._children,d=c?c.length:0,e=0;d>e;e++)b=c[e],b instanceof cc.Sprite&&b._renderCmd.setDirtyRecursively(a)},a._setBatchNodeForAddChild=function(a){var b=this._node;if(b._batchNode){if(!(a instanceof cc.Sprite))return cc.log(cc._LogInfos.Sprite_addChild),!1;a.texture._webTextureObj!==b.textureAtlas.texture._webTextureObj&&cc.log(cc._LogInfos.Sprite_addChild_2),b._batchNode.appendChild(a),b._reorderChildDirty||b._setReorderChildDirtyRecursively()}return!0},a._handleTextureForRotatedTexture=function(a){return a},a.isFrameDisplayed=function(a){var b=this._node;return cc.rectEqualToRect(a.getRect(),b._rect)&&a.getTexture().getName()===b._texture.getName()&&cc.pointEqualToPoint(a.getOffset(),b._unflippedOffsetPositionFromCenter)},a._init=function(){var a={r:255,g:255,b:255,a:255},b=this._quad;b.bl.colors=a,b.br.colors=a,b.tl.colors=a,b.tr.colors=a,this._quadDirty=!0},a._resetForBatchNode=function(){var a=this._node,b=a._offsetPosition.x,c=a._offsetPosition.y,d=b+a._rect.width,e=c+a._rect.height,f=this._quad;f.bl.vertices={x:b,y:c,z:0},f.br.vertices={x:d,y:c,z:0},f.tl.vertices={x:b,y:e,z:0},f.tr.vertices={x:d,y:e,z:0},this._quadDirty=!0},a.getQuad=function(){return this._quad},a._updateForSetSpriteFrame=function(){},a._spriteFrameLoadedCallback=function(a){this.setTextureRect(a.getRect(),a.isRotated(),a.getOriginalSize()),this.dispatchEvent("load")},a._textureLoadedCallback=function(a){var b=this._renderCmd;if(!this._textureLoaded){this._textureLoaded=!0;var c=this._rect;c?cc._rectEqualToZero(c)&&(c.width=a.width,c.height=a.height):c=cc.rect(0,0,a.width,a.height),this.texture=a,this.setTextureRect(c,this._rectRotated),this.setBatchNode(this._batchNode),b._quadDirty=!0,this.dispatchEvent("load")}},a._setTextureCoords=function(a,b){void 0===b&&(b=!0),b&&(a=cc.rectPointsToPixels(a));var c=this._node,d=c._batchNode?c.textureAtlas.texture:c._texture;if(d){var e,f,g,h,i,j=d.pixelsWidth,k=d.pixelsHeight,l=this._quad;c._rectRotated?(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(e=(2*a.x+1)/(2*j),f=e+(2*a.height-2)/(2*j),g=(2*a.y+1)/(2*k),h=g+(2*a.width-2)/(2*k)):(e=a.x/j,f=(a.x+a.height)/j,g=a.y/k,h=(a.y+a.width)/k),c._flippedX&&(i=g,g=h,h=i),c._flippedY&&(i=e,e=f,f=i),l.bl.texCoords.u=e,l.bl.texCoords.v=g,l.br.texCoords.u=e,l.br.texCoords.v=h,l.tl.texCoords.u=f,l.tl.texCoords.v=g,l.tr.texCoords.u=f,l.tr.texCoords.v=h):(cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(e=(2*a.x+1)/(2*j),f=e+(2*a.width-2)/(2*j),g=(2*a.y+1)/(2*k),h=g+(2*a.height-2)/(2*k)):(e=a.x/j,f=(a.x+a.width)/j,g=a.y/k,h=(a.y+a.height)/k),c._flippedX&&(i=e,e=f,f=i),c._flippedY&&(i=g,g=h,h=i),l.bl.texCoords.u=e,l.bl.texCoords.v=h,l.br.texCoords.u=f,l.br.texCoords.v=h,l.tl.texCoords.u=e,l.tl.texCoords.v=g,l.tr.texCoords.u=f,l.tr.texCoords.v=g),this._quadDirty=!0}},a.transform=function(a,b){cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,b),this._dirty=!0},a._setColorDirty=function(){},a._updateColor=function(){var a=this._displayedColor,b=this._displayedOpacity,c=this._node,d={r:a.r,g:a.g,b:a.b,a:b};c._opacityModifyRGB&&(d.r*=b/255,d.g*=b/255,d.b*=b/255);var e=this._quad;e.bl.colors=d,e.br.colors=d,e.tl.colors=d,e.tr.colors=d,c._batchNode&&(c.atlasIndex!==cc.Sprite.INDEX_NOT_INITIALIZED?c.textureAtlas.updateQuad(e,c.atlasIndex):this._dirty=!0),this._quadDirty=!0},a._updateBlendFunc=function(){if(this._batchNode)return void cc.log(cc._LogInfos.Sprite__updateBlendFunc);var a=this._node,b=a._blendFunc;a._texture&&a._texture.hasPremultipliedAlpha()?(b.src===cc.SRC_ALPHA&&b.dst===cc.BLEND_DST&&(b.src=cc.ONE),a.opacityModifyRGB=!0):(b.src===cc.ONE&&b.dst===cc.BLEND_DST&&(b.src=cc.SRC_ALPHA),a.opacityModifyRGB=!1)},a._setTexture=function(a){var b=this._node;if(b._batchNode){if(b._batchNode.texture!==a)return void cc.log(cc._LogInfos.Sprite_setTexture)}else b._texture!==a&&(b._textureLoaded=a?a._textureLoaded:!1,b._texture=a,this._updateBlendFunc());a?this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR):this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_COLOR)},a.updateTransform=function(){var a=this,b=this._node;if(this._dirty){var c=a._quad,d=b._parent;if(!b._visible||d&&d!==b._batchNode&&d._shouldBeHidden)c.br.vertices=c.tl.vertices=c.tr.vertices=c.bl.vertices={x:0,y:0,z:0},b._shouldBeHidden=!0;else{b._shouldBeHidden=!1,0!==this._dirtyFlag&&(this.updateStatus(),this._dirtyFlag=0),d&&d!==b._batchNode?b._transformToBatch=cc.affineTransformConcat(a.getNodeToParentTransform(),d._transformToBatch):b._transformToBatch=a.getNodeToParentTransform();var e=b._transformToBatch,f=b._rect,g=b._offsetPosition.x,h=b._offsetPosition.y,i=g+f.width,j=h+f.height,k=e.tx,l=e.ty,m=e.a,n=e.b,o=e.d,p=-e.c,q=g*m-h*p+k,r=g*n+h*o+l,s=i*m-h*p+k,t=i*n+h*o+l,u=i*m-j*p+k,v=i*n+j*o+l,w=g*m-j*p+k,x=g*n+j*o+l,y=b._vertexZ;cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(q=0|q,r=0|r,s=0|s,t=0|t,u=0|u,v=0|v,w=0|w,x=0|x),c.bl.vertices={x:q,y:r,z:y},c.br.vertices={x:s,y:t,z:y},c.tl.vertices={x:w,y:x,z:y},c.tr.vertices={x:u,y:v,z:y}}b.textureAtlas.updateQuad(c,b.atlasIndex),b._recursiveDirty=!1,this._dirty=!1}b._hasChildren&&b._arrayMakeObjectsPerformSelector(b._children,cc.Node._stateCallbackType.updateTransform)},a._checkTextureBoundary=function(a,b,c){if(a&&a.url){var d,e;c?(d=b.x+b.height,e=b.y+b.width):(d=b.x+b.width,e=b.y+b.height),d>a.width&&cc.error(cc._LogInfos.RectWidth,a.url),e>a.height&&cc.error(cc._LogInfos.RectHeight,a.url)}},a.rendering=function(a){var b=this._node,c=b._texture;if((!c||c._textureLoaded)&&0!==this._displayedOpacity){var d=a||cc._renderContext;if(c?c._textureLoaded&&(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst),cc.glBindTexture2DN(0,c),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),d.bindBuffer(d.ARRAY_BUFFER,this._quadWebBuffer),this._quadDirty&&(d.bufferData(d.ARRAY_BUFFER,this._quad.arrayBuffer,d.DYNAMIC_DRAW),this._quadDirty=!1),d.vertexAttribPointer(0,3,d.FLOAT,!1,24,0),d.vertexAttribPointer(1,4,d.UNSIGNED_BYTE,!0,24,12),d.vertexAttribPointer(2,2,d.FLOAT,!1,24,16),d.drawArrays(d.TRIANGLE_STRIP,0,4)):(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst),cc.glBindTexture2D(null),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_COLOR),d.bindBuffer(d.ARRAY_BUFFER,this._quadWebBuffer),this._quadDirty&&(d.bufferData(d.ARRAY_BUFFER,this._quad.arrayBuffer,d.STATIC_DRAW),this._quadDirty=!1),d.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,d.FLOAT,!1,24,0),d.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,d.UNSIGNED_BYTE,!0,24,12),d.drawArrays(d.TRIANGLE_STRIP,0,4)),cc.g_NumberOfDraws++,0!==cc.SPRITE_DEBUG_DRAW||b._showNode){if(cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW),cc.current_stack.stack.push(cc.current_stack.top),cc.current_stack.top=this._stackMatrix,1===cc.SPRITE_DEBUG_DRAW||b._showNode){var e=this._quad,f=[cc.p(e.tl.vertices.x,e.tl.vertices.y),cc.p(e.bl.vertices.x,e.bl.vertices.y),cc.p(e.br.vertices.x,e.br.vertices.y),cc.p(e.tr.vertices.x,e.tr.vertices.y)];cc._drawingUtil.drawPoly(f,4,!0)}else if(2===cc.SPRITE_DEBUG_DRAW){var g=b.getTextureRect(),h=b.getOffsetPosition(),i=[cc.p(h.x,h.y),cc.p(h.x+g.width,h.y),cc.p(h.x+g.width,h.y+g.height),cc.p(h.x,h.y+g.height)];cc._drawingUtil.drawPoly(i,4,!0)}cc.current_stack.top=cc.current_stack.stack.pop()}}}}(),function(){cc.LabelTTF.WebGLRenderCmd=function(a){cc.Sprite.WebGLRenderCmd.call(this,a),cc.LabelTTF.CacheRenderCmd.call(this),this.setShaderProgram(cc.shaderCache.programForKey(cc.LabelTTF._SHADER_PROGRAM))};var a=cc.LabelTTF.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);cc.inject(cc.LabelTTF.CacheRenderCmd.prototype,a),a.constructor=cc.LabelTTF.WebGLRenderCmd,a._updateColor=function(){this._updateTexture(),cc.Sprite.WebGLRenderCmd.prototype._updateColor.call(this)}}(),cc.DrawingPrimitiveWebGL=cc.Class.extend({_renderContext:null,_initialized:!1,_shader:null,_colorLocation:-1,_colorArray:null,_pointSizeLocation:-1,_pointSize:-1,ctor:function(a){if(null==a&&(a=cc._renderContext),!a instanceof WebGLRenderingContext)throw new Error("Can't initialise DrawingPrimitiveWebGL. context need is WebGLRenderingContext");this._renderContext=a,this._colorArray=new Float32Array([1,1,1,1])},lazy_init:function(){var a=this;a._initialized||(a._shader=cc.shaderCache.programForKey(cc.SHADER_POSITION_UCOLOR),a._colorLocation=a._renderContext.getUniformLocation(a._shader.getProgram(),"u_color"),a._pointSizeLocation=a._renderContext.getUniformLocation(a._shader.getProgram(),"u_pointSize"),a._initialized=!0)},drawInit:function(){this._initialized=!1},drawPoint:function(a){this.lazy_init();var b=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION),b.uniform4fv(this._colorLocation,this._colorArray),this._shader.setUniformLocationWith1f(this._pointSizeLocation,this._pointSize);var c=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,c),b.bufferData(b.ARRAY_BUFFER,new Float32Array([a.x,a.y]),b.STATIC_DRAW),b.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,b.FLOAT,!1,0,0),b.drawArrays(b.POINTS,0,1),b.deleteBuffer(c),cc.incrementGLDraws(1)},drawPoints:function(a,b){if(a&&0!==a.length){this.lazy_init();var c=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION),c.uniform4fv(this._colorLocation,this._colorArray),this._shader.setUniformLocationWith1f(this._pointSizeLocation,this._pointSize);var d=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,d),c.bufferData(c.ARRAY_BUFFER,this._pointsToTypeArray(a),c.STATIC_DRAW),c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,c.FLOAT,!1,0,0),c.drawArrays(c.POINTS,0,a.length),c.deleteBuffer(d),cc.incrementGLDraws(1)}},_pointsToTypeArray:function(a){for(var b=new Float32Array(2*a.length),c=0;c=i;i++){var j=i*g,k=b*Math.cos(j+c)+a.x,l=b*Math.sin(j+c)+a.y;h[2*i]=k,h[2*i+1]=l}h[2*(d+1)]=a.x,h[2*(d+1)+1]=a.y;var m=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION),m.uniform4fv(this._colorLocation,this._colorArray);var n=m.createBuffer();m.bindBuffer(m.ARRAY_BUFFER,n),m.bufferData(m.ARRAY_BUFFER,h,m.STATIC_DRAW),m.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,m.FLOAT,!1,0,0),m.drawArrays(m.LINE_STRIP,0,d+f),m.deleteBuffer(n),cc.incrementGLDraws(1)}},drawQuadBezier:function(a,b,c,d){this.lazy_init();for(var e=new Float32Array(2*(d+1)),f=0,g=0;d>g;g++)e[2*g]=Math.pow(1-f,2)*a.x+2*(1-f)*f*b.x+f*f*c.x,e[2*g+1]=Math.pow(1-f,2)*a.y+2*(1-f)*f*b.y+f*f*c.y,f+=1/d;e[2*d]=c.x,e[2*d+1]=c.y;var h=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION),h.uniform4fv(this._colorLocation,this._colorArray);var i=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,i),h.bufferData(h.ARRAY_BUFFER,e,h.STATIC_DRAW),h.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,h.FLOAT,!1,0,0),h.drawArrays(h.LINE_STRIP,0,d+1),h.deleteBuffer(i),cc.incrementGLDraws(1)},drawCubicBezier:function(a,b,c,d,e){this.lazy_init();for(var f=new Float32Array(2*(e+1)),g=0,h=0;e>h;h++)f[2*h]=Math.pow(1-g,3)*a.x+3*Math.pow(1-g,2)*g*b.x+3*(1-g)*g*g*c.x+g*g*g*d.x,f[2*h+1]=Math.pow(1-g,3)*a.y+3*Math.pow(1-g,2)*g*b.y+3*(1-g)*g*g*c.y+g*g*g*d.y,g+=1/e;f[2*e]=d.x,f[2*e+1]=d.y;var i=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION),i.uniform4fv(this._colorLocation,this._colorArray);var j=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,j),i.bufferData(i.ARRAY_BUFFER,f,i.STATIC_DRAW),i.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,i.FLOAT,!1,0,0),i.drawArrays(i.LINE_STRIP,0,e+1),i.deleteBuffer(j),cc.incrementGLDraws(1)},drawCatmullRom:function(a,b){this.drawCardinalSpline(a,.5,b)},drawCardinalSpline:function(a,b,c){this.lazy_init();for(var d,e,f=new Float32Array(2*(c+1)),g=1/a.length,h=0;c+1>h;h++){var i=h/c;1===i?(d=a.length-1,e=1):(d=0|i/g,e=(i-g*d)/g);var j=cc.cardinalSplineAt(cc.getControlPointAt(a,d-1),cc.getControlPointAt(a,d),cc.getControlPointAt(a,d+1),cc.getControlPointAt(a,d+2),b,e);f[2*h]=j.x,f[2*h+1]=j.y}var k=this._renderContext;this._shader.use(),this._shader.setUniformForModelViewAndProjectionMatrixWithMat4(),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION),k.uniform4fv(this._colorLocation,this._colorArray);var l=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,l),k.bufferData(k.ARRAY_BUFFER,f,k.STATIC_DRAW),k.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,k.FLOAT,!1,0,0),k.drawArrays(k.LINE_STRIP,0,c+1),k.deleteBuffer(l),cc.incrementGLDraws(1)},setDrawColor:function(a,b,c,d){this._colorArray[0]=a/255,this._colorArray[1]=b/255,this._colorArray[2]=c/255,this._colorArray[3]=d/255},setPointSize:function(a){ +this._pointSize=a*cc.contentScaleFactor()},setLineWidth:function(a){this._renderContext.lineWidth&&this._renderContext.lineWidth(a)}});var _p=cc.inputManager;_p.setAccelerometerEnabled=function(a){var b=this;if(b._accelEnabled!==a){b._accelEnabled=a;var c=cc.director.getScheduler();b._accelEnabled?(b._accelCurTime=0,c.scheduleUpdate(b)):(b._accelCurTime=0,c.scheduleUpdate(b))}},_p.setAccelerometerInterval=function(a){this._accelInterval!==a&&(this._accelInterval=a)},_p._registerKeyboardEvent=function(){cc._canvas.addEventListener("keydown",function(a){cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode,!0)),a.stopPropagation(),a.preventDefault()},!1),cc._canvas.addEventListener("keyup",function(a){cc.eventManager.dispatchEvent(new cc.EventKeyboard(a.keyCode,!1)),a.stopPropagation(),a.preventDefault()},!1)},_p._registerAccelerometerEvent=function(){var a=window,b=this;b._acceleration=new cc.Acceleration,b._accelDeviceEvent=a.DeviceMotionEvent||a.DeviceOrientationEvent,cc.sys.browserType===cc.sys.BROWSER_TYPE_MOBILE_QQ&&(b._accelDeviceEvent=window.DeviceOrientationEvent);var c=b._accelDeviceEvent===a.DeviceMotionEvent?"devicemotion":"deviceorientation",d=navigator.userAgent;(/Android/.test(d)||/Adr/.test(d)&&cc.sys.browserType===cc.BROWSER_TYPE_UC)&&(b._minus=-1),a.addEventListener(c,b.didAccelerate.bind(b),!1)},_p.didAccelerate=function(a){var b=this,c=window;if(b._accelEnabled){var d,e,f,g=b._acceleration;if(b._accelDeviceEvent===window.DeviceMotionEvent){var h=a.accelerationIncludingGravity;d=b._accelMinus*h.x*.1,e=b._accelMinus*h.y*.1,f=.1*h.z}else d=a.gamma/90*.981,e=.981*-(a.beta/90),f=a.alpha/90*.981;cc.sys.os===cc.sys.OS_ANDROID?(g.x=-d,g.y=-e):(g.x=d,g.y=e),g.z=f,g.timestamp=a.timeStamp||Date.now();var i=g.x;c.orientation===cc.UIInterfaceOrientationLandscapeRight?(g.x=-g.y,g.y=i):c.orientation===cc.UIInterfaceOrientationLandscapeLeft?(g.x=g.y,g.y=-i):c.orientation===cc.UIInterfaceOrientationPortraitUpsideDown&&(g.x=-g.x,g.y=-g.y)}},delete _p,cc.vertexLineToPolygon=function(a,b,c,d,e){if(e+=d,!(1>=e)){b*=.5;for(var f,g=e-1,h=d;e>h;h++){f=2*h;var i,j=cc.p(a[2*h],a[2*h+1]);if(0===h)i=cc.pPerp(cc.pNormalize(cc.pSub(j,cc.p(a[2*(h+1)],a[2*(h+1)+1]))));else if(h===g)i=cc.pPerp(cc.pNormalize(cc.pSub(cc.p(a[2*(h-1)],a[2*(h-1)+1]),j)));else{var k=cc.p(a[2*(h-1)],a[2*(h-1)+1]),l=cc.p(a[2*(h+1)],a[2*(h+1)+1]),m=cc.pNormalize(cc.pSub(l,j)),n=cc.pNormalize(cc.pSub(k,j)),o=Math.acos(cc.pDot(m,n));i=oh;h++){f=2*h;var p=f+2,q=cc.vertex2(c[2*f],c[2*f+1]),r=cc.vertex2(c[2*(f+1)],c[2*(f+1)+1]),s=cc.vertex2(c[2*p],c[2*p]),t=cc.vertex2(c[2*(p+1)],c[2*(p+1)+1]),u=!cc.vertexLineIntersect(q.x,q.y,t.x,t.y,r.x,r.y,s.x,s.y);u.isSuccess||(u.value<0||u.value>1)&&(u.isSuccess=!0),u.isSuccess&&(c[2*p]=t.x,c[2*p+1]=t.y,c[2*(p+1)]=s.x,c[2*(p+1)+1]=s.y)}}},cc.vertexLineIntersect=function(a,b,c,d,e,f,g,h){var i,j,k,l;if(a===c&&b===d||e===g&&f===h)return{isSuccess:!1,value:0};if(c-=a,d-=b,e-=a,f-=b,g-=a,h-=b,i=Math.sqrt(c*c+d*d),j=c/i,k=d/i,l=e*j+f*k,f=f*j-e*k,e=l,l=g*j+h*k,h=h*j-g*k,g=l,f===h)return{isSuccess:!1,value:0};var m=(g+(e-g)*h/(h-f))/i;return{isSuccess:!0,value:m}},cc.vertexListIsClockwise=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b],e=a[(b+1)%c],f=a[(b+2)%c];if(cc.pCross(cc.pSub(e,d),cc.pSub(f,e))>0)return!1}return!0},cc.CGAffineToGL=function(a,b){b[2]=b[3]=b[6]=b[7]=b[8]=b[9]=b[11]=b[14]=0,b[10]=b[15]=1,b[0]=a.a,b[4]=a.c,b[12]=a.tx,b[1]=a.b,b[5]=a.d,b[13]=a.ty},cc.GLToCGAffine=function(a,b){b.a=a[0],b.c=a[4],b.tx=a[12],b.b=a[1],b.d=a[5],b.ty=a[13]},cc.EventAcceleration=cc.Event.extend({_acc:null,ctor:function(a){cc.Event.prototype.ctor.call(this,cc.Event.ACCELERATION),this._acc=a}}),cc.EventKeyboard=cc.Event.extend({_keyCode:0,_isPressed:!1,ctor:function(a,b){cc.Event.prototype.ctor.call(this,cc.Event.KEYBOARD),this._keyCode=a,this._isPressed=b}}),cc._EventListenerAcceleration=cc.EventListener.extend({_onAccelerationEvent:null,ctor:function(a){this._onAccelerationEvent=a;var b=this,c=function(a){b._onAccelerationEvent(a._acc,a)};cc.EventListener.prototype.ctor.call(this,cc.EventListener.ACCELERATION,cc._EventListenerAcceleration.LISTENER_ID,c)},checkAvailable:function(){return cc.assert(this._onAccelerationEvent,cc._LogInfos._EventListenerAcceleration_checkAvailable),!0},clone:function(){return new cc._EventListenerAcceleration(this._onAccelerationEvent)}}),cc._EventListenerAcceleration.LISTENER_ID="__cc_acceleration",cc._EventListenerAcceleration.create=function(a){return new cc._EventListenerAcceleration(a)},cc._EventListenerKeyboard=cc.EventListener.extend({onKeyPressed:null,onKeyReleased:null,ctor:function(){var a=this,b=function(b){b._isPressed?a.onKeyPressed&&a.onKeyPressed(b._keyCode,b):a.onKeyReleased&&a.onKeyReleased(b._keyCode,b)};cc.EventListener.prototype.ctor.call(this,cc.EventListener.KEYBOARD,cc._EventListenerKeyboard.LISTENER_ID,b)},clone:function(){var a=new cc._EventListenerKeyboard;return a.onKeyPressed=this.onKeyPressed,a.onKeyReleased=this.onKeyReleased,a},checkAvailable:function(){return null===this.onKeyPressed&&null===this.onKeyReleased?(cc.log(cc._LogInfos._EventListenerKeyboard_checkAvailable),!1):!0}}),cc._EventListenerKeyboard.LISTENER_ID="__cc_keyboard",cc._EventListenerKeyboard.create=function(){return new cc._EventListenerKeyboard},cc.AtlasNode=cc.Node.extend({textureAtlas:null,quadsToDraw:0,_itemsPerRow:0,_itemsPerColumn:0,_itemWidth:0,_itemHeight:0,_opacityModifyRGB:!1,_blendFunc:null,_ignoreContentScaleFactor:!1,_className:"AtlasNode",_texture:null,_textureForCanvas:null,ctor:function(a,b,c,d){cc.Node.prototype.ctor.call(this),this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST},this._ignoreContentScaleFactor=!1,void 0!==d&&this.initWithTileFile(a,b,c,d)},_createRenderCmd:function(){cc._renderType===cc.game.RENDER_TYPE_CANVAS?this._renderCmd=new cc.AtlasNode.CanvasRenderCmd(this):this._renderCmd=new cc.AtlasNode.WebGLRenderCmd(this)},updateAtlasValues:function(){cc.log(cc._LogInfos.AtlasNode_updateAtlasValues)},getColor:function(){return this._opacityModifyRGB?this._renderCmd._colorUnmodified:cc.Node.prototype.getColor.call(this)},setOpacityModifyRGB:function(a){var b=this.color;this._opacityModifyRGB=a,this.setColor(b)},isOpacityModifyRGB:function(){return this._opacityModifyRGB},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?this._blendFunc=a:this._blendFunc={src:a,dst:b}},setTextureAtlas:function(a){this.textureAtlas=a},getTextureAtlas:function(){return this.textureAtlas},getQuadsToDraw:function(){return this.quadsToDraw},setQuadsToDraw:function(a){this.quadsToDraw=a},initWithTileFile:function(a,b,c,d){if(!a)throw new Error("cc.AtlasNode.initWithTileFile(): title should not be null");var e=cc.textureCache.addImage(a);return this.initWithTexture(e,b,c,d)},initWithTexture:function(a,b,c,d){return this._renderCmd.initWithTexture(a,b,c,d)},setColor:function(a){this._renderCmd.setColor(a)},setOpacity:function(a){this._renderCmd.setOpacity(a)},getTexture:function(){return this._texture},setTexture:function(a){this._texture=a},_setIgnoreContentScaleFactor:function(a){this._ignoreContentScaleFactor=a}});var _p=cc.AtlasNode.prototype;cc.defineGetterSetter(_p,"opacity",_p.getOpacity,_p.setOpacity),cc.defineGetterSetter(_p,"color",_p.getColor,_p.setColor),_p.texture,cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture),_p.textureAtlas,_p.quadsToDraw,cc.EventHelper.prototype.apply(_p),cc.AtlasNode.create=function(a,b,c,d){return new cc.AtlasNode(a,b,c,d)},function(){cc.AtlasNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!1,this._colorUnmodified=cc.color.WHITE,this._textureToRender=null};var a=cc.AtlasNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.AtlasNode.CanvasRenderCmd,a.initWithTexture=function(a,b,c,d){var e=this._node;return e._itemWidth=b,e._itemHeight=c,e._opacityModifyRGB=!0,e._texture=a,e._texture?(this._textureToRender=a,this._calculateMaxItems(),e.quadsToDraw=d,!0):(cc.log(cc._LogInfos.AtlasNode__initWithTexture),!1)},a.setColor=function(a){var b=this._node,c=b._realColor;(c.r!==a.r||c.g!==a.g||c.b!==a.b)&&(this._colorUnmodified=a,this._changeTextureColor())},a._changeTextureColor=function(){var a=this._node,b=a._texture,c=this._colorUnmodified,d=b.getHtmlElementObj(),e=cc.rect(0,0,d.width,d.height);b===this._textureToRender?this._textureToRender=b._generateColorTexture(c.r,c.g,c.b,e):b._generateColorTexture(c.r,c.g,c.b,e,this._textureToRender.getHtmlElementObj())},a.setOpacity=function(a){var b=this._node;cc.Node.prototype.setOpacity.call(b,a)},a._calculateMaxItems=function(){var a=this._node,b=a._texture,c=b.getContentSize();a._itemsPerColumn=0|c.height/a._itemHeight,a._itemsPerRow=0|c.width/a._itemWidth}}(),cc.TextureAtlas=cc.Class.extend({dirty:!1,texture:null,_indices:null,_buffersVBO:null,_capacity:0,_quads:null,_quadsArrayBuffer:null,_quadsWebBuffer:null,_quadsReader:null,ctor:function(a,b){this._buffersVBO=[],cc.isString(a)?this.initWithFile(a,b):a instanceof cc.Texture2D&&this.initWithTexture(a,b)},getTotalQuads:function(){return this._totalQuads},getCapacity:function(){return this._capacity},getTexture:function(){return this.texture},setTexture:function(a){this.texture=a},setDirty:function(a){this.dirty=a},isDirty:function(){return this.dirty},getQuads:function(){return this._quads},setQuads:function(a){this._quads=a},_copyQuadsToTextureAtlas:function(a,b){if(a)for(var c=0;c"},_setupIndices:function(){if(0!==this._capacity)for(var a=this._indices,b=this._capacity,c=0;b>c;c++)cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP?(a[6*c+0]=4*c+0,a[6*c+1]=4*c+0,a[6*c+2]=4*c+2,a[6*c+3]=4*c+1,a[6*c+4]=4*c+3,a[6*c+5]=4*c+3):(a[6*c+0]=4*c+0,a[6*c+1]=4*c+1,a[6*c+2]=4*c+2,a[6*c+3]=4*c+3,a[6*c+4]=4*c+2,a[6*c+5]=4*c+1)},_setupVBO:function(){var a=cc._renderContext;this._buffersVBO[0]=a.createBuffer(),this._buffersVBO[1]=a.createBuffer(),this._quadsWebBuffer=a.createBuffer(),this._mapBuffers()},_mapBuffers:function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._quadsWebBuffer),a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW)},initWithFile:function(a,b){var c=cc.textureCache.addImage(a);return c?this.initWithTexture(c,b):(cc.log(cc._LogInfos.TextureAtlas_initWithFile,a),!1)},initWithTexture:function(a,b){cc.assert(a,cc._LogInfos.TextureAtlas_initWithTexture),b=0|b,this._capacity=b,this._totalQuads=0,this.texture=a,this._quads=[],this._indices=new Uint16Array(6*b);var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;if(this._quadsArrayBuffer=new ArrayBuffer(c*b),this._quadsReader=new Uint8Array(this._quadsArrayBuffer),(!this._quads||!this._indices)&&b>0)return!1;for(var d=this._quads,e=0;b>e;e++)d[e]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,e*c);return this._setupIndices(),this._setupVBO(),this.dirty=!0,!0},updateQuad:function(a,b){cc.assert(a,cc._LogInfos.TextureAtlas_updateQuad),cc.assert(b>=0&&bthis._capacity)return void cc.log(cc._LogInfos.TextureAtlas_insertQuad);var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,d=this._totalQuads-1-b,e=b*c,f=d*c;this._quads[this._totalQuads-1]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,(this._totalQuads-1)*c),this._quadsReader.set(this._quadsReader.subarray(e,e+f),e+c),this._setQuadToArray(a,b),this.dirty=!0},insertQuads:function(a,b,c){c=c||a.length,cc.assert(b+c<=this._capacity,cc._LogInfos.TextureAtlas_insertQuads);var d=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;if(this._totalQuads+=c,this._totalQuads>this._capacity)return void cc.log(cc._LogInfos.TextureAtlas_insertQuad);var e,f=this._totalQuads-1-b-c,g=b*d,h=f*d,i=this._totalQuads-1-c;for(e=0;c>e;e++)this._quads[i+e]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,(this._totalQuads-1)*d);for(this._quadsReader.set(this._quadsReader.subarray(g,g+h),g+d*c),e=0;c>e;e++)this._setQuadToArray(a[e],b+e);this.dirty=!0},insertQuadFromIndex:function(a,b){if(a!==b){cc.assert(b>=0||b=0||ab?(c=b*e,d=(a-b)*e,f.set(f.subarray(c,c+d),c+e),f.set(g,c)):(c=(a+1)*e,d=(b-a)*e,f.set(f.subarray(c,c+d),c-e),f.set(g,b*e)),this.dirty=!0}},removeQuadAtIndex:function(a){cc.assert(ad;d++)this._quads=new cc.V3F_C4B_T2F_Quad(null,null,null,null,this._quadsArrayBuffer,d*b);else{var g,h,i=this._quads;if(e>c){for(g=[],h=new ArrayBuffer(b*e),d=0;f>d;d++)g[d]=new cc.V3F_C4B_T2F_Quad(i[d].tl,i[d].bl,i[d].tr,i[d].br,h,d*b);for(;e>d;d++)g[d]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,h,d*b);this._quadsReader=new Uint8Array(h),this._quads=g,this._quadsArrayBuffer=h}else{var j=Math.max(f,e);for(g=[],h=new ArrayBuffer(b*e),d=0;j>d;d++)g[d]=new cc.V3F_C4B_T2F_Quad(i[d].tl,i[d].bl,i[d].tr,i[d].br,h,d*b);this._quadsReader=new Uint8Array(h),this._quads=g,this._quadsArrayBuffer=h}}if(null===this._indices)this._indices=new Uint16Array(6*e);else if(e>c){var k=new Uint16Array(6*e);k.set(this._indices,0),this._indices=k}else this._indices=this._indices.subarray(0,6*e);return this._setupIndices(),this._mapBuffers(),this.dirty=!0,!0},increaseTotalQuadsWith:function(a){this._totalQuads+=a},moveQuadsFromIndex:function(a,b,c){if(void 0===c){if(c=b,b=this._totalQuads-a,cc.assert(c+(this._totalQuads-a)<=this._capacity,cc._LogInfos.TextureAtlas_moveQuadsFromIndex),0===b)return}else if(cc.assert(c+b<=this._totalQuads,cc._LogInfos.TextureAtlas_moveQuadsFromIndex_2),cc.assert(ac?(d=(a-c)*f,e=c*f,i.set(i.subarray(e,e+d),e+h)):(d=(c-a)*f,e=(a+b)*f,i.set(i.subarray(e,e+d),g)),i.set(j,k),this.dirty=!0},fillWithEmptyQuadsFromIndex:function(a,b){for(var c=b*cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,d=new Uint8Array(this._quadsArrayBuffer,a*cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,c),e=0;c>e;e++)d[e]=0},drawQuads:function(){this.drawNumberOfQuads(this._totalQuads,0)},_releaseBuffer:function(){var a=cc._renderContext;this._buffersVBO&&(this._buffersVBO[0]&&a.deleteBuffer(this._buffersVBO[0]),this._buffersVBO[1]&&a.deleteBuffer(this._buffersVBO[1])),this._quadsWebBuffer&&a.deleteBuffer(this._quadsWebBuffer)}});var _p=cc.TextureAtlas.prototype;_p.totalQuads,cc.defineGetterSetter(_p,"totalQuads",_p.getTotalQuads),_p.capacity,cc.defineGetterSetter(_p,"capacity",_p.getCapacity),_p.quads,cc.defineGetterSetter(_p,"quads",_p.getQuads,_p.setQuads),cc.TextureAtlas.create=function(a,b){return new cc.TextureAtlas(a,b)},cc.TextureAtlas.createWithTexture=cc.TextureAtlas.create,cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(cc.assert(cc.isFunction(cc._tmp.WebGLTextureAtlas),cc._LogInfos.MissingFile,"TexturesWebGL.js"),cc._tmp.WebGLTextureAtlas(),delete cc._tmp.WebGLTextureAtlas)}),cc.assert(cc.isFunction(cc._tmp.PrototypeTextureAtlas),cc._LogInfos.MissingFile,"TexturesPropertyDefine.js"),cc._tmp.PrototypeTextureAtlas(),delete cc._tmp.PrototypeTextureAtlas,cc.Camera=cc.Class.extend({_eyeX:null,_eyeY:null,_eyeZ:null,_centerX:null,_centerY:null,_centerZ:null,_upX:null,_upY:null,_upZ:null,_dirty:!1,_lookupMatrix:null,ctor:function(){this._lookupMatrix=new cc.math.Matrix4,this.restore()},description:function(){return""},setDirty:function(a){this._dirty=a},isDirty:function(){return this._dirty},restore:function(){this._eyeX=this._eyeY=0,this._eyeZ=cc.Camera.getZEye(),this._centerX=this._centerY=this._centerZ=0,this._upX=0,this._upY=1,this._upZ=0,this._lookupMatrix.identity(),this._dirty=!1},locate:function(){if(this._dirty){var a=new cc.math.Vec3(this._eyeX,this._eyeY,this._eyeZ),b=new cc.math.Vec3(this._centerX,this._centerY,this._centerZ),c=new cc.math.Vec3(this._upX,this._upY,this._upZ);this._lookupMatrix.lookAt(a,b,c),this._dirty=!1}cc.kmGLMultMatrix(this._lookupMatrix)},_locateForRenderer:function(a){if(this._dirty){var b=new cc.math.Vec3(this._eyeX,this._eyeY,this._eyeZ),c=new cc.math.Vec3(this._centerX,this._centerY,this._centerZ),d=new cc.math.Vec3(this._upX,this._upY,this._upZ);this._lookupMatrix.lookAt(b,c,d),this._dirty=!1}a.multiply(this._lookupMatrix)},setEyeXYZ:function(a,b,c){this.setEye(a,b,c)},setEye:function(a,b,c){this._eyeX=a,this._eyeY=b,this._eyeZ=c,this._dirty=!0},setCenterXYZ:function(a,b,c){this.setCenter(a,b,c)},setCenter:function(a,b,c){this._centerX=a,this._centerY=b,this._centerZ=c,this._dirty=!0},setUpXYZ:function(a,b,c){this.setUp(a,b,c)},setUp:function(a,b,c){this._upX=a,this._upY=b,this._upZ=c,this._dirty=!0},getEyeXYZ:function(a,b,c){return{x:this._eyeX,y:this._eyeY,z:this._eyeZ}},getEye:function(){return{x:this._eyeX,y:this._eyeY,z:this._eyeZ}},getCenterXYZ:function(a,b,c){return{x:this._centerX,y:this._centerY,z:this._centerZ}},getCenter:function(){return{x:this._centerX,y:this._centerY,z:this._centerZ}},getUpXYZ:function(a,b,c){return{x:this._upX,y:this._upY,z:this._upZ}},getUp:function(){return{x:this._upX,y:this._upY,z:this._upZ}},_DISALLOW_COPY_AND_ASSIGN:function(a){}}),cc.Camera.getZEye=function(){return cc.FLT_EPSILON},cc.PI2=2*Math.PI,cc.DrawingPrimitiveCanvas=cc.Class.extend({_cacheArray:[],_renderContext:null,ctor:function(a){this._renderContext=a},drawPoint:function(a,b){b||(b=1);var c=cc.view.getScaleX(),d=cc.view.getScaleY(),e=cc.p(a.x*c,a.y*d),f=this._renderContext.getContext();f.beginPath(),f.arc(e.x,-e.y,b*c,0,2*Math.PI,!1),f.closePath(),f.fill()},drawPoints:function(a,b,c){if(null!=a){c||(c=1);var d=this._renderContext.getContext(),e=cc.view.getScaleX(),f=cc.view.getScaleY();d.beginPath();for(var g=0,h=a.length;h>g;g++)d.arc(a[g].x*e,-a[g].y*f,c*e,0,2*Math.PI,!1);d.closePath(),d.fill()}},drawLine:function(a,b){var c=this._renderContext.getContext(),d=cc.view.getScaleX(),e=cc.view.getScaleY();c.beginPath(),c.moveTo(a.x*d,-a.y*e),c.lineTo(b.x*d,-b.y*e),c.closePath(),c.stroke()},drawRect:function(a,b){this.drawLine(cc.p(a.x,a.y),cc.p(b.x,a.y)),this.drawLine(cc.p(b.x,a.y),cc.p(b.x,b.y)),this.drawLine(cc.p(b.x,b.y),cc.p(a.x,b.y)),this.drawLine(cc.p(a.x,b.y),cc.p(a.x,a.y))},drawSolidRect:function(a,b,c){var d=[a,cc.p(b.x,a.y),b,cc.p(a.x,b.y)];this.drawSolidPoly(d,4,c)},drawPoly:function(a,b,c,d){if(d=d||!1,null!=a){if(a.length<3)throw new Error("Polygon's point must greater than 2");var e=a[0],f=this._renderContext.getContext(),g=cc.view.getScaleX(),h=cc.view.getScaleY();f.beginPath(),f.moveTo(e.x*g,-e.y*h);for(var i=1,j=a.length;j>i;i++)f.lineTo(a[i].x*g,-a[i].y*h);c&&f.closePath(),d?f.fill():f.stroke()}},drawSolidPoly:function(a,b,c){this.setDrawColor(c.r,c.g,c.b,c.a),this.drawPoly(a,b,!0,!0)},drawCircle:function(a,b,c,d,e){e=e||!1;var f=this._renderContext.getContext(),g=cc.view.getScaleX(),h=cc.view.getScaleY();f.beginPath();var i=c-2*Math.PI;f.arc(0|a.x*g,0|-(a.y*h),b*g,-c,-i,!1),e&&f.lineTo(0|a.x*g,0|-(a.y*h)),f.stroke()},drawQuadBezier:function(a,b,c,d){var e=this._cacheArray;e.length=0;for(var f=0,g=0;d>g;g++){var h=Math.pow(1-f,2)*a.x+2*(1-f)*f*b.x+f*f*c.x,i=Math.pow(1-f,2)*a.y+2*(1-f)*f*b.y+f*f*c.y;e.push(cc.p(h,i)),f+=1/d}e.push(cc.p(c.x,c.y)),this.drawPoly(e,d+1,!1,!1)},drawCubicBezier:function(a,b,c,d,e){var f=this._cacheArray;f.length=0;for(var g=0,h=0;e>h;h++){var i=Math.pow(1-g,3)*a.x+3*Math.pow(1-g,2)*g*b.x+3*(1-g)*g*g*c.x+g*g*g*d.x,j=Math.pow(1-g,3)*a.y+3*Math.pow(1-g,2)*g*b.y+3*(1-g)*g*g*c.y+g*g*g*d.y;f.push(cc.p(i,j)),g+=1/e}f.push(cc.p(d.x,d.y)),this.drawPoly(f,e+1,!1,!1)},drawCatmullRom:function(a,b){this.drawCardinalSpline(a,.5,b)},drawCardinalSpline:function(a,b,c){cc._renderContext.setStrokeStyle("rgba(255,255,255,1)");var d=this._cacheArray;d.length=0;for(var e,f,g=1/a.length,h=0;c+1>h;h++){var i=h/c;1===i?(e=a.length-1,f=1):(e=0|i/g,f=(i-g*e)/g);var j=cc.CardinalSplineAt(cc.getControlPointAt(a,e-1),cc.getControlPointAt(a,e-0),cc.getControlPointAt(a,e+1),cc.getControlPointAt(a,e+2),b,f);d.push(j)}this.drawPoly(d,c+1,!1,!1)},drawImage:function(a,b,c,d,e){var f=arguments.length,g=this._renderContext.getContext();switch(f){case 2:var h=a.height;g.drawImage(a,b.x,-(b.y+h));break;case 3:g.drawImage(a,b.x,-(b.y+c.height),c.width,c.height);break;case 5:g.drawImage(a,b.x,b.y,c.width,c.height,d.x,-(d.y+e.height),e.width,e.height);break;default:throw new Error("Argument must be non-nil")}},drawStar:function(a,b,c){var d=a||this._renderContext,e=d.getContext();b*=cc.view.getScaleX();var f="rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b);d.setFillStyle(f+",1)");var g=b/10;e.beginPath(),e.moveTo(-b,b),e.lineTo(0,g),e.lineTo(b,b),e.lineTo(g,0),e.lineTo(b,-b),e.lineTo(0,-g),e.lineTo(-b,-b),e.lineTo(-g,0),e.lineTo(-b,b),e.closePath(),e.fill();var h=e.createRadialGradient(0,0,g,0,0,b);h.addColorStop(0,f+", 1)"),h.addColorStop(.3,f+", 0.8)"),h.addColorStop(1,f+", 0.0)"),d.setFillStyle(h),e.beginPath();var i=0,j=cc.PI2;e.arc(0,0,b-g,i,j,!1),e.closePath(),e.fill()},drawColorBall:function(a,b,c){var d=a||this._renderContext,e=d.getContext();b*=cc.view.getScaleX();var f="rgba("+(0|c.r)+","+(0|c.g)+","+(0|c.b),g=b/10,h=e.createRadialGradient(0,0,g,0,0,b);h.addColorStop(0,f+", 1)"),h.addColorStop(.3,f+", 0.8)"),h.addColorStop(.6,f+", 0.4)"),h.addColorStop(1,f+", 0.0)"),d.setFillStyle(h),e.beginPath();var i=0,j=cc.PI2;e.arc(0,0,b,i,j,!1),e.closePath(),e.fill()},fillText:function(a,b,c){this._renderContext.getContext().fillText(a,b,-c)},setDrawColor:function(a,b,c,d){this._renderContext.setFillStyle("rgba("+a+","+b+","+c+","+d/255+")"),this._renderContext.setStrokeStyle("rgba("+a+","+b+","+c+","+d/255+")")},setPointSize:function(a){},setLineWidth:function(a){this._renderContext.getContext().lineWidth=a*cc.view.getScaleX()}});!function(){cc.AtlasNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._textureAtlas=null,this._colorUnmodified=cc.color.WHITE,this._colorF32Array=null,this._uniformColor=null,this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR),this._uniformColor=cc._renderContext.getUniformLocation(this._shaderProgram.getProgram(),"u_color")};var a=cc.AtlasNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.AtlasNode.WebGLRenderCmd,a._updateBlendFunc=function(){var a=this._node;this._textureAtlas.texture.hasPremultipliedAlpha()||(a._blendFunc.src=cc.SRC_ALPHA,a._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA)},a._updateOpacityModifyRGB=function(){this._node._opacityModifyRGB=this._textureAtlas.texture.hasPremultipliedAlpha()},a.rendering=function(a){var b=a||cc._renderContext,c=this._node;this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFunc(c._blendFunc.src,c._blendFunc.dst),this._uniformColor&&this._colorF32Array&&(b.uniform4fv(this._uniformColor,this._colorF32Array),this._textureAtlas.drawNumberOfQuads(c.quadsToDraw,0))},a.initWithTexture=function(a,b,c,d){var e=this._node;e._itemWidth=b,e._itemHeight=c,this._colorUnmodified=cc.color.WHITE,e._opacityModifyRGB=!0,e._blendFunc.src=cc.BLEND_SRC,e._blendFunc.dst=cc.BLEND_DST;var f=e._realColor;return this._colorF32Array=new Float32Array([f.r/255,f.g/255,f.b/255,e._realOpacity/255]),this._textureAtlas=new cc.TextureAtlas,this._textureAtlas.initWithTexture(a,d),this._textureAtlas?(this._updateBlendFunc(),this._updateOpacityModifyRGB(),this._calculateMaxItems(),e.quadsToDraw=d,!0):(cc.log(cc._LogInfos.AtlasNode__initWithTexture),!1)},a.setColor=function(a){var b=cc.color(a.r,a.g,a.b),c=this._node;this._colorUnmodified=a;var d=this._displayedOpacity;c._opacityModifyRGB&&(b.r=b.r*d/255,b.g=b.g*d/255,b.b=b.b*d/255),cc.Node.prototype.setColor.call(c,b)},a.setOpacity=function(a){var b=this._node;cc.Node.prototype.setOpacity.call(b,a),b._opacityModifyRGB&&(b.color=this._colorUnmodified)},a._updateColor=function(){var a=this._displayedColor;this._colorF32Array=new Float32Array([a.r/255,a.g/255,a.b/255,this._displayedOpacity/255])},a.getTexture=function(){return this._textureAtlas.texture},a.setTexture=function(a){this._textureAtlas.texture=a,this._updateBlendFunc(),this._updateOpacityModifyRGB()},a._calculateMaxItems=function(){var a=this._node,b=this._textureAtlas.texture,c=b.getContentSize();a._ignoreContentScaleFactor&&(c=b.getContentSizeInPixels()),a._itemsPerColumn=0|c.height/a._itemHeight,a._itemsPerRow=0|c.width/a._itemWidth}}();cc._LogInfos={ActionManager_addAction:"cc.ActionManager.addAction(): action must be non-null",ActionManager_removeAction:"cocos2d: removeAction: Target not found",ActionManager_removeActionByTag:"cc.ActionManager.removeActionByTag(): an invalid tag",ActionManager_removeActionByTag_2:"cc.ActionManager.removeActionByTag(): target must be non-null",ActionManager_getActionByTag:"cc.ActionManager.getActionByTag(): an invalid tag",ActionManager_getActionByTag_2:"cocos2d : getActionByTag(tag = %s): Action not found",configuration_dumpInfo:"cocos2d: **** WARNING **** CC_ENABLE_PROFILERS is defined. Disable it when you finish profiling (from ccConfig.js)",configuration_loadConfigFile:"Expected 'data' dict, but not found. Config file: %s",configuration_loadConfigFile_2:"Please load the resource first : %s",Director_resume:"cocos2d: Director: Error in gettimeofday",Director_setProjection:"cocos2d: Director: unrecognized projection",Director_popToSceneStackLevel:"cocos2d: Director: unrecognized projection",Director_popToSceneStackLevel_2:"cocos2d: Director: Error in gettimeofday",Director_popScene:"running scene should not null",Director_pushScene:"the scene should not null",arrayVerifyType:"element type is wrong!",Scheduler_scheduleCallbackForTarget:"CCSheduler#scheduleCallback. Callback already scheduled. Updating interval from:%s to %s",Scheduler_scheduleCallbackForTarget_2:"cc.scheduler.scheduleCallbackForTarget(): callback_fn should be non-null.",Scheduler_scheduleCallbackForTarget_3:"cc.scheduler.scheduleCallbackForTarget(): target should be non-null.",Scheduler_pauseTarget:"cc.Scheduler.pauseTarget():target should be non-null",Scheduler_resumeTarget:"cc.Scheduler.resumeTarget():target should be non-null",Scheduler_isTargetPaused:"cc.Scheduler.isTargetPaused():target should be non-null",Node_getZOrder:"getZOrder is deprecated. Please use getLocalZOrder instead.",Node_setZOrder:"setZOrder is deprecated. Please use setLocalZOrder instead.",Node_getRotation:"RotationX != RotationY. Don't know which one to return",Node_getScale:"ScaleX != ScaleY. Don't know which one to return",Node_addChild:"An Node can't be added as a child of itself.",Node_addChild_2:"child already added. It can't be added again",Node_addChild_3:"child must be non-null",Node_removeFromParentAndCleanup:"removeFromParentAndCleanup is deprecated. Use removeFromParent instead",Node_boundingBox:"boundingBox is deprecated. Use getBoundingBox instead",Node_removeChildByTag:"argument tag is an invalid tag",Node_removeChildByTag_2:"cocos2d: removeChildByTag(tag = %s): child not found!",Node_removeAllChildrenWithCleanup:"removeAllChildrenWithCleanup is deprecated. Use removeAllChildren instead",Node_stopActionByTag:"cc.Node.stopActionBy(): argument tag an invalid tag",Node_getActionByTag:"cc.Node.getActionByTag(): argument tag is an invalid tag",Node_resumeSchedulerAndActions:"resumeSchedulerAndActions is deprecated, please use resume instead.",Node_pauseSchedulerAndActions:"pauseSchedulerAndActions is deprecated, please use pause instead.",Node__arrayMakeObjectsPerformSelector:"Unknown callback function",Node_reorderChild:"child must be non-null",Node_runAction:"cc.Node.runAction(): action must be non-null",Node_schedule:"callback function must be non-null",Node_schedule_2:"interval must be positive",Node_initWithTexture:"cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",AtlasNode_updateAtlasValues:"cc.AtlasNode.updateAtlasValues(): Shall be overridden in subclasses",AtlasNode_initWithTileFile:"",AtlasNode__initWithTexture:"cocos2d: Could not initialize cc.AtlasNode. Invalid Texture.",_EventListenerKeyboard_checkAvailable:"cc._EventListenerKeyboard.checkAvailable(): Invalid EventListenerKeyboard!",_EventListenerTouchOneByOne_checkAvailable:"cc._EventListenerTouchOneByOne.checkAvailable(): Invalid EventListenerTouchOneByOne!",_EventListenerTouchAllAtOnce_checkAvailable:"cc._EventListenerTouchAllAtOnce.checkAvailable(): Invalid EventListenerTouchAllAtOnce!",_EventListenerAcceleration_checkAvailable:"cc._EventListenerAcceleration.checkAvailable(): _onAccelerationEvent must be non-nil",EventListener_create:"Invalid parameter.",__getListenerID:"Don't call this method if the event is for touch.",eventManager__forceAddEventListener:"Invalid scene graph priority!",eventManager_addListener:"0 priority is forbidden for fixed priority since it's used for scene graph based priority.",eventManager_removeListeners:"Invalid listener type!",eventManager_setPriority:"Can't set fixed priority with scene graph based listener.",eventManager_addListener_2:"Invalid parameters.",eventManager_addListener_3:"listener must be a cc.EventListener object when adding a fixed priority listener",eventManager_addListener_4:"The listener has been registered, please don't register it again.",LayerMultiplex_initWithLayers:"parameters should not be ending with null in Javascript",LayerMultiplex_switchTo:"Invalid index in MultiplexLayer switchTo message",LayerMultiplex_switchToAndReleaseMe:"Invalid index in MultiplexLayer switchTo message",LayerMultiplex_addLayer:"cc.Layer.addLayer(): layer should be non-null",EGLView_setDesignResolutionSize:"Resolution not valid",EGLView_setDesignResolutionSize_2:"should set resolutionPolicy",inputManager_handleTouchesBegin:"The touches is more than MAX_TOUCHES, nUnusedIndex = %s",swap:"cc.swap is being modified from original macro, please check usage",checkGLErrorDebug:"WebGL error %s",animationCache__addAnimationsWithDictionary:"cocos2d: cc.AnimationCache: No animations were found in provided dictionary.",animationCache__addAnimationsWithDictionary_2:"cc.AnimationCache. Invalid animation format",animationCache_addAnimations:"cc.AnimationCache.addAnimations(): File could not be found",animationCache__parseVersion1:"cocos2d: cc.AnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",animationCache__parseVersion1_2:"cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.",animationCache__parseVersion1_3:"cocos2d: cc.AnimationCache: None of the frames for animation '%s' were found in the cc.SpriteFrameCache. Animation is not being added to the Animation Cache.",animationCache__parseVersion1_4:"cocos2d: cc.AnimationCache: An animation in your dictionary refers to a frame which is not in the cc.SpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.",animationCache__parseVersion2:"cocos2d: CCAnimationCache: Animation '%s' found in dictionary without any frames - cannot add to animation cache.",animationCache__parseVersion2_2:"cocos2d: cc.AnimationCache: Animation '%s' refers to frame '%s' which is not currently in the cc.SpriteFrameCache. This frame will not be added to the animation.",animationCache_addAnimations_2:"cc.AnimationCache.addAnimations(): Invalid texture file name",Sprite_reorderChild:"cc.Sprite.reorderChild(): this child is not in children list",Sprite_ignoreAnchorPointForPosition:"cc.Sprite.ignoreAnchorPointForPosition(): it is invalid in cc.Sprite when using SpriteBatchNode",Sprite_setDisplayFrameWithAnimationName:"cc.Sprite.setDisplayFrameWithAnimationName(): Frame not found",Sprite_setDisplayFrameWithAnimationName_2:"cc.Sprite.setDisplayFrameWithAnimationName(): Invalid frame index",Sprite_setDisplayFrame:"setDisplayFrame is deprecated, please use setSpriteFrame instead.",Sprite__updateBlendFunc:"cc.Sprite._updateBlendFunc(): _updateBlendFunc doesn't work when the sprite is rendered using a cc.CCSpriteBatchNode",Sprite_initWithSpriteFrame:"cc.Sprite.initWithSpriteFrame(): spriteFrame should be non-null",Sprite_initWithSpriteFrameName:"cc.Sprite.initWithSpriteFrameName(): spriteFrameName should be non-null",Sprite_initWithSpriteFrameName1:" is null, please check.",Sprite_initWithFile:"cc.Sprite.initWithFile(): filename should be non-null",Sprite_setDisplayFrameWithAnimationName_3:"cc.Sprite.setDisplayFrameWithAnimationName(): animationName must be non-null",Sprite_reorderChild_2:"cc.Sprite.reorderChild(): child should be non-null",Sprite_addChild:"cc.Sprite.addChild(): cc.Sprite only supports cc.Sprites as children when using cc.SpriteBatchNode",Sprite_addChild_2:"cc.Sprite.addChild(): cc.Sprite only supports a sprite using same texture as children when using cc.SpriteBatchNode",Sprite_addChild_3:"cc.Sprite.addChild(): child should be non-null",Sprite_setTexture:"cc.Sprite.texture setter: Batched sprites should use the same texture as the batchnode",Sprite_updateQuadFromSprite:"cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",Sprite_insertQuadFromSprite:"cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",Sprite_addChild_4:"cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",Sprite_addChild_5:"cc.SpriteBatchNode.addChild(): cc.Sprite is not using the same texture",Sprite_initWithTexture:"Sprite.initWithTexture(): Argument must be non-nil ",Sprite_setSpriteFrame:"Invalid spriteFrameName",Sprite_setTexture_2:"Invalid argument: cc.Sprite.texture setter expects a CCTexture2D.",Sprite_updateQuadFromSprite_2:"cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",Sprite_insertQuadFromSprite_2:"cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",SpriteBatchNode_addSpriteWithoutQuad:"cc.SpriteBatchNode.addQuadFromSprite(): SpriteBatchNode only supports cc.Sprites as children",SpriteBatchNode_increaseAtlasCapacity:"cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from %s to %s.",SpriteBatchNode_increaseAtlasCapacity_2:"cocos2d: WARNING: Not enough memory to resize the atlas",SpriteBatchNode_reorderChild:"cc.SpriteBatchNode.addChild(): Child doesn't belong to Sprite",SpriteBatchNode_removeChild:"cc.SpriteBatchNode.addChild(): sprite batch node should contain the child",SpriteBatchNode_addSpriteWithoutQuad_2:"cc.SpriteBatchNode.addQuadFromSprite(): child should be non-null",SpriteBatchNode_reorderChild_2:"cc.SpriteBatchNode.addChild(): child should be non-null",spriteFrameCache__getFrameConfig:"cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist",spriteFrameCache_addSpriteFrames:"cocos2d: WARNING: an alias with name %s already exists",spriteFrameCache__checkConflict:"cocos2d: WARNING: Sprite frame: %s has already been added by another source, please fix name conflit",spriteFrameCache_getSpriteFrame:"cocos2d: cc.SpriteFrameCahce: Frame %s not found",spriteFrameCache__getFrameConfig_2:"Please load the resource first : %s",spriteFrameCache_addSpriteFrames_2:"cc.SpriteFrameCache.addSpriteFrames(): plist should be non-null",spriteFrameCache_addSpriteFrames_3:"Argument must be non-nil",CCSpriteBatchNode_updateQuadFromSprite:"cc.SpriteBatchNode.updateQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",CCSpriteBatchNode_insertQuadFromSprite:"cc.SpriteBatchNode.insertQuadFromSprite(): cc.SpriteBatchNode only supports cc.Sprites as children",CCSpriteBatchNode_addChild:"cc.SpriteBatchNode.addChild(): cc.SpriteBatchNode only supports cc.Sprites as children",CCSpriteBatchNode_initWithTexture:"Sprite.initWithTexture(): Argument must be non-nil ",CCSpriteBatchNode_addChild_2:"cc.Sprite.addChild(): child should be non-null",CCSpriteBatchNode_setSpriteFrame:"Invalid spriteFrameName",CCSpriteBatchNode_setTexture:"Invalid argument: cc.Sprite texture setter expects a CCTexture2D.",CCSpriteBatchNode_updateQuadFromSprite_2:"cc.SpriteBatchNode.updateQuadFromSprite(): sprite should be non-null",CCSpriteBatchNode_insertQuadFromSprite_2:"cc.SpriteBatchNode.insertQuadFromSprite(): sprite should be non-null",CCSpriteBatchNode_addChild_3:"cc.SpriteBatchNode.addChild(): child should be non-null",TextureAtlas_initWithFile:"cocos2d: Could not open file: %s",TextureAtlas_insertQuad:"cc.TextureAtlas.insertQuad(): invalid totalQuads",TextureAtlas_initWithTexture:"cc.TextureAtlas.initWithTexture():texture should be non-null",TextureAtlas_updateQuad:"cc.TextureAtlas.updateQuad(): quad should be non-null",TextureAtlas_updateQuad_2:"cc.TextureAtlas.updateQuad(): Invalid index",TextureAtlas_insertQuad_2:"cc.TextureAtlas.insertQuad(): Invalid index",TextureAtlas_insertQuads:"cc.TextureAtlas.insertQuad(): Invalid index + amount",TextureAtlas_insertQuadFromIndex:"cc.TextureAtlas.insertQuadFromIndex(): Invalid newIndex",TextureAtlas_insertQuadFromIndex_2:"cc.TextureAtlas.insertQuadFromIndex(): Invalid fromIndex",TextureAtlas_removeQuadAtIndex:"cc.TextureAtlas.removeQuadAtIndex(): Invalid index",TextureAtlas_removeQuadsAtIndex:"cc.TextureAtlas.removeQuadsAtIndex(): index + amount out of bounds",TextureAtlas_moveQuadsFromIndex:"cc.TextureAtlas.moveQuadsFromIndex(): move is out of bounds",TextureAtlas_moveQuadsFromIndex_2:"cc.TextureAtlas.moveQuadsFromIndex(): Invalid newIndex",TextureAtlas_moveQuadsFromIndex_3:"cc.TextureAtlas.moveQuadsFromIndex(): Invalid oldIndex",textureCache_addPVRTCImage:"TextureCache:addPVRTCImage does not support on HTML5",textureCache_addETCImage:"TextureCache:addPVRTCImage does not support on HTML5",textureCache_textureForKey:"textureForKey is deprecated. Please use getTextureForKey instead.",textureCache_addPVRImage:"addPVRImage does not support on HTML5",textureCache_addUIImage:"cocos2d: Couldn't add UIImage in TextureCache",textureCache_dumpCachedTextureInfo:"cocos2d: '%s' id=%s %s x %s",textureCache_dumpCachedTextureInfo_2:"cocos2d: '%s' id= HTMLCanvasElement %s x %s",textureCache_dumpCachedTextureInfo_3:"cocos2d: TextureCache dumpDebugInfo: %s textures, HTMLCanvasElement for %s KB (%s MB)",textureCache_addUIImage_2:"cc.Texture.addUIImage(): image should be non-null",Texture2D_initWithETCFile:"initWithETCFile does not support on HTML5",Texture2D_initWithPVRFile:"initWithPVRFile does not support on HTML5",Texture2D_initWithPVRTCData:"initWithPVRTCData does not support on HTML5",Texture2D_addImage:"cc.Texture.addImage(): path should be non-null",Texture2D_initWithImage:"cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil",Texture2D_initWithImage_2:"cocos2d: WARNING: Image (%s x %s) is bigger than the supported %s x %s",Texture2D_initWithString:"initWithString isn't supported on cocos2d-html5",Texture2D_initWithETCFile_2:"initWithETCFile does not support on HTML5",Texture2D_initWithPVRFile_2:"initWithPVRFile does not support on HTML5",Texture2D_initWithPVRTCData_2:"initWithPVRTCData does not support on HTML5",Texture2D_bitsPerPixelForFormat:"bitsPerPixelForFormat: %s, cannot give useful result, it's a illegal pixel format",Texture2D__initPremultipliedATextureWithImage:"cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha",Texture2D_addImage_2:"cc.Texture.addImage(): path should be non-null",Texture2D_initWithData:"NSInternalInconsistencyException",MissingFile:"Missing file: %s",radiansToDegress:"cc.radiansToDegress() should be called cc.radiansToDegrees()",RectWidth:"Rect width exceeds maximum margin: %s",RectHeight:"Rect height exceeds maximum margin: %s",EventManager__updateListeners:"If program goes here, there should be event in dispatch.",EventManager__updateListeners_2:"_inDispatch should be 1 here."},cc._logToWebPage=function(a){if(cc._canvas){var b=cc._logList,c=document;if(!b){var d=c.createElement("Div"),e=d.style;d.setAttribute("id","logInfoDiv"),cc._canvas.parentNode.appendChild(d),d.setAttribute("width","200"),d.setAttribute("height",cc._canvas.height),e.zIndex="99999",e.position="absolute",e.top="0",e.left="0",b=cc._logList=c.createElement("textarea");var f=b.style;b.setAttribute("rows","20"),b.setAttribute("cols","30"),b.setAttribute("disabled",!0),d.appendChild(b),f.backgroundColor="transparent",f.borderBottom="1px solid #cccccc",f.borderRightWidth="0px",f.borderLeftWidth="0px",f.borderTopWidth="0px",f.borderTopStyle="none",f.borderRightStyle="none",f.borderLeftStyle="none",f.padding="0px",f.margin=0}b.value=b.value+a+"\r\n",b.scrollTop=b.scrollHeight}},cc._formatString=function(a){if(!cc.isObject(a))return a;try{return JSON.stringify(a)}catch(b){return""}},cc._initDebugSetting=function(a){var b=cc.game;if(a!==b.DEBUG_MODE_NONE){var c;a>b.DEBUG_MODE_ERROR?(c=cc._logToWebPage.bind(cc),cc.error=function(){c("ERROR : "+cc.formatStr.apply(cc,arguments))},cc.assert=function(a,b){if(!a&&b){for(var d=2;de;++e){var f=c.actions[e];if(f&&f.getTag()===a&&f.getOriginalTarget()===b){this._removeActionAtIndex(e,c);break}}},getActionByTag:function(a,b){a===cc.ACTION_TAG_INVALID&&cc.log(cc._LogInfos.ActionManager_getActionByTag);var c=this._hashTargets[b.__instanceId];if(c){if(null!=c.actions)for(var d=0;d=a&&b.actionIndex--,0===b.actions.length&&(this._currentTarget===b?this._currentTargetSalvaged=!0:this._deleteHashElement(b))},_deleteHashElement:function(a){var b=!1;return a&&(this._hashTargets[a.target.__instanceId]&&(delete this._hashTargets[a.target.__instanceId],cc.arrayRemoveObject(this._arrayTargets,a),b=!0),a.actions=null,a.target=null),b},_actionAllocWithHashElement:function(a){null==a.actions&&(a.actions=[])},update:function(a){for(var b,c=this._arrayTargets,d=0;d=this._duration},_cloneDecoration:function(a){a._repeatForever=this._repeatForever,a._speed=this._speed,a._timesForRepeat=this._timesForRepeat,a._easeList=this._easeList,a._speedMethod=this._speedMethod,a._repeatMethod=this._repeatMethod},_reverseEaseList:function(a){if(this._easeList){a._easeList=[];for(var b=0;bc;c++)a=b[c].easing(a);return a},step:function(a){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=a;var b=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);b=1>b?b:1,this.update(b>0?b:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},startWithTarget:function(a){cc.Action.prototype.startWithTarget.call(this,a),this._elapsed=0,this._firstTick=!0},reverse:function(){return cc.log("cc.IntervalAction: reverse not implemented."),null},setAmplitudeRate:function(a){cc.log("cc.ActionInterval.setAmplitudeRate(): it should be overridden in subclass.")},getAmplitudeRate:function(){return cc.log("cc.ActionInterval.getAmplitudeRate(): it should be overridden in subclass."),0},speed:function(a){return 0>=a?(cc.log("The speed parameter error"),this):(this._speedMethod=!0,this._speed*=a,this)},getSpeed:function(){return this._speed},setSpeed:function(a){return this._speed=a,this},repeat:function(a){return a=Math.round(a),isNaN(a)||1>a?(cc.log("The repeat parameter error"),this):(this._repeatMethod=!0,this._timesForRepeat*=a,this)},repeatForever:function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this}}),cc.actionInterval=function(a){return new cc.ActionInterval(a)},cc.ActionInterval.create=cc.actionInterval,cc.Sequence=cc.ActionInterval.extend({_actions:null,_split:null,_last:0,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this),this._actions=[];var b=a instanceof Array?a:arguments,c=b.length-1;if(c>=0&&null==b[c]&&cc.log("parameters should not be ending with null in Javascript"),c>=0){for(var d,e=b[0],f=1;c>f;f++)b[f]&&(d=e,e=cc.Sequence._actionOneTwo(d,b[f]));this.initWithTwoActions(e,b[c])}},initWithTwoActions:function(a,b){if(!a||!b)throw new Error("cc.Sequence.initWithTwoActions(): arguments must all be non nil");var c=a._duration+b._duration;return this.initWithDuration(c),this._actions[0]=a,this._actions[1]=b,!0},clone:function(){var a=new cc.Sequence;return this._cloneDecoration(a),a.initWithTwoActions(this._actions[0].clone(),this._actions[1].clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._split=this._actions[0]._duration/this._duration,this._last=-1},stop:function(){-1!==this._last&&this._actions[this._last].stop(),cc.Action.prototype.stop.call(this)},update:function(a){var b,c,d=0,e=this._split,f=this._actions,g=this._last;a=this._computeEaseTime(a),e>a?(b=0!==e?a/e:1,0===d&&1===g&&(f[1].update(0),f[1].stop())):(d=1,b=1===e?1:(a-e)/(1-e),-1===g&&(f[0].startWithTarget(this.target),f[0].update(1),f[0].stop()),g||(f[0].update(1),f[0].stop())),c=f[d],g===d&&c.isDone()||(g!==d&&c.startWithTarget(this.target),b*=c._timesForRepeat,c.update(b>1?b%1:b),this._last=d)},reverse:function(){var a=cc.Sequence._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.sequence=function(a){var b=a instanceof Array?a:arguments;b.length>0&&null==b[b.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var c,d,e,f;b&&b.length>0;)for(d=Array.prototype.shift.call(b),f=d._timesForRepeat||1,d._repeatMethod=!1,d._timesForRepeat=1,e=0,c||(c=d,e=1),e;f>e;e++)c=cc.Sequence._actionOneTwo(c,d);return c},cc.Sequence.create=cc.sequence,cc.Sequence._actionOneTwo=function(a,b){var c=new cc.Sequence;return c.initWithTwoActions(a,b),c},cc.Repeat=cc.ActionInterval.extend({_times:0,_total:0,_nextDt:0,_actionInstant:!1,_innerAction:null,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this),void 0!==b&&this.initWithAction(a,b)},initWithAction:function(a,b){var c=a._duration*b;return this.initWithDuration(c)?(this._times=b,this._innerAction=a,a instanceof cc.ActionInstant&&(this._actionInstant=!0,this._times-=1),this._total=0,!0):!1},clone:function(){var a=new cc.Repeat;return this._cloneDecoration(a),a.initWithAction(this._innerAction.clone(),this._times),a},startWithTarget:function(a){this._total=0,this._nextDt=this._innerAction._duration/this._duration,cc.ActionInterval.prototype.startWithTarget.call(this,a),this._innerAction.startWithTarget(a)},stop:function(){this._innerAction.stop(),cc.Action.prototype.stop.call(this)},update:function(a){a=this._computeEaseTime(a);var b=this._innerAction,c=this._duration,d=this._times,e=this._nextDt;if(a>=e){for(;a>e&&this._total=1&&this._total=0&&null==b[c]&&cc.log("parameters should not be ending with null in Javascript"),c>=0){for(var d,e=b[0],f=1;c>f;f++)b[f]&&(d=e,e=cc.Spawn._actionOneTwo(d,b[f]));this.initWithTwoActions(e,b[c])}},initWithTwoActions:function(a,b){if(!a||!b)throw new Error("cc.Spawn.initWithTwoActions(): arguments must all be non null");var c=!1,d=a._duration,e=b._duration;return this.initWithDuration(Math.max(d,e))&&(this._one=a,this._two=b,d>e?this._two=cc.Sequence._actionOneTwo(b,cc.delayTime(d-e)):e>d&&(this._one=cc.Sequence._actionOneTwo(a,cc.delayTime(e-d))),c=!0),c},clone:function(){var a=new cc.Spawn;return this._cloneDecoration(a),a.initWithTwoActions(this._one.clone(),this._two.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._one.startWithTarget(a),this._two.startWithTarget(a)},stop:function(){this._one.stop(),this._two.stop(),cc.Action.prototype.stop.call(this)},update:function(a){a=this._computeEaseTime(a),this._one&&this._one.update(a),this._two&&this._two.update(a)},reverse:function(){var a=cc.Spawn._actionOneTwo(this._one.reverse(),this._two.reverse());return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.spawn=function(a){var b=a instanceof Array?a:arguments;b.length>0&&null==b[b.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var c=b[0],d=1;d180&&(c-=360),-180>c&&(c+=360),this._startAngleX=b,this._diffAngleX=c,this._startAngleY=a.rotationY%360;var d=this._dstAngleY-this._startAngleY;d>180&&(d-=360),-180>d&&(d+=360),this._diffAngleY=d},reverse:function(){cc.log("cc.RotateTo.reverse(): it should be overridden in subclass.")},update:function(a){a=this._computeEaseTime(a),this.target&&(this.target.rotationX=this._startAngleX+this._diffAngleX*a,this.target.rotationY=this._startAngleY+this._diffAngleY*a)}}),cc.rotateTo=function(a,b,c){return new cc.RotateTo(a,b,c)},cc.RotateTo.create=cc.rotateTo,cc.RotateBy=cc.ActionInterval.extend({_angleX:0,_startAngleX:0,_angleY:0,_startAngleY:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this),void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._angleX=b||0,this._angleY=c||this._angleX,!0):!1},clone:function(){var a=new cc.RotateBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._angleX,this._angleY),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._startAngleX=a.rotationX,this._startAngleY=a.rotationY},update:function(a){a=this._computeEaseTime(a),this.target&&(this.target.rotationX=this._startAngleX+this._angleX*a,this.target.rotationY=this._startAngleY+this._angleY*a)},reverse:function(){var a=new cc.RotateBy(this._duration,-this._angleX,-this._angleY);return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.rotateBy=function(a,b,c){return new cc.RotateBy(a,b,c)},cc.RotateBy.create=cc.rotateBy,cc.MoveBy=cc.ActionInterval.extend({_positionDelta:null,_startPosition:null,_previousPosition:null,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this),this._positionDelta=cc.p(0,0),this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(void 0!==b.x&&(c=b.y,b=b.x),this._positionDelta.x=b,this._positionDelta.y=c,!0):!1},clone:function(){var a=new cc.MoveBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._positionDelta),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.getPositionX(),c=a.getPositionY();this._previousPosition.x=b,this._previousPosition.y=c,this._startPosition.x=b,this._startPosition.y=c},update:function(a){if(a=this._computeEaseTime(a),this.target){var b=this._positionDelta.x*a,c=this._positionDelta.y*a,d=this._startPosition;if(cc.ENABLE_STACKABLE_ACTIONS){var e=this.target.getPositionX(),f=this.target.getPositionY(),g=this._previousPosition;d.x=d.x+e-g.x,d.y=d.y+f-g.y,b+=d.x,c+=d.y,g.x=b,g.y=c,this.target.setPosition(b,c)}else this.target.setPosition(d.x+b,d.y+c)}},reverse:function(){var a=new cc.MoveBy(this._duration,cc.p(-this._positionDelta.x,-this._positionDelta.y));return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.moveBy=function(a,b,c){return new cc.MoveBy(a,b,c)},cc.MoveBy.create=cc.moveBy,cc.MoveTo=cc.MoveBy.extend({_endPosition:null,ctor:function(a,b,c){cc.MoveBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.MoveBy.prototype.initWithDuration.call(this,a,b,c)?(void 0!==b.x&&(c=b.y,b=b.x),this._endPosition.x=b,this._endPosition.y=c,!0):!1},clone:function(){var a=new cc.MoveTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endPosition),a},startWithTarget:function(a){cc.MoveBy.prototype.startWithTarget.call(this,a),this._positionDelta.x=this._endPosition.x-a.getPositionX(),this._positionDelta.y=this._endPosition.y-a.getPositionY()}}),cc.moveTo=function(a,b,c){return new cc.MoveTo(a,b,c)},cc.MoveTo.create=cc.moveTo,cc.SkewTo=cc.ActionInterval.extend({_skewX:0,_skewY:0,_startSkewX:0,_startSkewY:0,_endSkewX:0,_endSkewY:0,_deltaX:0,_deltaY:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this),void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){var d=!1;return cc.ActionInterval.prototype.initWithDuration.call(this,a)&&(this._endSkewX=b,this._endSkewY=c,d=!0),d},clone:function(){var a=new cc.SkewTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endSkewX,this._endSkewY),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._startSkewX=a.skewX%180,this._deltaX=this._endSkewX-this._startSkewX,this._deltaX>180&&(this._deltaX-=360),this._deltaX<-180&&(this._deltaX+=360),this._startSkewY=a.skewY%360,this._deltaY=this._endSkewY-this._startSkewY,this._deltaY>180&&(this._deltaY-=360),this._deltaY<-180&&(this._deltaY+=360)},update:function(a){a=this._computeEaseTime(a),this.target.skewX=this._startSkewX+this._deltaX*a,this.target.skewY=this._startSkewY+this._deltaY*a}}),cc.skewTo=function(a,b,c){return new cc.SkewTo(a,b,c)},cc.SkewTo.create=cc.skewTo,cc.SkewBy=cc.SkewTo.extend({ctor:function(a,b,c){cc.SkewTo.prototype.ctor.call(this),void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){var d=!1;return cc.SkewTo.prototype.initWithDuration.call(this,a,b,c)&&(this._skewX=b,this._skewY=c,d=!0),d},clone:function(){var a=new cc.SkewBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._skewX,this._skewY),a},startWithTarget:function(a){cc.SkewTo.prototype.startWithTarget.call(this,a),this._deltaX=this._skewX,this._deltaY=this._skewY,this._endSkewX=this._startSkewX+this._deltaX,this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){var a=new cc.SkewBy(this._duration,-this._skewX,-this._skewY);return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.skewBy=function(a,b,c){return new cc.SkewBy(a,b,c)},cc.SkewBy.create=cc.skewBy,cc.JumpBy=cc.ActionInterval.extend({_startPosition:null,_delta:null,_height:0,_jumps:0,_previousPosition:null,ctor:function(a,b,c,d,e){cc.ActionInterval.prototype.ctor.call(this),this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),this._delta=cc.p(0,0),void 0!==d&&this.initWithDuration(a,b,c,d,e)},initWithDuration:function(a,b,c,d,e){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(void 0===e&&(e=d,d=c,c=b.y,b=b.x),this._delta.x=b,this._delta.y=c,this._height=d,this._jumps=e,!0):!1},clone:function(){var a=new cc.JumpBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._delta,this._height,this._jumps),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.getPositionX(),c=a.getPositionY();this._previousPosition.x=b,this._previousPosition.y=c,this._startPosition.x=b,this._startPosition.y=c},update:function(a){if(a=this._computeEaseTime(a),this.target){var b=a*this._jumps%1,c=4*this._height*b*(1-b);c+=this._delta.y*a;var d=this._delta.x*a,e=this._startPosition;if(cc.ENABLE_STACKABLE_ACTIONS){var f=this.target.getPositionX(),g=this.target.getPositionY(),h=this._previousPosition;e.x=e.x+f-h.x,e.y=e.y+g-h.y,d+=e.x,c+=e.y,h.x=d,h.y=c,this.target.setPosition(d,c)}else this.target.setPosition(e.x+d,e.y+c)}},reverse:function(){var a=new cc.JumpBy(this._duration,cc.p(-this._delta.x,-this._delta.y),this._height,this._jumps);return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.jumpBy=function(a,b,c,d,e){return new cc.JumpBy(a,b,c,d,e)},cc.JumpBy.create=cc.jumpBy,cc.JumpTo=cc.JumpBy.extend({_endPosition:null,ctor:function(a,b,c,d,e){cc.JumpBy.prototype.ctor.call(this),this._endPosition=cc.p(0,0),void 0!==d&&this.initWithDuration(a,b,c,d,e)},initWithDuration:function(a,b,c,d,e){return cc.JumpBy.prototype.initWithDuration.call(this,a,b,c,d,e)?(void 0===e&&(c=b.y,b=b.x),this._endPosition.x=b,this._endPosition.y=c,!0):!1},startWithTarget:function(a){cc.JumpBy.prototype.startWithTarget.call(this,a),this._delta.x=this._endPosition.x-this._startPosition.x,this._delta.y=this._endPosition.y-this._startPosition.y},clone:function(){var a=new cc.JumpTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._endPosition,this._height,this._jumps),a}}),cc.jumpTo=function(a,b,c,d,e){return new cc.JumpTo(a,b,c,d,e)},cc.JumpTo.create=cc.jumpTo,cc.bezierAt=function(a,b,c,d,e){return Math.pow(1-e,3)*a+3*e*Math.pow(1-e,2)*b+3*Math.pow(e,2)*(1-e)*c+Math.pow(e,3)*d},cc.BezierBy=cc.ActionInterval.extend({_config:null,_startPosition:null,_previousPosition:null,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this),this._config=[],this._startPosition=cc.p(0,0),this._previousPosition=cc.p(0,0),b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._config=b,!0):!1},clone:function(){var a=new cc.BezierBy;this._cloneDecoration(a);for(var b=[],c=0;cb/2}},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._originalState=a.visible},stop:function(){this.target.visible=this._originalState,cc.ActionInterval.prototype.stop.call(this)},reverse:function(){var a=new cc.Blink(this._duration,this._times);return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.blink=function(a,b){return new cc.Blink(a,b); +},cc.Blink.create=cc.blink,cc.FadeTo=cc.ActionInterval.extend({_toOpacity:0,_fromOpacity:0,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this),void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._toOpacity=b,!0):!1},clone:function(){var a=new cc.FadeTo;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toOpacity),a},update:function(a){a=this._computeEaseTime(a);var b=void 0!==this._fromOpacity?this._fromOpacity:255;this.target.opacity=b+(this._toOpacity-b)*a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._fromOpacity=a.opacity}}),cc.fadeTo=function(a,b){return new cc.FadeTo(a,b)},cc.FadeTo.create=cc.fadeTo,cc.FadeIn=cc.FadeTo.extend({_reverseAction:null,ctor:function(a){cc.FadeTo.prototype.ctor.call(this),null==a&&(a=0),this.initWithDuration(a,255)},reverse:function(){var a=new cc.FadeOut;return a.initWithDuration(this._duration,0),this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.FadeIn;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toOpacity),a},startWithTarget:function(a){this._reverseAction&&(this._toOpacity=this._reverseAction._fromOpacity),cc.FadeTo.prototype.startWithTarget.call(this,a)}}),cc.fadeIn=function(a){return new cc.FadeIn(a)},cc.FadeIn.create=cc.fadeIn,cc.FadeOut=cc.FadeTo.extend({ctor:function(a){cc.FadeTo.prototype.ctor.call(this),null==a&&(a=0),this.initWithDuration(a,0)},reverse:function(){var a=new cc.FadeIn;return a._reverseAction=this,a.initWithDuration(this._duration,255),this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.FadeOut;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._toOpacity),a}}),cc.fadeOut=function(a){return new cc.FadeOut(a)},cc.FadeOut.create=cc.fadeOut,cc.TintTo=cc.ActionInterval.extend({_to:null,_from:null,ctor:function(a,b,c,d){cc.ActionInterval.prototype.ctor.call(this),this._to=cc.color(0,0,0),this._from=cc.color(0,0,0),void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=cc.color(b,c,d),!0):!1},clone:function(){var a=new cc.TintTo;this._cloneDecoration(a);var b=this._to;return a.initWithDuration(this._duration,b.r,b.g,b.b),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._from=this.target.color},update:function(a){a=this._computeEaseTime(a);var b=this._from,c=this._to;b&&this.target.setColor(cc.color(b.r+(c.r-b.r)*a,b.g+(c.g-b.g)*a,b.b+(c.b-b.b)*a))}}),cc.tintTo=function(a,b,c,d){return new cc.TintTo(a,b,c,d)},cc.TintTo.create=cc.tintTo,cc.TintBy=cc.ActionInterval.extend({_deltaR:0,_deltaG:0,_deltaB:0,_fromR:0,_fromG:0,_fromB:0,ctor:function(a,b,c,d){cc.ActionInterval.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._deltaR=b,this._deltaG=c,this._deltaB=d,!0):!1},clone:function(){var a=new cc.TintBy;return this._cloneDecoration(a),a.initWithDuration(this._duration,this._deltaR,this._deltaG,this._deltaB),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);var b=a.color;this._fromR=b.r,this._fromG=b.g,this._fromB=b.b},update:function(a){a=this._computeEaseTime(a),this.target.color=cc.color(this._fromR+this._deltaR*a,this._fromG+this._deltaG*a,this._fromB+this._deltaB*a)},reverse:function(){var a=new cc.TintBy(this._duration,-this._deltaR,-this._deltaG,-this._deltaB);return this._cloneDecoration(a),this._reverseEaseList(a),a}}),cc.tintBy=function(a,b,c,d){return new cc.TintBy(a,b,c,d)},cc.TintBy.create=cc.tintBy,cc.DelayTime=cc.ActionInterval.extend({update:function(a){},reverse:function(){var a=new cc.DelayTime(this._duration);return this._cloneDecoration(a),this._reverseEaseList(a),a},clone:function(){var a=new cc.DelayTime;return this._cloneDecoration(a),a.initWithDuration(this._duration),a}}),cc.delayTime=function(a){return new cc.DelayTime(a)},cc.DelayTime.create=cc.delayTime,cc.ReverseTime=cc.ActionInterval.extend({_other:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this),this._other=null,a&&this.initWithAction(a)},initWithAction:function(a){if(!a)throw new Error("cc.ReverseTime.initWithAction(): action must be non null");if(a===this._other)throw new Error("cc.ReverseTime.initWithAction(): the action was already passed in.");return cc.ActionInterval.prototype.initWithDuration.call(this,a._duration)?(this._other=a,!0):!1},clone:function(){var a=new cc.ReverseTime;return this._cloneDecoration(a),a.initWithAction(this._other.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._other.startWithTarget(a)},update:function(a){a=this._computeEaseTime(a),this._other&&this._other.update(1-a)},reverse:function(){return this._other.clone()},stop:function(){this._other.stop(),cc.Action.prototype.stop.call(this)}}),cc.reverseTime=function(a){return new cc.ReverseTime(a)},cc.ReverseTime.create=cc.reverseTime,cc.Animate=cc.ActionInterval.extend({_animation:null,_nextFrame:0,_origFrame:null,_executedLoops:0,_splitTimes:null,_currFrameIndex:0,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this),this._splitTimes=[],a&&this.initWithAnimation(a)},getAnimation:function(){return this._animation},setAnimation:function(a){this._animation=a},getCurrentFrameIndex:function(){return this._currFrameIndex},initWithAnimation:function(a){if(!a)throw new Error("cc.Animate.initWithAnimation(): animation must be non-NULL");var b=a.getDuration();if(this.initWithDuration(b*a.getLoops())){this._nextFrame=0,this.setAnimation(a),this._origFrame=null,this._executedLoops=0;var c=this._splitTimes;c.length=0;var d=0,e=b/a.getTotalDelayUnits(),f=a.getFrames();cc.arrayVerifyType(f,cc.AnimationFrame);for(var g=0;ga){a*=this._animation.getLoops();var b=0|a;b>this._executedLoops&&(this._nextFrame=0,this._executedLoops++),a%=1}for(var c=this._animation.getFrames(),d=c.length,e=this._splitTimes,f=this._nextFrame;d>f&&e[f]<=a;f++)_currFrameIndex=f,this.target.setSpriteFrame(c[_currFrameIndex].getSpriteFrame()),this._nextFrame=f+1},reverse:function(){var a=this._animation,b=a.getFrames(),c=[];if(cc.arrayVerifyType(b,cc.AnimationFrame),b.length>0)for(var d=b.length-1;d>=0;d--){var e=b[d];if(!e)break;c.push(e.clone())}var f=new cc.Animation(c,a.getDelayPerUnit(),a.getLoops());f.setRestoreOriginalFrame(a.getRestoreOriginalFrame());var g=new cc.Animate(f);return this._cloneDecoration(g),this._reverseEaseList(g),g},stop:function(){this._animation.getRestoreOriginalFrame()&&this.target&&this.target.setSpriteFrame(this._origFrame),cc.Action.prototype.stop.call(this)}}),cc.animate=function(a){return new cc.Animate(a)},cc.Animate.create=cc.animate,cc.TargetedAction=cc.ActionInterval.extend({_action:null,_forcedTarget:null,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this),b&&this.initWithTarget(a,b)},initWithTarget:function(a,b){return this.initWithDuration(b._duration)?(this._forcedTarget=a,this._action=b,!0):!1},clone:function(){var a=new cc.TargetedAction;return this._cloneDecoration(a),a.initWithTarget(this._forcedTarget,this._action.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._action.startWithTarget(this._forcedTarget)},stop:function(){this._action.stop()},update:function(a){a=this._computeEaseTime(a),this._action.update(a)},getForcedTarget:function(){return this._forcedTarget},setForcedTarget:function(a){this._forcedTarget!==a&&(this._forcedTarget=a)}}),cc.targetedAction=function(a,b){return new cc.TargetedAction(a,b)},cc.TargetedAction.create=cc.targetedAction,cc.ActionInstant=cc.FiniteTimeAction.extend({isDone:function(){return!0},step:function(a){this.update(1)},update:function(a){},reverse:function(){return this.clone()},clone:function(){return new cc.ActionInstant}}),cc.Show=cc.ActionInstant.extend({update:function(a){this.target.visible=!0},reverse:function(){return new cc.Hide},clone:function(){return new cc.Show}}),cc.show=function(){return new cc.Show},cc.Show.create=cc.show,cc.Hide=cc.ActionInstant.extend({update:function(a){this.target.visible=!1},reverse:function(){return new cc.Show},clone:function(){return new cc.Hide}}),cc.hide=function(){return new cc.Hide},cc.Hide.create=cc.hide,cc.ToggleVisibility=cc.ActionInstant.extend({update:function(a){this.target.visible=!this.target.visible},reverse:function(){return new cc.ToggleVisibility},clone:function(){return new cc.ToggleVisibility}}),cc.toggleVisibility=function(){return new cc.ToggleVisibility},cc.ToggleVisibility.create=cc.toggleVisibility,cc.RemoveSelf=cc.ActionInstant.extend({_isNeedCleanUp:!0,ctor:function(a){cc.FiniteTimeAction.prototype.ctor.call(this),void 0!==a&&this.init(a)},update:function(a){this.target.removeFromParent(this._isNeedCleanUp)},init:function(a){return this._isNeedCleanUp=a,!0},reverse:function(){return new cc.RemoveSelf(this._isNeedCleanUp)},clone:function(){return new cc.RemoveSelf(this._isNeedCleanUp)}}),cc.removeSelf=function(a){return new cc.RemoveSelf(a)},cc.RemoveSelf.create=cc.removeSelf,cc.FlipX=cc.ActionInstant.extend({_flippedX:!1,ctor:function(a){cc.FiniteTimeAction.prototype.ctor.call(this),this._flippedX=!1,void 0!==a&&this.initWithFlipX(a)},initWithFlipX:function(a){return this._flippedX=a,!0},update:function(a){this.target.flippedX=this._flippedX},reverse:function(){return new cc.FlipX(!this._flippedX)},clone:function(){var a=new cc.FlipX;return a.initWithFlipX(this._flippedX),a}}),cc.flipX=function(a){return new cc.FlipX(a)},cc.FlipX.create=cc.flipX,cc.FlipY=cc.ActionInstant.extend({_flippedY:!1,ctor:function(a){cc.FiniteTimeAction.prototype.ctor.call(this),this._flippedY=!1,void 0!==a&&this.initWithFlipY(a)},initWithFlipY:function(a){return this._flippedY=a,!0},update:function(a){this.target.flippedY=this._flippedY},reverse:function(){return new cc.FlipY(!this._flippedY)},clone:function(){var a=new cc.FlipY;return a.initWithFlipY(this._flippedY),a}}),cc.flipY=function(a){return new cc.FlipY(a)},cc.FlipY.create=cc.flipY,cc.Place=cc.ActionInstant.extend({_x:0,_y:0,ctor:function(a,b){cc.FiniteTimeAction.prototype.ctor.call(this),this._x=0,this._y=0,void 0!==a&&(void 0!==a.x&&(b=a.y,a=a.x),this.initWithPosition(a,b))},initWithPosition:function(a,b){return this._x=a,this._y=b,!0},update:function(a){this.target.setPosition(this._x,this._y)},clone:function(){var a=new cc.Place;return a.initWithPosition(this._x,this._y),a}}),cc.place=function(a,b){return new cc.Place(a,b)},cc.Place.create=cc.place,cc.CallFunc=cc.ActionInstant.extend({_selectorTarget:null,_function:null,_data:null,ctor:function(a,b,c){cc.FiniteTimeAction.prototype.ctor.call(this),this.initWithFunction(a,b,c)},initWithFunction:function(a,b,c){return a&&(this._function=a),b&&(this._selectorTarget=b),void 0!==c&&(this._data=c),!0},execute:function(){this._function&&this._function.call(this._selectorTarget,this.target,this._data)},update:function(a){this.execute()},getTargetCallback:function(){return this._selectorTarget},setTargetCallback:function(a){a!==this._selectorTarget&&(this._selectorTarget&&(this._selectorTarget=null),this._selectorTarget=a)},clone:function(){var a=new cc.CallFunc;return a.initWithFunction(this._function,this._selectorTarget,this._data),a}}),cc.callFunc=function(a,b,c){return new cc.CallFunc(a,b,c)},cc.CallFunc.create=cc.callFunc,cc.ActionCamera=cc.ActionInterval.extend({_centerXOrig:0,_centerYOrig:0,_centerZOrig:0,_eyeXOrig:0,_eyeYOrig:0,_eyeZOrig:0,_upXOrig:0,_upYOrig:0,_upZOrig:0,ctor:function(){var a=this;cc.ActionInterval.prototype.ctor.call(a),a._centerXOrig=0,a._centerYOrig=0,a._centerZOrig=0,a._eyeXOrig=0,a._eyeYOrig=0,a._eyeZOrig=0,a._upXOrig=0,a._upYOrig=0,a._upZOrig=0},startWithTarget:function(a){var b=this;cc.ActionInterval.prototype.startWithTarget.call(b,a);var c=a.getCamera(),d=c.getCenter();b._centerXOrig=d.x,b._centerYOrig=d.y,b._centerZOrig=d.z;var e=c.getEye();b._eyeXOrig=e.x,b._eyeYOrig=e.y,b._eyeZOrig=e.z;var f=c.getUp();b._upXOrig=f.x,b._upYOrig=f.y,b._upZOrig=f.z},clone:function(){return new cc.ActionCamera},reverse:function(){return new cc.ReverseTime(this)}}),cc.OrbitCamera=cc.ActionCamera.extend({_radius:0,_deltaRadius:0,_angleZ:0,_deltaAngleZ:0,_angleX:0,_deltaAngleX:0,_radZ:0,_radDeltaZ:0,_radX:0,_radDeltaX:0,ctor:function(a,b,c,d,e,f,g){cc.ActionCamera.prototype.ctor.call(this),void 0!==g&&this.initWithDuration(a,b,c,d,e,f,g)},initWithDuration:function(a,b,c,d,e,f,g){if(cc.ActionInterval.prototype.initWithDuration.call(this,a)){var h=this;return h._radius=b,h._deltaRadius=c,h._angleZ=d,h._deltaAngleZ=e,h._angleX=f,h._deltaAngleX=g,h._radDeltaZ=cc.degreesToRadians(e),h._radDeltaX=cc.degreesToRadians(g),!0}return!1},sphericalRadius:function(){var a,b,c,d=this.target.getCamera(),e=d.getEye(),f=d.getCenter(),g=e.x-f.x,h=e.y-f.y,i=e.z-f.z,j=Math.sqrt(Math.pow(g,2)+Math.pow(h,2)+Math.pow(i,2)),k=Math.sqrt(Math.pow(g,2)+Math.pow(h,2));return 0===k&&(k=cc.FLT_EPSILON),0===j&&(j=cc.FLT_EPSILON),b=Math.acos(i/j),c=0>g?Math.PI-Math.asin(h/k):Math.asin(h/k),a=j/cc.Camera.getZEye(),{newRadius:a,zenith:b,azimuth:c}},startWithTarget:function(a){var b=this;cc.ActionInterval.prototype.startWithTarget.call(b,a);var c=b.sphericalRadius();isNaN(b._radius)&&(b._radius=c.newRadius),isNaN(b._angleZ)&&(b._angleZ=cc.radiansToDegrees(c.zenith)),isNaN(b._angleX)&&(b._angleX=cc.radiansToDegrees(c.azimuth)),b._radZ=cc.degreesToRadians(b._angleZ),b._radX=cc.degreesToRadians(b._angleX)},clone:function(){var a=new cc.OrbitCamera,b=this;return a.initWithDuration(b._duration,b._radius,b._deltaRadius,b._angleZ,b._deltaAngleZ,b._angleX,b._deltaAngleX),a},update:function(a){a=this._computeEaseTime(a);var b=(this._radius+this._deltaRadius*a)*cc.Camera.getZEye(),c=this._radZ+this._radDeltaZ*a,d=this._radX+this._radDeltaX*a,e=Math.sin(c)*Math.cos(d)*b+this._centerXOrig,f=Math.sin(c)*Math.sin(d)*b+this._centerYOrig,g=Math.cos(c)*b+this._centerZOrig;this.target.getCamera().setEye(e,f,g),this.target.setNodeDirty()}}),cc.orbitCamera=function(a,b,c,d,e,f,g){return new cc.OrbitCamera(a,b,c,d,e,f,g)},cc.OrbitCamera.create=cc.orbitCamera,cc.ActionEase=cc.ActionInterval.extend({_inner:null,ctor:function(a){cc.ActionInterval.prototype.ctor.call(this),a&&this.initWithAction(a)},initWithAction:function(a){if(!a)throw new Error("cc.ActionEase.initWithAction(): action must be non nil");return this.initWithDuration(a.getDuration())?(this._inner=a,!0):!1},clone:function(){var a=new cc.ActionEase;return a.initWithAction(this._inner.clone()),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._inner.startWithTarget(this.target)},stop:function(){this._inner.stop(),cc.ActionInterval.prototype.stop.call(this)},update:function(a){this._inner.update(a)},reverse:function(){return new cc.ActionEase(this._inner.reverse())},getInnerAction:function(){return this._inner}}),cc.actionEase=function(a){return new cc.ActionEase(a)},cc.ActionEase.create=cc.actionEase,cc.EaseRateAction=cc.ActionEase.extend({_rate:0,ctor:function(a,b){cc.ActionEase.prototype.ctor.call(this),void 0!==b&&this.initWithAction(a,b)},setRate:function(a){this._rate=a},getRate:function(){return this._rate},initWithAction:function(a,b){return cc.ActionEase.prototype.initWithAction.call(this,a)?(this._rate=b,!0):!1},clone:function(){var a=new cc.EaseRateAction;return a.initWithAction(this._inner.clone(),this._rate),a},reverse:function(){return new cc.EaseRateAction(this._inner.reverse(),1/this._rate)}}),cc.easeRateAction=function(a,b){return new cc.EaseRateAction(a,b)},cc.EaseRateAction.create=cc.easeRateAction,cc.EaseIn=cc.EaseRateAction.extend({update:function(a){this._inner.update(Math.pow(a,this._rate))},reverse:function(){return new cc.EaseIn(this._inner.reverse(),1/this._rate)},clone:function(){var a=new cc.EaseIn;return a.initWithAction(this._inner.clone(),this._rate),a}}),cc.EaseIn.create=function(a,b){return new cc.EaseIn(a,b)},cc.easeIn=function(a){return{_rate:a,easing:function(a){return Math.pow(a,this._rate)},reverse:function(){return cc.easeIn(1/this._rate)}}},cc.EaseOut=cc.EaseRateAction.extend({update:function(a){this._inner.update(Math.pow(a,1/this._rate))},reverse:function(){return new cc.EaseOut(this._inner.reverse(),1/this._rate)},clone:function(){var a=new cc.EaseOut;return a.initWithAction(this._inner.clone(),this._rate),a}}),cc.EaseOut.create=function(a,b){return new cc.EaseOut(a,b)},cc.easeOut=function(a){return{_rate:a,easing:function(a){return Math.pow(a,1/this._rate)},reverse:function(){return cc.easeOut(1/this._rate)}}},cc.EaseInOut=cc.EaseRateAction.extend({update:function(a){a*=2,1>a?this._inner.update(.5*Math.pow(a,this._rate)):this._inner.update(1-.5*Math.pow(2-a,this._rate))},clone:function(){var a=new cc.EaseInOut;return a.initWithAction(this._inner.clone(),this._rate),a},reverse:function(){return new cc.EaseInOut(this._inner.reverse(),this._rate)}}),cc.EaseInOut.create=function(a,b){return new cc.EaseInOut(a,b)},cc.easeInOut=function(a){return{_rate:a,easing:function(a){return a*=2,1>a?.5*Math.pow(a,this._rate):1-.5*Math.pow(2-a,this._rate)},reverse:function(){return cc.easeInOut(this._rate)}}},cc.EaseExponentialIn=cc.ActionEase.extend({update:function(a){this._inner.update(0===a?0:Math.pow(2,10*(a-1)))},reverse:function(){return new cc.EaseExponentialOut(this._inner.reverse())},clone:function(){var a=new cc.EaseExponentialIn;return a.initWithAction(this._inner.clone()),a}}),cc.EaseExponentialIn.create=function(a){return new cc.EaseExponentialIn(a)},cc._easeExponentialInObj={easing:function(a){return 0===a?0:Math.pow(2,10*(a-1))},reverse:function(){return cc._easeExponentialOutObj}},cc.easeExponentialIn=function(){return cc._easeExponentialInObj},cc.EaseExponentialOut=cc.ActionEase.extend({update:function(a){this._inner.update(1===a?1:-Math.pow(2,-10*a)+1)},reverse:function(){return new cc.EaseExponentialIn(this._inner.reverse())},clone:function(){var a=new cc.EaseExponentialOut;return a.initWithAction(this._inner.clone()),a}}),cc.EaseExponentialOut.create=function(a){return new cc.EaseExponentialOut(a)},cc._easeExponentialOutObj={easing:function(a){return 1===a?1:-Math.pow(2,-10*a)+1},reverse:function(){return cc._easeExponentialInObj}},cc.easeExponentialOut=function(){return cc._easeExponentialOutObj},cc.EaseExponentialInOut=cc.ActionEase.extend({update:function(a){1!==a&&0!==a&&(a*=2,a=1>a?.5*Math.pow(2,10*(a-1)):.5*(-Math.pow(2,-10*(a-1))+2)),this._inner.update(a)},reverse:function(){return new cc.EaseExponentialInOut(this._inner.reverse())},clone:function(){var a=new cc.EaseExponentialInOut;return a.initWithAction(this._inner.clone()),a}}),cc.EaseExponentialInOut.create=function(a){return new cc.EaseExponentialInOut(a)},cc._easeExponentialInOutObj={easing:function(a){return 1!==a&&0!==a?(a*=2,1>a?.5*Math.pow(2,10*(a-1)):.5*(-Math.pow(2,-10*(a-1))+2)):a},reverse:function(){return cc._easeExponentialInOutObj}},cc.easeExponentialInOut=function(){return cc._easeExponentialInOutObj},cc.EaseSineIn=cc.ActionEase.extend({update:function(a){a=0===a||1===a?a:-1*Math.cos(a*Math.PI/2)+1,this._inner.update(a)},reverse:function(){return new cc.EaseSineOut(this._inner.reverse())},clone:function(){var a=new cc.EaseSineIn;return a.initWithAction(this._inner.clone()),a}}),cc.EaseSineIn.create=function(a){return new cc.EaseSineIn(a)},cc._easeSineInObj={easing:function(a){return 0===a||1===a?a:-1*Math.cos(a*Math.PI/2)+1},reverse:function(){return cc._easeSineOutObj}},cc.easeSineIn=function(){return cc._easeSineInObj},cc.EaseSineOut=cc.ActionEase.extend({update:function(a){a=0===a||1===a?a:Math.sin(a*Math.PI/2),this._inner.update(a)},reverse:function(){return new cc.EaseSineIn(this._inner.reverse())},clone:function(){var a=new cc.EaseSineOut;return a.initWithAction(this._inner.clone()),a}}),cc.EaseSineOut.create=function(a){return new cc.EaseSineOut(a)},cc._easeSineOutObj={easing:function(a){return 0===a||1===a?a:Math.sin(a*Math.PI/2)},reverse:function(){return cc._easeSineInObj}},cc.easeSineOut=function(){return cc._easeSineOutObj},cc.EaseSineInOut=cc.ActionEase.extend({update:function(a){a=0===a||1===a?a:-.5*(Math.cos(Math.PI*a)-1),this._inner.update(a)},clone:function(){var a=new cc.EaseSineInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseSineInOut(this._inner.reverse())}}),cc.EaseSineInOut.create=function(a){return new cc.EaseSineInOut(a)},cc._easeSineInOutObj={easing:function(a){return 0===a||1===a?a:-.5*(Math.cos(Math.PI*a)-1)},reverse:function(){return cc._easeSineInOutObj}},cc.easeSineInOut=function(){return cc._easeSineInOutObj},cc.EaseElastic=cc.ActionEase.extend({_period:.3,ctor:function(a,b){cc.ActionEase.prototype.ctor.call(this),a&&this.initWithAction(a,b)},getPeriod:function(){return this._period},setPeriod:function(a){this._period=a},initWithAction:function(a,b){return cc.ActionEase.prototype.initWithAction.call(this,a),this._period=null==b?.3:b,!0},reverse:function(){return cc.log("cc.EaseElastic.reverse(): it should be overridden in subclass."),null},clone:function(){var a=new cc.EaseElastic;return a.initWithAction(this._inner.clone(),this._period),a}}),cc.EaseElastic.create=function(a,b){return new cc.EaseElastic(a,b)},cc.EaseElasticIn=cc.EaseElastic.extend({update:function(a){var b=0;if(0===a||1===a)b=a;else{var c=this._period/4;a-=1,b=-Math.pow(2,10*a)*Math.sin((a-c)*Math.PI*2/this._period)}this._inner.update(b)},reverse:function(){return new cc.EaseElasticOut(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticIn;return a.initWithAction(this._inner.clone(),this._period),a}}),cc.EaseElasticIn.create=function(a,b){return new cc.EaseElasticIn(a,b)},cc._easeElasticInObj={easing:function(a){return 0===a||1===a?a:(a-=1,-Math.pow(2,10*a)*Math.sin((a-.075)*Math.PI*2/.3))},reverse:function(){return cc._easeElasticOutObj}},cc.easeElasticIn=function(a){return a&&.3!==a?{_period:a,easing:function(a){return 0===a||1===a?a:(a-=1,-Math.pow(2,10*a)*Math.sin((a-this._period/4)*Math.PI*2/this._period))},reverse:function(){return cc.easeElasticOut(this._period)}}:cc._easeElasticInObj},cc.EaseElasticOut=cc.EaseElastic.extend({update:function(a){var b=0;if(0===a||1===a)b=a;else{var c=this._period/4;b=Math.pow(2,-10*a)*Math.sin((a-c)*Math.PI*2/this._period)+1}this._inner.update(b)},reverse:function(){return new cc.EaseElasticIn(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticOut;return a.initWithAction(this._inner.clone(),this._period),a}}),cc.EaseElasticOut.create=function(a,b){return new cc.EaseElasticOut(a,b)},cc._easeElasticOutObj={easing:function(a){return 0===a||1===a?a:Math.pow(2,-10*a)*Math.sin((a-.075)*Math.PI*2/.3)+1},reverse:function(){return cc._easeElasticInObj}},cc.easeElasticOut=function(a){return a&&.3!==a?{_period:a,easing:function(a){return 0===a||1===a?a:Math.pow(2,-10*a)*Math.sin((a-this._period/4)*Math.PI*2/this._period)+1},reverse:function(){return cc.easeElasticIn(this._period)}}:cc._easeElasticOutObj},cc.EaseElasticInOut=cc.EaseElastic.extend({update:function(a){var b=0,c=this._period;if(0===a||1===a)b=a;else{a=2*a,c||(c=this._period=.3*1.5);var d=c/4;a-=1,b=0>a?-.5*Math.pow(2,10*a)*Math.sin((a-d)*Math.PI*2/c):Math.pow(2,-10*a)*Math.sin((a-d)*Math.PI*2/c)*.5+1}this._inner.update(b)},reverse:function(){return new cc.EaseElasticInOut(this._inner.reverse(),this._period)},clone:function(){var a=new cc.EaseElasticInOut;return a.initWithAction(this._inner.clone(),this._period),a}}),cc.EaseElasticInOut.create=function(a,b){return new cc.EaseElasticInOut(a,b)},cc.easeElasticInOut=function(a){return a=a||.3,{_period:a,easing:function(a){var b=0,c=this._period;if(0===a||1===a)b=a;else{a=2*a,c||(c=this._period=.3*1.5);var d=c/4;a-=1,b=0>a?-.5*Math.pow(2,10*a)*Math.sin((a-d)*Math.PI*2/c):Math.pow(2,-10*a)*Math.sin((a-d)*Math.PI*2/c)*.5+1}return b},reverse:function(){return cc.easeElasticInOut(this._period)}}},cc.EaseBounce=cc.ActionEase.extend({bounceTime:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?(a-=1.5/2.75,7.5625*a*a+.75):2.5/2.75>a?(a-=2.25/2.75,7.5625*a*a+.9375):(a-=2.625/2.75,7.5625*a*a+.984375)},clone:function(){var a=new cc.EaseBounce;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseBounce(this._inner.reverse())}}),cc.EaseBounce.create=function(a){return new cc.EaseBounce(a)},cc.EaseBounceIn=cc.EaseBounce.extend({update:function(a){var b=1-this.bounceTime(1-a);this._inner.update(b)},reverse:function(){return new cc.EaseBounceOut(this._inner.reverse())},clone:function(){var a=new cc.EaseBounceIn;return a.initWithAction(this._inner.clone()),a}}),cc.EaseBounceIn.create=function(a){return new cc.EaseBounceIn(a)},cc._bounceTime=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?(a-=1.5/2.75,7.5625*a*a+.75):2.5/2.75>a?(a-=2.25/2.75,7.5625*a*a+.9375):(a-=2.625/2.75,7.5625*a*a+.984375)},cc._easeBounceInObj={easing:function(a){return 1-cc._bounceTime(1-a)},reverse:function(){return cc._easeBounceOutObj}},cc.easeBounceIn=function(){return cc._easeBounceInObj},cc.EaseBounceOut=cc.EaseBounce.extend({update:function(a){var b=this.bounceTime(a);this._inner.update(b)},reverse:function(){return new cc.EaseBounceIn(this._inner.reverse())},clone:function(){var a=new cc.EaseBounceOut;return a.initWithAction(this._inner.clone()),a}}),cc.EaseBounceOut.create=function(a){return new cc.EaseBounceOut(a)},cc._easeBounceOutObj={easing:function(a){return cc._bounceTime(a)},reverse:function(){return cc._easeBounceInObj}},cc.easeBounceOut=function(){return cc._easeBounceOutObj},cc.EaseBounceInOut=cc.EaseBounce.extend({update:function(a){var b=0;.5>a?(a=2*a,b=.5*(1-this.bounceTime(1-a))):b=.5*this.bounceTime(2*a-1)+.5,this._inner.update(b)},clone:function(){var a=new cc.EaseBounceInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseBounceInOut(this._inner.reverse())}}),cc.EaseBounceInOut.create=function(a){return new cc.EaseBounceInOut(a)},cc._easeBounceInOutObj={easing:function(a){var b;return.5>a?(a=2*a,b=.5*(1-cc._bounceTime(1-a))):b=.5*cc._bounceTime(2*a-1)+.5,b},reverse:function(){return cc._easeBounceInOutObj}},cc.easeBounceInOut=function(){return cc._easeBounceInOutObj},cc.EaseBackIn=cc.ActionEase.extend({update:function(a){var b=1.70158;a=0===a||1===a?a:a*a*((b+1)*a-b),this._inner.update(a)},reverse:function(){return new cc.EaseBackOut(this._inner.reverse())},clone:function(){var a=new cc.EaseBackIn;return a.initWithAction(this._inner.clone()),a}}),cc.EaseBackIn.create=function(a){return new cc.EaseBackIn(a)},cc._easeBackInObj={easing:function(a){var b=1.70158;return 0===a||1===a?a:a*a*((b+1)*a-b)},reverse:function(){return cc._easeBackOutObj}},cc.easeBackIn=function(){return cc._easeBackInObj},cc.EaseBackOut=cc.ActionEase.extend({update:function(a){var b=1.70158;a-=1,this._inner.update(a*a*((b+1)*a+b)+1)},reverse:function(){return new cc.EaseBackIn(this._inner.reverse())},clone:function(){var a=new cc.EaseBackOut;return a.initWithAction(this._inner.clone()),a}}),cc.EaseBackOut.create=function(a){return new cc.EaseBackOut(a)},cc._easeBackOutObj={easing:function(a){var b=1.70158;return a-=1,a*a*((b+1)*a+b)+1},reverse:function(){return cc._easeBackInObj}},cc.easeBackOut=function(){return cc._easeBackOutObj},cc.EaseBackInOut=cc.ActionEase.extend({update:function(a){var b=2.5949095;a=2*a,1>a?this._inner.update(a*a*((b+1)*a-b)/2):(a-=2,this._inner.update(a*a*((b+1)*a+b)/2+1))},clone:function(){var a=new cc.EaseBackInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseBackInOut(this._inner.reverse())}}),cc.EaseBackInOut.create=function(a){return new cc.EaseBackInOut(a)},cc._easeBackInOutObj={easing:function(a){var b=2.5949095;return a=2*a,1>a?a*a*((b+1)*a-b)/2:(a-=2,a*a*((b+1)*a+b)/2+1)},reverse:function(){return cc._easeBackInOutObj}},cc.easeBackInOut=function(){return cc._easeBackInOutObj},cc.EaseBezierAction=cc.ActionEase.extend({_p0:null,_p1:null,_p2:null,_p3:null,ctor:function(a){cc.ActionEase.prototype.ctor.call(this,a)},_updateTime:function(a,b,c,d,e){return Math.pow(1-e,3)*a+3*e*Math.pow(1-e,2)*b+3*Math.pow(e,2)*(1-e)*c+Math.pow(e,3)*d},update:function(a){var b=this._updateTime(this._p0,this._p1,this._p2,this._p3,a);this._inner.update(b)},clone:function(){var a=new cc.EaseBezierAction;return a.initWithAction(this._inner.clone()),a.setBezierParamer(this._p0,this._p1,this._p2,this._p3),a},reverse:function(){var a=new cc.EaseBezierAction(this._inner.reverse());return a.setBezierParamer(this._p3,this._p2,this._p1,this._p0),a},setBezierParamer:function(a,b,c,d){this._p0=a||0,this._p1=b||0,this._p2=c||0,this._p3=d||0}}),cc.EaseBezierAction.create=function(a){return new cc.EaseBezierAction(a)},cc.easeBezierAction=function(a,b,c,d){return{easing:function(e){return cc.EaseBezierAction.prototype._updateTime(a,b,c,d,e)},reverse:function(){return cc.easeBezierAction(d,c,b,a)}}},cc.EaseQuadraticActionIn=cc.ActionEase.extend({_updateTime:function(a){return Math.pow(a,2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuadraticActionIn(this._inner.reverse())}}),cc.EaseQuadraticActionIn.create=function(a){return new cc.EaseQuadraticActionIn(a)},cc._easeQuadraticActionIn={easing:cc.EaseQuadraticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionIn}},cc.easeQuadraticActionIn=function(){return cc._easeQuadraticActionIn},cc.EaseQuadraticActionOut=cc.ActionEase.extend({_updateTime:function(a){return-a*(a-2)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionOut;return a.initWithAction(),a},reverse:function(){return new cc.EaseQuadraticActionOut(this._inner.reverse())}}),cc.EaseQuadraticActionOut.create=function(a){return new cc.EaseQuadraticActionOut(a)},cc._easeQuadraticActionOut={easing:cc.EaseQuadraticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionOut}},cc.easeQuadraticActionOut=function(){return cc._easeQuadraticActionOut},cc.EaseQuadraticActionInOut=cc.ActionEase.extend({_updateTime:function(a){var b=a;return a*=2,1>a?b=a*a*.5:(--a,b=-.5*(a*(a-2)-1)),b},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuadraticActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuadraticActionInOut(this._inner.reverse())}}),cc.EaseQuadraticActionInOut.create=function(a){return new cc.EaseQuadraticActionInOut(a)},cc._easeQuadraticActionInOut={easing:cc.EaseQuadraticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuadraticActionInOut}},cc.easeQuadraticActionInOut=function(){return cc._easeQuadraticActionInOut},cc.EaseQuarticActionIn=cc.ActionEase.extend({_updateTime:function(a){return a*a*a*a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuarticActionIn(this._inner.reverse())}}),cc.EaseQuarticActionIn.create=function(a){return new cc.EaseQuarticActionIn(a)},cc._easeQuarticActionIn={easing:cc.EaseQuarticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuarticActionIn}},cc.easeQuarticActionIn=function(){return cc._easeQuarticActionIn},cc.EaseQuarticActionOut=cc.ActionEase.extend({ +_updateTime:function(a){return a-=1,-(a*a*a*a-1)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuarticActionOut(this._inner.reverse())}}),cc.EaseQuarticActionOut.create=function(a){return new cc.EaseQuarticActionOut(a)},cc._easeQuarticActionOut={easing:cc.EaseQuarticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuarticActionOut}},cc.easeQuarticActionOut=function(){return cc._easeQuarticActionOut},cc.EaseQuarticActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a=2*a,1>a?.5*a*a*a*a:(a-=2,-.5*(a*a*a*a-2))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuarticActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuarticActionInOut(this._inner.reverse())}}),cc.EaseQuarticActionInOut.create=function(a){return new cc.EaseQuarticActionInOut(a)},cc._easeQuarticActionInOut={easing:cc.EaseQuarticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuarticActionInOut}},cc.easeQuarticActionInOut=function(){return cc._easeQuarticActionInOut},cc.EaseQuinticActionIn=cc.ActionEase.extend({_updateTime:function(a){return a*a*a*a*a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuinticActionIn(this._inner.reverse())}}),cc.EaseQuinticActionIn.create=function(a){return new cc.EaseQuinticActionIn(a)},cc._easeQuinticActionIn={easing:cc.EaseQuinticActionIn.prototype._updateTime,reverse:function(){return cc._easeQuinticActionIn}},cc.easeQuinticActionIn=function(){return cc._easeQuinticActionIn},cc.EaseQuinticActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,a*a*a*a*a+1},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuinticActionOut(this._inner.reverse())}}),cc.EaseQuinticActionOut.create=function(a){return new cc.EaseQuinticActionOut(a)},cc._easeQuinticActionOut={easing:cc.EaseQuinticActionOut.prototype._updateTime,reverse:function(){return cc._easeQuinticActionOut}},cc.easeQuinticActionOut=function(){return cc._easeQuinticActionOut},cc.EaseQuinticActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a=2*a,1>a?.5*a*a*a*a*a:(a-=2,.5*(a*a*a*a*a+2))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseQuinticActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseQuinticActionInOut(this._inner.reverse())}}),cc.EaseQuinticActionInOut.create=function(a){return new cc.EaseQuinticActionInOut(a)},cc._easeQuinticActionInOut={easing:cc.EaseQuinticActionInOut.prototype._updateTime,reverse:function(){return cc._easeQuinticActionInOut}},cc.easeQuinticActionInOut=function(){return cc._easeQuinticActionInOut},cc.EaseCircleActionIn=cc.ActionEase.extend({_updateTime:function(a){return-1*(Math.sqrt(1-a*a)-1)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCircleActionIn(this._inner.reverse())}}),cc.EaseCircleActionIn.create=function(a){return new cc.EaseCircleActionIn(a)},cc._easeCircleActionIn={easing:cc.EaseCircleActionIn.prototype._updateTime,reverse:function(){return cc._easeCircleActionIn}},cc.easeCircleActionIn=function(){return cc._easeCircleActionIn},cc.EaseCircleActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,Math.sqrt(1-a*a)},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCircleActionOut(this._inner.reverse())}}),cc.EaseCircleActionOut.create=function(a){return new cc.EaseCircleActionOut(a)},cc._easeCircleActionOut={easing:cc.EaseCircleActionOut.prototype._updateTime,reverse:function(){return cc._easeCircleActionOut}},cc.easeCircleActionOut=function(){return cc._easeCircleActionOut},cc.EaseCircleActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a=2*a,1>a?-.5*(Math.sqrt(1-a*a)-1):(a-=2,.5*(Math.sqrt(1-a*a)+1))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCircleActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCircleActionInOut(this._inner.reverse())}}),cc.EaseCircleActionInOut.create=function(a){return new cc.EaseCircleActionInOut(a)},cc._easeCircleActionInOut={easing:cc.EaseCircleActionInOut.prototype._updateTime,reverse:function(){return cc._easeCircleActionInOut}},cc.easeCircleActionInOut=function(){return cc._easeCircleActionInOut},cc.EaseCubicActionIn=cc.ActionEase.extend({_updateTime:function(a){return a*a*a},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionIn;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCubicActionIn(this._inner.reverse())}}),cc.EaseCubicActionIn.create=function(a){return new cc.EaseCubicActionIn(a)},cc._easeCubicActionIn={easing:cc.EaseCubicActionIn.prototype._updateTime,reverse:function(){return cc._easeCubicActionIn}},cc.easeCubicActionIn=function(){return cc._easeCubicActionIn},cc.EaseCubicActionOut=cc.ActionEase.extend({_updateTime:function(a){return a-=1,a*a*a+1},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCubicActionOut(this._inner.reverse())}}),cc.EaseCubicActionOut.create=function(a){return new cc.EaseCubicActionOut(a)},cc._easeCubicActionOut={easing:cc.EaseCubicActionOut.prototype._updateTime,reverse:function(){return cc._easeCubicActionOut}},cc.easeCubicActionOut=function(){return cc._easeCubicActionOut},cc.EaseCubicActionInOut=cc.ActionEase.extend({_updateTime:function(a){return a=2*a,1>a?.5*a*a*a:(a-=2,.5*(a*a*a+2))},update:function(a){this._inner.update(this._updateTime(a))},clone:function(){var a=new cc.EaseCubicActionInOut;return a.initWithAction(this._inner.clone()),a},reverse:function(){return new cc.EaseCubicActionInOut(this._inner.reverse())}}),cc.EaseCubicActionInOut.create=function(a){return new cc.EaseCubicActionInOut(a)},cc._easeCubicActionInOut={easing:cc.EaseCubicActionInOut.prototype._updateTime,reverse:function(){return cc._easeCubicActionInOut}},cc.easeCubicActionInOut=function(){return cc._easeCubicActionInOut},cc.cardinalSplineAt=function(a,b,c,d,e,f){var g=f*f,h=g*f,i=(1-e)/2,j=i*(-h+2*g-f),k=i*(-h+g)+(2*h-3*g+1),l=i*(h-2*g+f)+(-2*h+3*g),m=i*(h-g),n=a.x*j+b.x*k+c.x*l+d.x*m,o=a.y*j+b.y*k+c.y*l+d.y*m;return cc.p(n,o)},cc.reverseControlPoints=function(a){for(var b=[],c=a.length-1;c>=0;c--)b.push(cc.p(a[c].x,a[c].y));return b},cc.cloneControlPoints=function(a){for(var b=[],c=0;cd;++d){var e=a[d];a[d]=a[b-d-1],a[b-d-1]=e}},cc.CardinalSplineTo=cc.ActionInterval.extend({_points:null,_deltaT:0,_tension:0,_previousPosition:null,_accumulatedDiff:null,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this),this._points=[],void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){if(!b||0===b.length)throw new Error("Invalid configuration. It must at least have one control point");return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this.setPoints(b),this._tension=c,!0):!1},clone:function(){var a=new cc.CardinalSplineTo;return a.initWithDuration(this._duration,cc.copyControlPoints(this._points),this._tension),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._deltaT=1/(this._points.length-1),this._previousPosition=cc.p(this.target.getPositionX(),this.target.getPositionY()),this._accumulatedDiff=cc.p(0,0)},update:function(a){a=this._computeEaseTime(a);var b,c,d=this._points;if(1===a)b=d.length-1,c=1;else{var e=this._deltaT;b=0|a/e,c=(a-e*b)/e}var f=cc.cardinalSplineAt(cc.getControlPointAt(d,b-1),cc.getControlPointAt(d,b-0),cc.getControlPointAt(d,b+1),cc.getControlPointAt(d,b+2),this._tension,c);if(cc.ENABLE_STACKABLE_ACTIONS){var g,h;if(g=this.target.getPositionX()-this._previousPosition.x,h=this.target.getPositionY()-this._previousPosition.y,0!==g||0!==h){var i=this._accumulatedDiff;g=i.x+g,h=i.y+h,i.x=g,i.y=h,f.x+=g,f.y+=h}}this.updatePosition(f)},reverse:function(){var a=cc.reverseControlPoints(this._points);return cc.cardinalSplineTo(this._duration,a,this._tension)},updatePosition:function(a){this.target.setPosition(a),this._previousPosition=a},getPoints:function(){return this._points},setPoints:function(a){this._points=a}}),cc.cardinalSplineTo=function(a,b,c){return new cc.CardinalSplineTo(a,b,c)},cc.CardinalSplineTo.create=cc.cardinalSplineTo,cc.CardinalSplineBy=cc.CardinalSplineTo.extend({_startPosition:null,ctor:function(a,b,c){cc.CardinalSplineTo.prototype.ctor.call(this),this._startPosition=cc.p(0,0),void 0!==c&&this.initWithDuration(a,b,c)},startWithTarget:function(a){cc.CardinalSplineTo.prototype.startWithTarget.call(this,a),this._startPosition.x=a.getPositionX(),this._startPosition.y=a.getPositionY()},reverse:function(){for(var a,b=this._points.slice(),c=b[0],d=1;dc?window.__audioSupport={MULTI_CHANNEL:!1,WEB_AUDIO:!0,AUTOPLAY:!1}:42===c&&(window.__audioSupport.NEED_MANUAL_LOOP=!0);break;case b.BROWSER_TYPE_MIUI:cc.sys.isMobile&&(c=c.match(/\d+/g),(c[0]<2||2===c[0]&&0===c[1]&&c[2]<=1)&&(window.__audioSupport.AUTOPLAY=!1))}a&&setTimeout(function(){cc.log("browse type: "+b.browserType),cc.log("browse version: "+c),cc.log("MULTI_CHANNEL: "+window.__audioSupport.MULTI_CHANNEL),cc.log("WEB_AUDIO: "+window.__audioSupport.WEB_AUDIO),cc.log("AUTOPLAY: "+window.__audioSupport.AUTOPLAY)},0)}(),cc.Audio=cc.Class.extend({volume:1,loop:!1,src:null,_touch:!1,_playing:!1,_AUDIO_TYPE:"AUDIO",_pause:!1,_buffer:null,_currentSource:null,_startTime:null,_currentTime:null,_context:null,_volume:null,_ignoreEnded:!1,_manualLoop:!1,_element:null,ctor:function(a,b,c){a&&(this._context=a),b&&(this._volume=b),a&&b&&(this._AUDIO_TYPE="WEBAUDIO"),this.src=c},_setBufferCallback:null,setBuffer:function(a){if(a){var b=this._playing;this._AUDIO_TYPE="WEBAUDIO",this._buffer&&this._buffer!==a&&this.getPlaying()&&this.stop(),this._buffer=a,b&&this.play(),this._volume.gain.value=this.volume,this._setBufferCallback&&this._setBufferCallback(a)}},_setElementCallback:null,setElement:function(a){if(a){var b=this._playing;this._AUDIO_TYPE="AUDIO",this._element&&this._element!==a&&this.getPlaying()&&this.stop(),this._element=a,b&&this.play(),a.volume=this.volume,a.loop=this.loop,this._setElementCallback&&this._setElementCallback(a)}},play:function(a,b){this._playing=!0,this.loop=void 0===b?this.loop:b,"AUDIO"===this._AUDIO_TYPE?this._playOfAudio(a):this._playOfWebAudio(a)},getPlaying:function(){if(!this._playing)return!1;if("AUDIO"===this._AUDIO_TYPE){var a=this._element;return!a||this._pause||a.ended?this._playing=!1:!0}var b=this._currentSource;return b&&b.playbackState?this._currentTime+this._context.currentTime-this._startTimeb.buffer.duration))return;this._stopOfWebAudio()}var c=this._context.createBufferSource();if(c.buffer=this._buffer,c.connect(this._volume),this._manualLoop?c.loop=!1:c.loop=this.loop,this._startTime=this._context.currentTime,this._currentTime=a||0,this._ignoreEnded=!1,c.start)c.start(0,a||0);else if(c.noteGrainOn){var d=c.buffer.duration;this.loop?c.noteGrainOn(0,a,d):c.noteGrainOn(0,a,d-a)}else c.noteOn(0);this._currentSource=c;var e=this;c.onended=function(){return e._manualLoop&&e._playing&&e.loop?(e.stop(),void e.play()):void(e._ignoreEnded?e._ignoreEnded=!1:e._pause?e._playing=!1:e.stop())}}},_playOfAudio:function(){var a=this._element;a&&(a.loop=this.loop,a.play())},stop:function(){this._playing=!1,"AUDIO"===this._AUDIO_TYPE?this._stopOfAudio():this._stopOfWebAudio()},_stopOfWebAudio:function(){var a=this._currentSource;this._ignoreEnded=!0,a&&(a.stop(0),this._currentSource=null)},_stopOfAudio:function(){var a=this._element;a&&(a.pause(),a.duration&&a.duration!==1/0&&(a.currentTime=0))},pause:function(){this.getPlaying()!==!1&&(this._playing=!1,this._pause=!0,"AUDIO"===this._AUDIO_TYPE?this._pauseOfAudio():this._pauseOfWebAudio())},_pauseOfWebAudio:function(){this._currentTime+=this._context.currentTime-this._startTime;var a=this._currentSource;a&&a.stop(0)},_pauseOfAudio:function(){var a=this._element;a&&a.pause()},resume:function(){this._pause&&("AUDIO"===this._AUDIO_TYPE?this._resumeOfAudio():this._resumeOfWebAudio(),this._pause=!1,this._playing=!0)},_resumeOfWebAudio:function(){var a=this._currentSource;if(a){this._startTime=this._context.currentTime;var b=this._currentTime%a.buffer.duration;this._playOfWebAudio(b)}},_resumeOfAudio:function(){var a=this._element;a&&a.play()},setVolume:function(a){a>1&&(a=1),0>a&&(a=0),this.volume=a,"AUDIO"===this._AUDIO_TYPE?this._element&&(this._element.volume=a):this._volume&&(this._volume.gain.value=a)},getVolume:function(){return this.volume},cloneNode:function(){var a,b;if("AUDIO"===this._AUDIO_TYPE){a=new cc.Audio;var c=document.createElement("audio");c.src=this.src,a.setElement(c)}else{var d=this._context.createGain();d.gain.value=1,d.connect(this._context.destination),a=new cc.Audio(this._context,d,this.src),this._buffer?a.setBuffer(this._buffer):(b=this,this._setBufferCallback=function(c){a.setBuffer(c),b._setBufferCallback=null}),a._manualLoop=this._manualLoop}return a._AUDIO_TYPE=this._AUDIO_TYPE,a}}),function(a){var b=a.WEB_AUDIO,c=a.MULTI_CHANNEL,d=a.AUTOPLAY,e=[];!function(){var a=document.createElement("audio");if(a.canPlayType){var b=a.canPlayType('audio/ogg; codecs="vorbis"');b&&""!==b&&e.push(".ogg");var c=a.canPlayType("audio/mpeg");c&&""!==c&&e.push(".mp3");var d=a.canPlayType('audio/wav; codecs="1"');d&&""!==d&&e.push(".wav");var f=a.canPlayType("audio/mp4");f&&""!==f&&e.push(".mp4");var g=a.canPlayType("audio/x-m4a");g&&""!==g&&e.push(".m4a")}}();try{if(b){var f=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext);a.DELAY_CREATE_CTX&&setTimeout(function(){f=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)},0)}}catch(g){b=!1,cc.log("browser don't support web audio")}var h={cache:{},load:function(c,d,g,i){if(0===e.length)return i("can not support audio!");var j;cc.loader.audioPath&&(c=cc.path.join(cc.loader.audioPath,c));var k=cc.path.extname(c),l=[k];for(j=0;j1&&(a=1),0>a&&(a=0),this._musicVolume=a;var b=this._currMusic;b&&b.setVolume(a)},isMusicPlaying:function(){var a=this._currMusic;return a?a.getPlaying():!1},_audioPool:{},_maxAudioInstance:5,_effectVolume:1,playEffect:function(a,d){if(!c)return null;var e=this._audioPool[a];e||(e=this._audioPool[a]=[]);var f;for(f=0;fthis._maxAudioInstance)cc.log("Error: %s greater than %d",a,this._maxAudioInstance);else{var g=h.cache[a];g||(cc.loader.load(a),g=h.cache[a]),g=g.cloneNode(),g.setVolume(this._effectVolume),g.loop=d||!1,g.play(),e.push(g)}return g},setEffectsVolume:function(a){a-=0,isNaN(a)&&(a=1),a>1&&(a=1),0>a&&(a=0),this._effectVolume=a;var b=this._audioPool;for(var c in b){var d=b[c];if(Array.isArray(d))for(var e=0;e0&&(h=new cc.LabelAtlas(a,b,c,d,e)),cc.MenuItemLabel.prototype.ctor.call(this,h,f,g)},initWithString:function(a,b,c,d,e,f,g){if(!a||0===a.length)throw new Error("cc.MenuItemAtlasFont.initWithString(): value should be non-null and its length should be greater than 0");var h=new cc.LabelAtlas;return h.initWithString(a,b,c,d,e),this.initWithLabel(h,f,g),!0}}),cc.MenuItemAtlasFont.create=function(a,b,c,d,e,f,g){return new cc.MenuItemAtlasFont(a,b,c,d,e,f,g)},cc.MenuItemFont=cc.MenuItemLabel.extend({_fontSize:null,_fontName:null,ctor:function(a,b,c){var d;a&&a.length>0?(this._fontName=cc._globalFontName,this._fontSize=cc._globalFontSize,d=new cc.LabelTTF(a,this._fontName,this._fontSize)):(this._fontSize=0,this._fontName=""),cc.MenuItemLabel.prototype.ctor.call(this,d,b,c)},initWithString:function(a,b,c){if(!a||0===a.length)throw new Error("Value should be non-null and its length should be greater than 0");this._fontName=cc._globalFontName,this._fontSize=cc._globalFontSize;var d=new cc.LabelTTF(a,this._fontName,this._fontSize);return this.initWithLabel(d,b,c),!0},setFontSize:function(a){this._fontSize=a,this._recreateLabel()},getFontSize:function(){return this._fontSize},setFontName:function(a){this._fontName=a,this._recreateLabel()},getFontName:function(){return this._fontName},_recreateLabel:function(){var a=new cc.LabelTTF(this._label.string,this._fontName,this._fontSize);this.setLabel(a)}}),cc.MenuItemFont.setFontSize=function(a){cc._globalFontSize=a},cc.MenuItemFont.fontSize=function(){return cc._globalFontSize},cc.MenuItemFont.setFontName=function(a){cc._globalFontNameRelease&&(cc._globalFontName=""),cc._globalFontName=a,cc._globalFontNameRelease=!0};var _p=cc.MenuItemFont.prototype;_p.fontSize,cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize),_p.fontName,cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName),cc.MenuItemFont.fontName=function(){return cc._globalFontName},cc.MenuItemFont.create=function(a,b,c){return new cc.MenuItemFont(a,b,c)},cc.MenuItemSprite=cc.MenuItem.extend({_normalImage:null,_selectedImage:null,_disabledImage:null,ctor:function(a,b,c,d,e){if(cc.MenuItem.prototype.ctor.call(this),this._normalImage=null,this._selectedImage=null,this._disabledImage=null,void 0!==b){var f,g,h;void 0!==e?(f=c,h=d,g=e):void 0!==d&&cc.isFunction(d)?(f=c,h=d):void 0!==d&&cc.isFunction(c)?(g=d,h=c,f=null):void 0===c&&(f=null),this.initWithNormalSprite(a,b,f,h,g)}},getNormalImage:function(){return this._normalImage},setNormalImage:function(a){this._normalImage!==a&&(a&&(this.addChild(a,0,cc.NORMAL_TAG),a.anchorX=0,a.anchorY=0),this._normalImage&&this.removeChild(this._normalImage,!0),this._normalImage=a,this._normalImage&&(this.width=this._normalImage.width,this.height=this._normalImage.height,this._updateImagesVisibility(),a.textureLoaded&&!a.textureLoaded()&&a.addEventListener("load",function(a){this.width=a.width,this.height=a.height},this)))},getSelectedImage:function(){return this._selectedImage},setSelectedImage:function(a){this._selectedImage!==a&&(a&&(this.addChild(a,0,cc.SELECTED_TAG),a.anchorX=0,a.anchorY=0),this._selectedImage&&this.removeChild(this._selectedImage,!0),this._selectedImage=a,this._updateImagesVisibility())},getDisabledImage:function(){return this._disabledImage},setDisabledImage:function(a){this._disabledImage!==a&&(a&&(this.addChild(a,0,cc.DISABLE_TAG),a.anchorX=0,a.anchorY=0),this._disabledImage&&this.removeChild(this._disabledImage,!0),this._disabledImage=a,this._updateImagesVisibility())},initWithNormalSprite:function(a,b,c,d,e){this.initWithCallback(d,e),this.setNormalImage(a),this.setSelectedImage(b),this.setDisabledImage(c);var f=this._normalImage;return f&&(this.width=f.width,this.height=f.height,f.textureLoaded&&!f.textureLoaded()&&f.addEventListener("load",function(a){this.width=a.width,this.height=a.height,this.setCascadeColorEnabled(!0),this.setCascadeOpacityEnabled(!0)},this)),this.setCascadeColorEnabled(!0),this.setCascadeOpacityEnabled(!0),!0},selected:function(){cc.MenuItem.prototype.selected.call(this),this._normalImage&&(this._disabledImage&&(this._disabledImage.visible=!1),this._selectedImage?(this._normalImage.visible=!1,this._selectedImage.visible=!0):this._normalImage.visible=!0)},unselected:function(){cc.MenuItem.prototype.unselected.call(this),this._normalImage&&(this._normalImage.visible=!0,this._selectedImage&&(this._selectedImage.visible=!1),this._disabledImage&&(this._disabledImage.visible=!1))},setEnabled:function(a){this._enabled!==a&&(cc.MenuItem.prototype.setEnabled.call(this,a),this._updateImagesVisibility())},_updateImagesVisibility:function(){var a=this._normalImage,b=this._selectedImage,c=this._disabledImage;this._enabled?(a&&(a.visible=!0),b&&(b.visible=!1),c&&(c.visible=!1)):c?(a&&(a.visible=!1),b&&(b.visible=!1),c&&(c.visible=!0)):(a&&(a.visible=!0),b&&(b.visible=!1))}});var _p=cc.MenuItemSprite.prototype;_p.normalImage,cc.defineGetterSetter(_p,"normalImage",_p.getNormalImage,_p.setNormalImage),_p.selectedImage,cc.defineGetterSetter(_p,"selectedImage",_p.getSelectedImage,_p.setSelectedImage),_p.disabledImage,cc.defineGetterSetter(_p,"disabledImage",_p.getDisabledImage,_p.setDisabledImage),cc.MenuItemSprite.create=function(a,b,c,d,e){return new cc.MenuItemSprite(a,b,c,d,e||void 0)},cc.MenuItemImage=cc.MenuItemSprite.extend({ctor:function(a,b,c,d,e){var f=null,g=null,h=null,i=null,j=null;void 0===a||null===a?cc.MenuItemSprite.prototype.ctor.call(this):(f=new cc.Sprite(a),b&&(g=new cc.Sprite(b)),void 0===d?i=c:void 0===e?(i=c,j=d):e&&(h=new cc.Sprite(c),i=d,j=e),cc.MenuItemSprite.prototype.ctor.call(this,f,g,h,i,j))},setNormalSpriteFrame:function(a){this.setNormalImage(new cc.Sprite(a))},setSelectedSpriteFrame:function(a){this.setSelectedImage(new cc.Sprite(a))},setDisabledSpriteFrame:function(a){this.setDisabledImage(new cc.Sprite(a))},initWithNormalImage:function(a,b,c,d,e){var f=null,g=null,h=null;return a&&(f=new cc.Sprite(a)),b&&(g=new cc.Sprite(b)),c&&(h=new cc.Sprite(c)),this.initWithNormalSprite(f,g,h,d,e)}}),cc.MenuItemImage.create=function(a,b,c,d,e){return new cc.MenuItemImage(a,b,c,d,e)},cc.MenuItemToggle=cc.MenuItem.extend({subItems:null,_selectedIndex:0,_opacity:null,_color:null,ctor:function(){cc.MenuItem.prototype.ctor.call(this),this._selectedIndex=0,this.subItems=[],this._opacity=0,this._color=cc.color.WHITE,arguments.length>0&&this.initWithItems(Array.prototype.slice.apply(arguments))},getOpacity:function(){return this._opacity},setOpacity:function(a){if(this._opacity=a,this.subItems&&this.subItems.length>0)for(var b=0;b0)for(var c=0;cd;d++)a[d]&&c.push(a[d]);return this._selectedIndex=cc.UINT_MAX,this.setSelectedIndex(0),this.setCascadeColorEnabled(!0),this.setCascadeOpacityEnabled(!0),!0},addSubItem:function(a){this.subItems.push(a)},activate:function(){if(this._enabled){var a=(this._selectedIndex+1)%this.subItems.length;this.setSelectedIndex(a)}cc.MenuItem.prototype.activate.call(this)},selected:function(){cc.MenuItem.prototype.selected.call(this),this.subItems[this._selectedIndex].selected()},unselected:function(){cc.MenuItem.prototype.unselected.call(this),this.subItems[this._selectedIndex].unselected()},setEnabled:function(a){if(this._enabled!==a){cc.MenuItem.prototype.setEnabled.call(this,a);var b=this.subItems;if(b&&b.length>0)for(var c=0;c0&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");var a=new cc.MenuItemToggle;return a.initWithItems(Array.prototype.slice.apply(arguments)),a},cc.MENU_STATE_WAITING=0,cc.MENU_STATE_TRACKING_TOUCH=1,cc.MENU_HANDLER_PRIORITY=-128,cc.DEFAULT_PADDING=5,cc.Menu=cc.Layer.extend({enabled:!1,_selectedItem:null,_state:-1,_touchListener:null,_className:"Menu",ctor:function(a){cc.Layer.prototype.ctor.call(this),this._color=cc.color.WHITE,this.enabled=!1,this._opacity=255,this._selectedItem=null,this._state=-1,this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,onTouchBegan:this._onTouchBegan,onTouchMoved:this._onTouchMoved,onTouchEnded:this._onTouchEnded,onTouchCancelled:this._onTouchCancelled}),arguments.length>0&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");var b,c=arguments.length;if(0===c)b=[];else if(1===c)b=a instanceof Array?a:[a];else if(c>1){b=[];for(var d=0;c>d;d++)arguments[d]&&b.push(arguments[d])}this.initWithArray(b)},onEnter:function(){var a=this._touchListener;a._isRegistered()||cc.eventManager.addListener(a,this),cc.Node.prototype.onEnter.call(this)},isEnabled:function(){return this.enabled},setEnabled:function(a){this.enabled=a},initWithItems:function(a){var b=[];if(a)for(var c=0;c0){for(c=0,b=h.length;b>c;c++)g+=h[c].height*h[c].scaleY+a;var i=g/2;for(c=0,b=h.length;b>c;c++)f=h[c],e=f.height,d=f.scaleY,f.setPosition(0,i-e*d/2),i-=e*d+a}},alignItemsHorizontally:function(){this.alignItemsHorizontallyWithPadding(cc.DEFAULT_PADDING)},alignItemsHorizontallyWithPadding:function(a){var b,c,d,e,f,g=-a,h=this._children;if(h&&h.length>0){for(b=0,c=h.length;c>b;b++)g+=h[b].width*h[b].scaleX+a;var i=-g/2;for(b=0,c=h.length;c>b;b++)f=h[b],d=f.scaleX,e=h[b].width,f.setPosition(i+e*d/2,0),i+=e*d+a}},alignItemsInColumns:function(){arguments.length>0&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");for(var a=[],b=0;b0)for(b=0,e=j.length;e>b;b++)g>=a.length||(c=a[g],c&&(d=j[b].height,h=h>=d||isNaN(d)?h:d,++i,i>=c&&(f+=h+5,i=0,h=0,++g)));var k=cc.director.getWinSize();g=0,h=0,c=0;var l=0,m=0,n=f/2;if(j&&j.length>0)for(b=0,e=j.length;e>b;b++){var o=j[b];0===c&&(c=a[g],l=k.width/(1+c),m=l),d=o._getHeight(),h=h>=d||isNaN(d)?h:d,o.setPosition(m-k.width/2,n-d/2),m+=l,++i,i>=c&&(n-=h+5,i=0,c=0,h=0,++g)}},alignItemsInRows:function(){arguments.length>0&&null==arguments[arguments.length-1]&&cc.log("parameters should not be ending with null in Javascript");var a,b=[];for(a=0;a0)for(a=0,e=n.length;e>a;a++)d=n[a],k>=b.length||(c=b[k],c&&(f=d.width,l=l>=f||isNaN(f)?l:f,j+=d.height+5,++m,m>=c&&(g.push(l),h.push(j),i+=l+10,m=0,l=0,j=-5,++k)));var o=cc.director.getWinSize();k=0,l=0,c=0;var p=-i/2,q=0;if(n&&n.length>0)for(a=0,e=n.length;e>a;a++)d=n[a],0===c&&(c=b[k],q=h[k]),f=d._getWidth(),l=l>=f||isNaN(f)?l:f,d.setPosition(p+g[k]/2,q-o.height/2),q-=d.height+10,++m,m>=c&&(p+=l+5,m=0,c=0,l=0,++k)},removeChild:function(a,b){if(null!=a){if(!(a instanceof cc.MenuItem))return void cc.log("cc.Menu.removeChild():Menu only supports MenuItem objects as children");this._selectedItem===a&&(this._selectedItem=null),cc.Node.prototype.removeChild.call(this,a,b)}},_onTouchBegan:function(a,b){var c=b.getCurrentTarget();if(c._state!==cc.MENU_STATE_WAITING||!c._visible||!c.enabled)return!1;for(var d=c.parent;null!=d;d=d.parent)if(!d.isVisible())return!1;return c._selectedItem=c._itemForTouch(a),c._selectedItem?(c._state=cc.MENU_STATE_TRACKING_TOUCH,c._selectedItem.selected(),c._selectedItem.setNodeDirty(),!0):!1},_onTouchEnded:function(a,b){var c=b.getCurrentTarget();return c._state!==cc.MENU_STATE_TRACKING_TOUCH?void cc.log("cc.Menu.onTouchEnded(): invalid state"):(c._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty(),c._selectedItem.activate()),void(c._state=cc.MENU_STATE_WAITING))},_onTouchCancelled:function(a,b){var c=b.getCurrentTarget();return c._state!==cc.MENU_STATE_TRACKING_TOUCH?void cc.log("cc.Menu.onTouchCancelled(): invalid state"):(c._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty()),void(c._state=cc.MENU_STATE_WAITING))},_onTouchMoved:function(a,b){var c=b.getCurrentTarget();if(c._state!==cc.MENU_STATE_TRACKING_TOUCH)return void cc.log("cc.Menu.onTouchMoved(): invalid state");var d=c._itemForTouch(a);d!==c._selectedItem&&(c._selectedItem&&(c._selectedItem.unselected(),c._selectedItem.setNodeDirty()),c._selectedItem=d,c._selectedItem&&(c._selectedItem.selected(),c._selectedItem.setNodeDirty()))},onExit:function(){this._state===cc.MENU_STATE_TRACKING_TOUCH&&(this._selectedItem&&(this._selectedItem.unselected(),this._selectedItem=null),this._state=cc.MENU_STATE_WAITING),cc.Node.prototype.onExit.call(this)},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},_itemForTouch:function(a){var b,c=a.getLocation(),d=this._children;if(d&&d.length>0)for(var e=d.length-1;e>=0;e--)if(b=d[e],b.isVisible()&&b.isEnabled()){var f=b.convertToNodeSpace(c),g=b.rect();if(g.x=0,g.y=0,cc.rectContainsPoint(g,f))return b}return null}});var _p=cc.Menu.prototype;_p.enabled,cc.Menu.create=function(a){var b=arguments.length;b>0&&null==arguments[b-1]&&cc.log("parameters should not be ending with null in Javascript");var c;return c=0===b?new cc.Menu:1===b?new cc.Menu(a):new cc.Menu(Array.prototype.slice.call(arguments,0))};cc.math=cc.math||{},cc.math.EPSILON=1/64,cc.math.square=function(a){return a*a},cc.math.almostEqual=function(a,b){return a+cc.math.EPSILON>b&&a-cc.math.EPSILONb.x-a.math.EPSILON&&this.yb.y-a.math.EPSILON}}(cc),function(a){a.kmVec3=a.math.Vec3=function(a,b,c){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z):(this.x=a||0,this.y=b||0,this.z=c||0)},a.math.vec3=function(b,c,d){return new a.math.Vec3(b,c,d)};var b=a.math.Vec3.prototype;b.fill=function(a,b,c){return a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z):(this.x=a,this.y=b,this.z=c),this},b.length=function(){return Math.sqrt(a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z))},b.lengthSq=function(){return a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z)},b.normalize=function(){var a=1/this.length();return this.x*=a,this.y*=a,this.z*=a,this},b.cross=function(a){var b=this.x,c=this.y,d=this.z;return this.x=c*a.z-d*a.y,this.y=d*a.x-b*a.z,this.z=b*a.y-c*a.x,this},b.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z},b.add=function(a){return this.x+=a.x,this.y+=a.y,this.z+=a.z,this},b.subtract=function(a){return this.x-=a.x,this.y-=a.y,this.z-=a.z,this},b.transform=function(a){var b=this.x,c=this.y,d=this.z,e=a.mat;return this.x=b*e[0]+c*e[4]+d*e[8]+e[12],this.y=b*e[1]+c*e[5]+d*e[9]+e[13],this.z=b*e[2]+c*e[6]+d*e[10]+e[14],this},b.transformNormal=function(a){var b=this.x,c=this.y,d=this.z,e=a.mat;return this.x=b*e[0]+c*e[4]+d*e[8],this.y=b*e[1]+c*e[5]+d*e[9],this.z=b*e[2]+c*e[6]+d*e[10],this},b.transformCoord=function(b){var c=new a.math.Vec4(this.x,this.y,this.z,1);return c.transform(b),this.x=c.x/c.w,this.y=c.y/c.w,this.z=c.z/c.w,this},b.scale=function(a){return this.x*=a,this.y*=a,this.z*=a,this},b.equals=function(b){var c=a.math.EPSILON;return this.xb.x-c&&this.yb.y-c&&this.zb.z-c},b.inverseTransform=function(b){var c=b.mat,d=new a.math.Vec3(this.x-c[12],this.y-c[13],this.z-c[14]);return this.x=d.x*c[0]+d.y*c[1]+d.z*c[2],this.y=d.x*c[4]+d.y*c[5]+d.z*c[6],this.z=d.x*c[8]+d.y*c[9]+d.z*c[10],this},b.inverseTransformNormal=function(a){var b=this.x,c=this.y,d=this.z,e=a.mat;return this.x=b*e[0]+c*e[1]+d*e[2],this.y=b*e[4]+c*e[5]+d*e[6],this.z=b*e[8]+c*e[9]+d*e[10],this},b.assignFrom=function(a){return a?(this.x=a.x,this.y=a.y,this.z=a.z,this):this},a.math.Vec3.zero=function(a){return a.x=a.y=a.z=0,a},b.toTypeArray=function(){var a=new Float32Array(3);return a[0]=this.x,a[1]=this.y,a[2]=this.z,a}}(cc),function(a){a.math.Vec4=function(a,b,c,d){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w):(this.x=a||0,this.y=b||0,this.z=c||0,this.w=d||0)},a.kmVec4=a.math.Vec4;var b=a.math.Vec4.prototype;b.fill=function(a,b,c,d){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w):(this.x=a,this.y=b,this.z=c,this.w=d)},b.add=function(a){return a?(this.x+=a.x,this.y+=a.y,this.z+=a.z,this.w+=a.w,this):this},b.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},b.length=function(){return Math.sqrt(a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z)+a.math.square(this.w))},b.lengthSq=function(){return a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z)+a.math.square(this.w)},b.lerp=function(a,b){return this},b.normalize=function(){var a=1/this.length();return this.x*=a,this.y*=a,this.z*=a,this.w*=a,this},b.scale=function(a){return this.normalize(),this.x*=a,this.y*=a,this.z*=a,this.w*=a,this},b.subtract=function(a){this.x-=a.x,this.y-=a.y,this.z-=a.z,this.w-=a.w},b.transform=function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.mat;return this.x=b*f[0]+c*f[4]+d*f[8]+e*f[12],this.y=b*f[1]+c*f[5]+d*f[9]+e*f[13],this.z=b*f[2]+c*f[6]+d*f[10]+e*f[14],this.w=b*f[3]+c*f[7]+d*f[11]+e*f[15],this},a.math.Vec4.transformArray=function(b,c){for(var d=[],e=0;eb.x-c&&this.yb.y-c&&this.zb.z-c&&this.wb.w-c},b.assignFrom=function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w,this},b.toTypeArray=function(){var a=new Float32Array(4);return a[0]=this.x,a[1]=this.y,a[2]=this.z,a[3]=this.w,a}}(cc),function(a){function b(b,c,d){var e=new a.math.Vec2(c);e.subtract(b),d.x=-e.y,d.y=e.x,d.normalize()}a.math.Ray2=function(b,c){this.start=b||new a.math.Vec2,this.dir=c||new a.math.Vec2},a.math.Ray2.prototype.fill=function(a,b,c,d){this.start.x=a,this.start.y=b,this.dir.x=c,this.dir.y=d},a.math.Ray2.prototype.intersectLineSegment=function(b,c,d){var e,f,g,h=this.start.x,i=this.start.y,j=this.start.x+this.dir.x,k=this.start.y+this.dir.y,l=b.x,m=b.y,n=c.x,o=c.y,p=(o-m)*(j-h)-(n-l)*(k-i);return p>-a.math.EPSILON&&pMath.max(b.x,c.x)+a.math.EPSILON||gMath.max(b.y,c.y)+a.math.EPSILON?!1:fMath.max(h,j)+a.math.EPSILON||gMath.max(i,k)+a.math.EPSILON?!1:(d.x=f,d.y=g,!0))},a.math.Ray2.prototype.intersectTriangle=function(c,d,e,f,g){var h,i=new a.math.Vec2,j=new a.math.Vec2,k=new a.math.Vec2,l=1e4,m=!1;return this.intersectLineSegment(c,d,i)&&(m=!0,h=i.subtract(this.start).length(),l>h&&(j.x=i.x,j.y=i.y,l=h,b(c,d,k))),this.intersectLineSegment(d,e,i)&&(m=!0,h=i.subtract(this.start).length(),l>h&&(j.x=i.x,j.y=i.y,l=h,b(d,e,k))),this.intersectLineSegment(e,c,i)&&(m=!0,h=i.subtract(this.start).length(),l>h&&(j.x=i.x,j.y=i.y,l=h,b(e,c,k))),m&&(f.x=j.x,f.y=j.y,g&&(g.x=k.x,g.y=k.y)),m}}(cc),window.Uint16Array=window.Uint16Array||window.Array,window.Float32Array=window.Float32Array||window.Array,function(a){a.math.Matrix3=function(a){a&&a.mat?this.mat=new Float32Array(a.mat):this.mat=new Float32Array(9)},a.kmMat3=a.math.Matrix3;var b=a.math.Matrix3.prototype;b.fill=function(a){var b=this.mat,c=a.mat;return b[0]=c[0],b[1]=c[1],b[2]=c[2],b[3]=c[3],b[4]=c[4],b[5]=c[5],b[6]=c[6],b[7]=c[7],b[8]=c[8],this},b.adjugate=function(){var a=this.mat,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8];return a[0]=f*j-g*i,a[1]=d*i-c*j,a[2]=c*g-d*f,a[3]=g*h-e*j,a[4]=b*j-d*h,a[5]=d*e-b*g,a[6]=e*i-f*h,a[8]=b*f-c*e,this},b.identity=function(){var a=this.mat;return a[1]=a[2]=a[3]=a[5]=a[6]=a[7]=0,a[0]=a[4]=a[8]=1,this};var c=new a.math.Matrix3;b.inverse=function(a){if(0===a)return this;c.assignFrom(this);var b=1/a;return this.adjugate(),this.multiplyScalar(b),this},b.isIdentity=function(){var a=this.mat;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&1===a[4]&&0===a[5]&&0===a[6]&&0===a[7]&&1===a[8]},b.transpose=function(){var a=this.mat,b=a[1],c=a[2],d=a[3],e=a[5],f=a[6],g=a[7];return a[1]=d,a[2]=f,a[3]=b,a[5]=g,a[6]=c,a[7]=e,this},b.determinant=function(){var a=this.mat,b=a[0]*a[4]*a[8]+a[1]*a[5]*a[6]+a[2]*a[3]*a[7];return b-=a[2]*a[4]*a[6]+a[0]*a[5]*a[7]+a[1]*a[3]*a[8]},b.multiply=function(a){var b=this.mat,c=a.mat,d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return b[0]=d*m+g*n+j*o,b[1]=e*m+h*n+k*o,b[2]=f*m+i*n+l*o,b[3]=f*m+i*n+l*o,b[4]=e*p+h*q+k*r,b[5]=f*p+i*q+l*r,b[6]=d*s+g*t+j*u,b[7]=e*s+h*t+k*u,b[8]=f*s+i*t+l*u,this},b.multiplyScalar=function(a){var b=this.mat;return b[0]*=a,b[1]*=a,b[2]*=a,b[3]*=a,b[4]*=a,b[5]*=a,b[6]*=a,b[7]*=a,b[8]*=a,this},a.math.Matrix3.rotationAxisAngle=function(b,c){var d=Math.cos(c),e=Math.sin(c),f=new a.math.Matrix3,g=f.mat;return g[0]=d+b.x*b.x*(1-d),g[1]=b.z*e+b.y*b.x*(1-d),g[2]=-b.y*e+b.z*b.x*(1-d),g[3]=-b.z*e+b.x*b.y*(1-d),g[4]=d+b.y*b.y*(1-d),g[5]=b.x*e+b.z*b.y*(1-d),g[6]=b.y*e+b.x*b.z*(1-d),g[7]=-b.x*e+b.y*b.z*(1-d),g[8]=d+b.z*b.z*(1-d),f},b.assignFrom=function(b){if(this===b)return a.log("cc.math.Matrix3.assign(): current matrix equals matIn"),this;var c=this.mat,d=b.mat;return c[0]=d[0],c[1]=d[1],c[2]=d[2],c[3]=d[3],c[4]=d[4],c[5]=d[5],c[6]=d[6],c[7]=d[7],c[8]=d[8],this},b.equals=function(b){if(this===b)return!0;for(var c=a.math.EPSILON,d=this.mat,e=b.mat,f=0;9>f;++f)if(!(d[f]+c>e[f]&&d[f]-cc;c++)b[c]=a[c];return this},a.kmMat4Identity=function(a){var b=a.mat;return b[1]=b[2]=b[3]=b[4]=b[6]=b[7]=b[8]=b[9]=b[11]=b[12]=b[13]=b[14]=0,b[0]=b[5]=b[10]=b[15]=1,a},b.identity=function(){var a=this.mat;return a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[11]=a[12]=a[13]=a[14]=0,a[0]=a[5]=a[10]=a[15]=1,this},b.get=function(a,b){return this.mat[a+4*b]},b.set=function(a,b,c){this.mat[a+4*b]=c},b.swap=function(a,b,c,d){var e=this.mat,f=e[a+4*b];e[a+4*b]=e[c+4*d],e[c+4*d]=f},a.math.Matrix4._gaussj=function(a,b){var c,d,e,f,g,h,i,j,k,l=0,m=0,n=4,o=4,p=[0,0,0,0],q=[0,0,0,0],r=[0,0,0,0];for(c=0;n>c;c++){for(i=0,d=0;n>d;d++)if(1!==r[d])for(e=0;n>e;e++)0===r[e]&&(h=Math.abs(a.get(d,e)),h>=i&&(i=h,m=d,l=e));if(++r[l],m!==l){for(f=0;n>f;f++)a.swap(m,f,l,f);for(f=0;o>f;f++)b.swap(m,f,l,f)}if(q[c]=m,p[c]=l,0===a.get(l,l))return!1;for(k=1/a.get(l,l),a.set(l,l,1),f=0;n>f;f++)a.set(l,f,a.get(l,f)*k);for(f=0;o>f;f++)b.set(l,f,b.get(l,f)*k);for(g=0;n>g;g++)if(g!==l){for(j=a.get(g,l),a.set(g,l,0),f=0;n>f;f++)a.set(g,f,a.get(g,f)-a.get(l,f)*j);for(f=0;o>f;f++)b.set(g,f,a.get(g,f)-b.get(l,f)*j)}}for(f=n-1;f>=0;f--)if(q[f]!==p[f])for(e=0;n>e;e++)a.swap(e,q[f],e,p[f]);return!0};var c=(new a.math.Matrix4).identity();a.kmMat4Inverse=function(b,d){var e=new a.math.Matrix4(d),f=new a.math.Matrix4(c);return a.math.Matrix4._gaussj(e,f)===!1?null:(b.assignFrom(e),b)},b.inverse=function(){var b=new a.math.Matrix4(this),d=new a.math.Matrix4(c);return a.math.Matrix4._gaussj(b,d)===!1?null:b},b.isIdentity=function(){var a=this.mat;return 1===a[0]&&0===a[1]&&0===a[2]&&0===a[3]&&0===a[4]&&1===a[5]&&0===a[6]&&0===a[7]&&0===a[8]&&0===a[9]&&1===a[10]&&0===a[11]&&0===a[12]&&0===a[13]&&0===a[14]&&1===a[15]},b.transpose=function(){var a=this.mat,b=a[1],c=a[2],d=a[3],e=a[4],f=a[6],g=a[7],h=a[8],i=a[9],j=a[11],k=a[12],l=a[13],m=a[14];return a[1]=e,a[2]=h,a[3]=k,a[4]=b,a[6]=i,a[7]=l,a[8]=c,a[9]=f,a[11]=m,a[12]=d,a[13]=g,a[14]=j,this},a.kmMat4Multiply=function(a,b,c){var d=a.mat,e=b.mat,f=c.mat,g=e[0],h=e[1],i=e[2],j=e[3],k=e[4],l=e[5],m=e[6],n=e[7],o=e[8],p=e[9],q=e[10],r=e[11],s=e[12],t=e[13],u=e[14],v=e[15],w=f[0],x=f[1],y=f[2],z=f[3],A=f[4],B=f[5],C=f[6],D=f[7],E=f[8],F=f[9],G=f[10],H=f[11],I=f[12],J=f[13],K=f[14],L=f[15];return d[0]=w*g+x*k+y*o+z*s,d[1]=w*h+x*l+y*p+z*t,d[2]=w*i+x*m+y*q+z*u,d[3]=w*j+x*n+y*r+z*v,d[4]=A*g+B*k+C*o+D*s,d[5]=A*h+B*l+C*p+D*t,d[6]=A*i+B*m+C*q+D*u,d[7]=A*j+B*n+C*r+D*v,d[8]=E*g+F*k+G*o+H*s,d[9]=E*h+F*l+G*p+H*t,d[10]=E*i+F*m+G*q+H*u,d[11]=E*j+F*n+G*r+H*v,d[12]=I*g+J*k+K*o+L*s,d[13]=I*h+J*l+K*p+L*t,d[14]=I*i+J*m+K*q+L*u,d[15]=I*j+J*n+K*r+L*v,a},b.multiply=function(a){var b=this.mat,c=a.mat,d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3],x=c[4],y=c[5],z=c[6],A=c[7],B=c[8],C=c[9],D=c[10],E=c[11],F=c[12],G=c[13],H=c[14],I=c[15];return b[0]=t*d+u*h+v*l+w*p,b[1]=t*e+u*i+v*m+w*q,b[2]=t*f+u*j+v*n+w*r,b[3]=t*g+u*k+v*o+w*s,b[4]=x*d+y*h+z*l+A*p,b[5]=x*e+y*i+z*m+A*q,b[6]=x*f+y*j+z*n+A*r,b[7]=x*g+y*k+z*o+A*s,b[8]=B*d+C*h+D*l+E*p,b[9]=B*e+C*i+D*m+E*q,b[10]=B*f+C*j+D*n+E*r,b[11]=B*g+C*k+D*o+E*s,b[12]=F*d+G*h+H*l+I*p,b[13]=F*e+G*i+H*m+I*q,b[14]=F*f+G*j+H*n+I*r,b[15]=F*g+G*k+H*o+I*s,this},a.getMat4MultiplyValue=function(a,b){var c=a.mat,d=b.mat,e=new Float32Array(16);return e[0]=c[0]*d[0]+c[4]*d[1]+c[8]*d[2]+c[12]*d[3],e[1]=c[1]*d[0]+c[5]*d[1]+c[9]*d[2]+c[13]*d[3],e[2]=c[2]*d[0]+c[6]*d[1]+c[10]*d[2]+c[14]*d[3],e[3]=c[3]*d[0]+c[7]*d[1]+c[11]*d[2]+c[15]*d[3],e[4]=c[0]*d[4]+c[4]*d[5]+c[8]*d[6]+c[12]*d[7],e[5]=c[1]*d[4]+c[5]*d[5]+c[9]*d[6]+c[13]*d[7],e[6]=c[2]*d[4]+c[6]*d[5]+c[10]*d[6]+c[14]*d[7],e[7]=c[3]*d[4]+c[7]*d[5]+c[11]*d[6]+c[15]*d[7],e[8]=c[0]*d[8]+c[4]*d[9]+c[8]*d[10]+c[12]*d[11],e[9]=c[1]*d[8]+c[5]*d[9]+c[9]*d[10]+c[13]*d[11],e[10]=c[2]*d[8]+c[6]*d[9]+c[10]*d[10]+c[14]*d[11],e[11]=c[3]*d[8]+c[7]*d[9]+c[11]*d[10]+c[15]*d[11],e[12]=c[0]*d[12]+c[4]*d[13]+c[8]*d[14]+c[12]*d[15],e[13]=c[1]*d[12]+c[5]*d[13]+c[9]*d[14]+c[13]*d[15],e[14]=c[2]*d[12]+c[6]*d[13]+c[10]*d[14]+c[14]*d[15],e[15]=c[3]*d[12]+c[7]*d[13]+c[11]*d[14]+c[15]*d[15],e},a.kmMat4Assign=function(b,c){if(b===c)return a.log("cc.kmMat4Assign(): pOut equals pIn"),b;var d=b.mat,e=c.mat;return d[0]=e[0],d[1]=e[1],d[2]=e[2],d[3]=e[3],d[4]=e[4],d[5]=e[5],d[6]=e[6],d[7]=e[7],d[8]=e[8],d[9]=e[9],d[10]=e[10],d[11]=e[11],d[12]=e[12],d[13]=e[13],d[14]=e[14],d[15]=e[15],b},b.assignFrom=function(b){if(this===b)return a.log("cc.mat.Matrix4.assignFrom(): mat4 equals current matrix"),this;var c=this.mat,d=b.mat;return c[0]=d[0],c[1]=d[1],c[2]=d[2],c[3]=d[3],c[4]=d[4],c[5]=d[5],c[6]=d[6],c[7]=d[7],c[8]=d[8],c[9]=d[9],c[10]=d[10],c[11]=d[11],c[12]=d[12],c[13]=d[13],c[14]=d[14],c[15]=d[15],this},b.equals=function(b){if(this===b)return a.log("cc.kmMat4AreEqual(): pMat1 and pMat2 are same object."),!0;for(var c=this.mat,d=b.mat,e=a.math.EPSILON,f=0;16>f;f++)if(!(c[f]+e>d[f]&&c[f]-e.001?a.math.Plane.POINT_INFRONT_OF_PLANE:-.001>c?a.math.Plane.POINT_BEHIND_PLANE:a.math.Plane.POINT_ON_PLANE}}(cc),function(a){a.math.Quaternion=function(a,b,c,d){a&&void 0===b?(this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w):(this.x=a||0,this.y=b||0,this.z=c||0,this.w=d||0)},a.kmQuaternion=a.math.Quaternion;var b=a.math.Quaternion.prototype;b.conjugate=function(a){return this.x=-a.x,this.y=-a.y,this.z=-a.z,this.w=a.w,this},b.dot=function(a){return this.w*a.w+this.x*a.x+this.y*a.y+this.z*a.z},b.exponential=function(){return this},b.identity=function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},b.inverse=function(){var b=this.length();return Math.abs(b)>a.math.EPSILON?(this.x=0,this.y=0,this.z=0,this.w=0,this):(this.conjugate(this).scale(1/b),this)},b.isIdentity=function(){return 0===this.x&&0===this.y&&0===this.z&&1===this.w},b.length=function(){return Math.sqrt(this.lengthSq())},b.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},b.multiply=function(a){var b=this.x,c=this.y,d=this.z,e=this.w;return this.w=e*a.w-b*a.x-c*a.y-d*a.z,this.x=e*a.x+b*a.w+c*a.z-d*a.y,this.y=e*a.y+c*a.w+d*a.x-b*a.z,this.z=e*a.z+d*a.w+b*a.y-c*a.x,this},b.normalize=function(){var b=this.length();if(Math.abs(b)<=a.math.EPSILON)throw new Error("current quaternion is an invalid value");return this.scale(1/b),this},b.rotationAxis=function(a,b){var c=.5*b,d=Math.sin(c);return this.w=Math.cos(c),this.x=a.x*d,this.y=a.y*d,this.z=a.z*d,this},a.math.Quaternion.rotationMatrix=function(b){if(!b)return null;var c,d,e,f,g=[],h=b.mat,i=0;g[0]=h[0],g[1]=h[3],g[2]=h[6],g[4]=h[1],g[5]=h[4],g[6]=h[7],g[8]=h[2],g[9]=h[5],g[10]=h[8],g[15]=1;var j=g[0],k=j[0]+j[5]+j[10]+1;return k>a.math.EPSILON?(i=2*Math.sqrt(k),c=(j[9]-j[6])/i,d=(j[2]-j[8])/i,e=(j[4]-j[1])/i,f=.25*i):j[0]>j[5]&&j[0]>j[10]?(i=2*Math.sqrt(1+j[0]-j[5]-j[10]),c=.25*i,d=(j[4]+j[1])/i,e=(j[2]+j[8])/i,f=(j[9]-j[6])/i):j[5]>j[10]?(i=2*Math.sqrt(1+j[5]-j[0]-j[10]),c=(j[4]+j[1])/i,d=.25*i,e=(j[9]+j[6])/i,f=(j[2]-j[8])/i):(i=2*Math.sqrt(1+j[10]-j[0]-j[5]),c=(j[2]+j[8])/i,d=(j[9]+j[6])/i,e=.25*i,f=(j[4]-j[1])/i),new a.math.Quaternion(c,d,e,f)},a.math.Quaternion.rotationYawPitchRoll=function(b,c,d){var e,f,g,h,i,j,k,l,m,n,o;e=a.degreesToRadians(c)/2,f=a.degreesToRadians(b)/2,g=a.degreesToRadians(d)/2,h=Math.cos(e),i=Math.cos(f),j=Math.cos(g),k=Math.sin(e),l=Math.sin(f),m=Math.sin(g),n=i*j,o=l*m;var p=new a.math.Quaternion;return p.w=h*n+k*o,p.x=k*n-h*o,p.y=h*l*j+k*i*m,p.z=h*i*m-k*l*j,p.normalize(),p},b.slerp=function(b,c){if(this.x===b.x&&this.y===b.y&&this.z===b.z&&this.w===b.w)return this;var d=this.dot(b),e=Math.acos(d),f=Math.sqrt(1-a.math.square(d)),g=Math.sin(c*e)/f,h=Math.sin((1-c)*e)/f,i=new a.math.Quaternion(b);return this.scale(h),i.scale(g),this.add(i),this},b.toAxisAndAngle=function(){var b,c,d,e=new a.math.Vec3;return b=Math.acos(this.w),c=Math.sqrt(a.math.square(this.x)+a.math.square(this.y)+a.math.square(this.z)),c>-a.math.EPSILON&&c2*Math.PI-a.math.EPSILON?(d=0,e.x=0,e.y=0,e.z=1):(d=2*b,e.x=this.x/c,e.y=this.y/c,e.z=this.z/c,e.normalize()),{axis:e,angle:d}},b.scale=function(a){return this.x*=a,this.y*=a,this.z*=a,this.w*=a,this},b.assignFrom=function(a){return this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w,this},b.add=function(a){return this.x+=a.x,this.y+=a.y,this.z+=a.z,this.w+=a.w,this},a.math.Quaternion.rotationBetweenVec3=function(b,c,d){var e=new a.math.Vec3(b),f=new a.math.Vec3(c);e.normalize(),f.normalize();var g=e.dot(f),h=new a.math.Quaternion;if(g>=1)return h.identity(),h;if(1e-6-1>g)if(Math.abs(d.lengthSq())=this.min.x&&a.x<=this.max.x&&a.y>=this.min.y&&a.y<=this.max.y&&a.z>=this.min.z&&a.z<=this.max.z},cc.math.AABB.containsPoint=function(a,b){return a.x>=b.min.x&&a.x<=b.max.x&&a.y>=b.min.y&&a.y<=b.max.y&&a.z>=b.min.z&&a.z<=b.max.z},cc.math.AABB.prototype.assignFrom=function(a){this.min.assignFrom(a.min),this.max.assignFrom(a.max)},cc.math.AABB.assign=function(a,b){return a.min.assignFrom(b.min),a.max.assignFrom(b.max),a},function(a){a.math.Matrix4Stack=function(a,b){this.top=a,this.stack=b||[]},a.km_mat4_stack=a.math.Matrix4Stack;var b=a.math.Matrix4Stack.prototype;b.initialize=function(){this.stack.length=0,this.top=null},a.km_mat4_stack_push=function(b,c){b.stack.push(b.top),b.top=new a.math.Matrix4(c)},a.km_mat4_stack_pop=function(a,b){a.top=a.stack.pop()},a.km_mat4_stack_release=function(a){a.stack=null,a.top=null},b.push=function(b){b=b||this.top,this.stack.push(this.top),this.top=new a.math.Matrix4(b)},b.pop=function(){this.top=this.stack.pop()},b.release=function(){this.stack=null,this.top=null,this._matrixPool=null},b._getFromPool=function(b){var c=this._matrixPool;if(0===c.length)return new a.math.Matrix4(b);var d=c.pop();return d.assignFrom(b),d},b._putInPool=function(a){this._matrixPool.push(a)}}(cc),function(a){a.KM_GL_MODELVIEW=5888,a.KM_GL_PROJECTION=5889,a.KM_GL_TEXTURE=5890,a.modelview_matrix_stack=new a.math.Matrix4Stack,a.projection_matrix_stack=new a.math.Matrix4Stack,a.texture_matrix_stack=new a.math.Matrix4Stack,a.current_stack=null;var b=!1;a.lazyInitialize=function(){if(!b){var c=new a.math.Matrix4;a.modelview_matrix_stack.initialize(),a.projection_matrix_stack.initialize(),a.texture_matrix_stack.initialize(),a.current_stack=a.modelview_matrix_stack,a.initialized=!0,c.identity(),a.modelview_matrix_stack.push(c),a.projection_matrix_stack.push(c),a.texture_matrix_stack.push(c)}},a.lazyInitialize(),a.kmGLFreeAll=function(){a.modelview_matrix_stack.release(),a.modelview_matrix_stack=null,a.projection_matrix_stack.release(),a.projection_matrix_stack=null,a.texture_matrix_stack.release(),a.texture_matrix_stack=null,a.initialized=!1,a.current_stack=null},a.kmGLPushMatrix=function(){a.current_stack.push(a.current_stack.top)},a.kmGLPushMatrixWitMat4=function(b){a.current_stack.stack.push(a.current_stack.top),b.assignFrom(a.current_stack.top),a.current_stack.top=b},a.kmGLPopMatrix=function(){a.current_stack.top=a.current_stack.stack.pop()},a.kmGLMatrixMode=function(b){switch(b){case a.KM_GL_MODELVIEW:a.current_stack=a.modelview_matrix_stack;break;case a.KM_GL_PROJECTION:a.current_stack=a.projection_matrix_stack;break;case a.KM_GL_TEXTURE:a.current_stack=a.texture_matrix_stack;break;default:throw new Error("Invalid matrix mode specified")}},a.kmGLLoadIdentity=function(){a.current_stack.top.identity()},a.kmGLLoadMatrix=function(b){a.current_stack.top.assignFrom(b)},a.kmGLMultMatrix=function(b){a.current_stack.top.multiply(b)};var c=new a.math.Matrix4;a.kmGLTranslatef=function(b,d,e){var f=a.math.Matrix4.createByTranslation(b,d,e,c);a.current_stack.top.multiply(f)};var d=new a.math.Vec3;a.kmGLRotatef=function(b,e,f,g){d.fill(e,f,g);var h=a.math.Matrix4.createByAxisAndAngle(d,a.degreesToRadians(b),c);a.current_stack.top.multiply(h)},a.kmGLScalef=function(b,d,e){var f=a.math.Matrix4.createByScale(b,d,e,c);a.current_stack.top.multiply(f)},a.kmGLGetMatrix=function(b,c){switch(b){case a.KM_GL_MODELVIEW:c.assignFrom(a.modelview_matrix_stack.top);break;case a.KM_GL_PROJECTION:c.assignFrom(a.projection_matrix_stack.top);break;case a.KM_GL_TEXTURE:c.assignFrom(a.texture_matrix_stack.top);break;default:throw new Error("Invalid matrix mode specified")}}}(cc);cc.SHADER_POSITION_UCOLOR_FRAG="precision lowp float;\nvarying vec4 v_fragmentColor;\nvoid main() \n{ \n gl_FragColor = v_fragmentColor; \n}\n",cc.SHADER_POSITION_UCOLOR_VERT="attribute vec4 a_position;\nuniform vec4 u_color;\nuniform float u_pointSize;\nvarying lowp vec4 v_fragmentColor; \nvoid main(void) \n{\n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n gl_PointSize = u_pointSize; \n v_fragmentColor = u_color; \n}",cc.SHADER_POSITION_COLOR_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvoid main() \n{ \n gl_FragColor = v_fragmentColor; \n} ",cc.SHADER_POSITION_COLOR_VERT="attribute vec4 a_position;\nattribute vec4 a_color;\nvarying lowp vec4 v_fragmentColor;\nvoid main()\n{\n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor = a_color; \n}",cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG="// #extension GL_OES_standard_derivatives : enable\nvarying mediump vec4 v_color;\nvarying mediump vec2 v_texcoord;\nvoid main() \n{ \n// #if defined GL_OES_standard_derivatives \n// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); \n// #else \ngl_FragColor = v_color * step(0.0, 1.0 - length(v_texcoord)); \n// #endif \n}",cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT="attribute mediump vec4 a_position; \nattribute mediump vec2 a_texcoord; \nattribute mediump vec4 a_color; \nvarying mediump vec4 v_color; \nvarying mediump vec2 v_texcoord; \nvoid main() \n{ \n v_color = a_color;//vec4(a_color.rgb * a_color.a, a_color.a); \n v_texcoord = a_texcoord; \n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n}",cc.SHADER_POSITION_TEXTURE_FRAG="precision lowp float; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor = texture2D(CC_Texture0, v_texCoord); \n}",cc.SHADER_POSITION_TEXTURE_VERT="attribute vec4 a_position; \nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n v_texCoord = a_texCoord; \n}",cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG="precision lowp float; \nuniform vec4 u_color; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor = texture2D(CC_Texture0, v_texCoord) * u_color; \n}",cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT="attribute vec4 a_position;\nattribute vec2 a_texCoord; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n v_texCoord = a_texCoord; \n}",cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor = vec4( v_fragmentColor.rgb, \n v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a \n ); \n}",cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT="attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color; \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor = a_color; \n v_texCoord = a_texCoord; \n}",cc.SHADER_POSITION_TEXTURE_COLOR_FRAG="precision lowp float;\nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nvoid main() \n{ \n gl_FragColor = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); \n}",cc.SHADER_POSITION_TEXTURE_COLOR_VERT="attribute vec4 a_position; \nattribute vec2 a_texCoord; \nattribute vec4 a_color; \nvarying lowp vec4 v_fragmentColor; \nvarying mediump vec2 v_texCoord; \nvoid main() \n{ \n gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position; \n v_fragmentColor = a_color; \n v_texCoord = a_texCoord; \n}",cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform float CC_alpha_value; \nvoid main() \n{ \n vec4 texColor = texture2D(CC_Texture0, v_texCoord); \n if ( texColor.a <= CC_alpha_value ) \n discard; \n gl_FragColor = texColor * v_fragmentColor; \n}",cc.SHADEREX_SWITCHMASK_FRAG="precision lowp float; \nvarying vec4 v_fragmentColor; \nvarying vec2 v_texCoord; \nuniform sampler2D u_texture; \nuniform sampler2D u_mask; \nvoid main() \n{ \n vec4 texColor = texture2D(u_texture, v_texCoord); \n vec4 maskColor = texture2D(u_mask, v_texCoord); \n vec4 finalColor = vec4(texColor.r, texColor.g, texColor.b, maskColor.a * texColor.a); \n gl_FragColor = v_fragmentColor * finalColor; \n}",cc.shaderCache={TYPE_POSITION_TEXTURECOLOR:0,TYPE_POSITION_TEXTURECOLOR_ALPHATEST:1,TYPE_POSITION_COLOR:2,TYPE_POSITION_TEXTURE:3,TYPE_POSITION_TEXTURE_UCOLOR:4,TYPE_POSITION_TEXTURE_A8COLOR:5,TYPE_POSITION_UCOLOR:6,TYPE_POSITION_LENGTH_TEXTURECOLOR:7,TYPE_MAX:8,_programs:{},_init:function(){return this.loadDefaultShaders(),!0},_loadDefaultShader:function(a,b){switch(b){case this.TYPE_POSITION_TEXTURECOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT,cc.SHADER_POSITION_TEXTURE_COLOR_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT,cc.SHADER_POSITION_TEXTURE_COLOR_ALPHATEST_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_COLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_VERT,cc.SHADER_POSITION_COLOR_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);break;case this.TYPE_POSITION_TEXTURE:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_VERT,cc.SHADER_POSITION_TEXTURE_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_TEXTURE_UCOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_UCOLOR_VERT,cc.SHADER_POSITION_TEXTURE_UCOLOR_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_TEXTURE_A8COLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_A8COLOR_VERT,cc.SHADER_POSITION_TEXTURE_A8COLOR_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS);break;case this.TYPE_POSITION_UCOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_UCOLOR_VERT,cc.SHADER_POSITION_UCOLOR_FRAG),a.addAttribute("aVertex",cc.VERTEX_ATTRIB_POSITION);break;case this.TYPE_POSITION_LENGTH_TEXTURECOLOR:a.initWithVertexShaderByteArray(cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_VERT,cc.SHADER_POSITION_COLOR_LENGTH_TEXTURE_FRAG),a.addAttribute(cc.ATTRIBUTE_NAME_POSITION,cc.VERTEX_ATTRIB_POSITION),a.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD,cc.VERTEX_ATTRIB_TEX_COORDS),a.addAttribute(cc.ATTRIBUTE_NAME_COLOR,cc.VERTEX_ATTRIB_COLOR);break;default:return void cc.log("cocos2d: cc.shaderCache._loadDefaultShader, error shader type")}a.link(),a.updateUniforms()},loadDefaultShaders:function(){var a=new cc.GLProgram;this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR),this._programs[cc.SHADER_POSITION_TEXTURECOLOR]=a,this._programs.ShaderPositionTextureColor=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST),this._programs[cc.SHADER_POSITION_TEXTURECOLORALPHATEST]=a,this._programs.ShaderPositionTextureColorAlphaTest=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_COLOR),this._programs[cc.SHADER_POSITION_COLOR]=a,this._programs.ShaderPositionColor=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE),this._programs[cc.SHADER_POSITION_TEXTURE]=a,this._programs.ShaderPositionTexture=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_UCOLOR),this._programs[cc.SHADER_POSITION_TEXTURE_UCOLOR]=a,this._programs.ShaderPositionTextureUColor=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_A8COLOR),this._programs[cc.SHADER_POSITION_TEXTUREA8COLOR]=a,this._programs.ShaderPositionTextureA8Color=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_UCOLOR),this._programs[cc.SHADER_POSITION_UCOLOR]=a,this._programs.ShaderPositionUColor=a,a=new cc.GLProgram,this._loadDefaultShader(a,this.TYPE_POSITION_LENGTH_TEXTURECOLOR),this._programs[cc.SHADER_POSITION_LENGTHTEXTURECOLOR]=a,this._programs.ShaderPositionLengthTextureColor=a},reloadDefaultShaders:function(){var a=this.programForKey(cc.SHADER_POSITION_TEXTURECOLOR);a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR),a=this.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST),a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURECOLOR_ALPHATEST),a=this.programForKey(cc.SHADER_POSITION_COLOR),a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_COLOR),a=this.programForKey(cc.SHADER_POSITION_TEXTURE),a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE),a=this.programForKey(cc.SHADER_POSITION_TEXTURE_UCOLOR),a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_UCOLOR),a=this.programForKey(cc.SHADER_POSITION_TEXTUREA8COLOR),a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_TEXTURE_A8COLOR),a=this.programForKey(cc.SHADER_POSITION_UCOLOR),a.reset(),this._loadDefaultShader(a,this.TYPE_POSITION_UCOLOR)},programForKey:function(a){return this._programs[a]},getProgram:function(a){return this._programs[a]},addProgram:function(a,b){this._programs[b]=a}},cc.HashUniformEntry=function(a,b,c){this.value=a,this.location=b,this.hh=c||{}},cc.GLProgram=cc.Class.extend({_glContext:null,_programObj:null,_vertShader:null,_fragShader:null,_uniforms:null,_hashForUniforms:null,_usesTime:!1,_updateUniformLocation:function(a,b,c){if(null==a)return!1;for(var d=!0,e=null,f=0;f"},_compileShader:function(a,b,c){if(!c||!a)return!1;var d=cc.GLProgram._isHighpSupported()?"precision highp float;\n":"precision mediump float;\n";c=d+"uniform mat4 CC_PMatrix; \nuniform mat4 CC_MVMatrix; \nuniform mat4 CC_MVPMatrix; \nuniform vec4 CC_Time; \nuniform vec4 CC_SinTime; \nuniform vec4 CC_CosTime; \nuniform vec4 CC_Random01; \nuniform sampler2D CC_Texture0; \n//CC INCLUDES END \n"+c,this._glContext.shaderSource(a,c),this._glContext.compileShader(a);var e=this._glContext.getShaderParameter(a,this._glContext.COMPILE_STATUS);return e||(cc.log("cocos2d: ERROR: Failed to compile shader:\n"+this._glContext.getShaderSource(a)),b===this._glContext.VERTEX_SHADER?cc.log("cocos2d: \n"+this.vertexShaderLog()):cc.log("cocos2d: \n"+this.fragmentShaderLog())),e===!0},ctor:function(a,b,c){this._uniforms=[],this._hashForUniforms=[],this._glContext=c||cc._renderContext,a&&b&&this.init(a,b)},destroyProgram:function(){this._vertShader=null,this._fragShader=null,this._uniforms=null,this._hashForUniforms=null,this._glContext.deleteProgram(this._programObj)},initWithVertexShaderByteArray:function(a,b){var c=this._glContext;return this._programObj=c.createProgram(),this._vertShader=null,this._fragShader=null,a&&(this._vertShader=c.createShader(c.VERTEX_SHADER),this._compileShader(this._vertShader,c.VERTEX_SHADER,a)||cc.log("cocos2d: ERROR: Failed to compile vertex shader")),b&&(this._fragShader=c.createShader(c.FRAGMENT_SHADER),this._compileShader(this._fragShader,c.FRAGMENT_SHADER,b)||cc.log("cocos2d: ERROR: Failed to compile fragment shader")),this._vertShader&&c.attachShader(this._programObj,this._vertShader),cc.checkGLErrorDebug(),this._fragShader&&c.attachShader(this._programObj,this._fragShader),this._hashForUniforms.length=0,cc.checkGLErrorDebug(),!0},initWithString:function(a,b){return this.initWithVertexShaderByteArray(a,b)},initWithVertexShaderFilename:function(a,b){var c=cc.loader.getRes(a);if(!c)throw new Error("Please load the resource firset : "+a);var d=cc.loader.getRes(b);if(!d)throw new Error("Please load the resource firset : "+b);return this.initWithVertexShaderByteArray(c,d)},init:function(a,b){return this.initWithVertexShaderFilename(a,b)},addAttribute:function(a,b){this._glContext.bindAttribLocation(this._programObj,b,a)},link:function(){if(!this._programObj)return cc.log("cc.GLProgram.link(): Cannot link invalid program"),!1;if(this._glContext.linkProgram(this._programObj),this._vertShader&&this._glContext.deleteShader(this._vertShader),this._fragShader&&this._glContext.deleteShader(this._fragShader),this._vertShader=null,this._fragShader=null,cc.game.config[cc.game.CONFIG_KEY.debugMode]){var a=this._glContext.getProgramParameter(this._programObj,this._glContext.LINK_STATUS);if(!a)return cc.log("cocos2d: ERROR: Failed to link program: "+this._glContext.getProgramInfoLog(this._programObj)),cc.glDeleteProgram(this._programObj),this._programObj=null,!1}return!0},use:function(){cc.glUseProgram(this._programObj)},updateUniforms:function(){this._uniforms[cc.UNIFORM_PMATRIX]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_PMATRIX_S),this._uniforms[cc.UNIFORM_MVMATRIX]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_MVMATRIX_S),this._uniforms[cc.UNIFORM_MVPMATRIX]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_MVPMATRIX_S),this._uniforms[cc.UNIFORM_TIME]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_TIME_S),this._uniforms[cc.UNIFORM_SINTIME]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_SINTIME_S),this._uniforms[cc.UNIFORM_COSTIME]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_COSTIME_S),this._usesTime=null!=this._uniforms[cc.UNIFORM_TIME]||null!=this._uniforms[cc.UNIFORM_SINTIME]||null!=this._uniforms[cc.UNIFORM_COSTIME],this._uniforms[cc.UNIFORM_RANDOM01]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_RANDOM01_S),this._uniforms[cc.UNIFORM_SAMPLER]=this._glContext.getUniformLocation(this._programObj,cc.UNIFORM_SAMPLER_S),this.use(),this.setUniformLocationWith1i(this._uniforms[cc.UNIFORM_SAMPLER],0)},getUniformLocationForName:function(a){if(!a)throw new Error("cc.GLProgram.getUniformLocationForName(): uniform name should be non-null");if(!this._programObj)throw new Error("cc.GLProgram.getUniformLocationForName(): Invalid operation. Cannot get uniform location when program is not initialized");return this._glContext.getUniformLocation(this._programObj,a)},getUniformMVPMatrix:function(){return this._uniforms[cc.UNIFORM_MVPMATRIX]},getUniformSampler:function(){return this._uniforms[cc.UNIFORM_SAMPLER]},setUniformLocationWith1i:function(a,b){var c=this._updateUniformLocation(a,b);c&&this._glContext.uniform1i(a,b)},setUniformLocationWith2i:function(a,b,c){var d=[b,c],e=this._updateUniformLocation(a,d);e&&this._glContext.uniform2i(a,b,c)},setUniformLocationWith3i:function(a,b,c,d){var e=[b,c,d],f=this._updateUniformLocation(a,e);f&&this._glContext.uniform3i(a,b,c,d)},setUniformLocationWith4i:function(a,b,c,d,e){var f=[b,c,d,e],g=this._updateUniformLocation(a,f);g&&this._glContext.uniform4i(a,b,c,d,e)},setUniformLocationWith2iv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniform2iv(a,b)},setUniformLocationWith3iv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniform3iv(a,b)},setUniformLocationWith4iv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniform4iv(a,b)},setUniformLocationI32:function(a,b){this.setUniformLocationWith1i(arguments[0],arguments[1])},setUniformLocationWith1f:function(a,b){var c=this._updateUniformLocation(a,b);c&&this._glContext.uniform1f(a,b)},setUniformLocationWith2f:function(a,b,c){var d=[b,c],e=this._updateUniformLocation(a,d);e&&this._glContext.uniform2f(a,b,c)},setUniformLocationWith3f:function(a,b,c,d){var e=[b,c,d],f=this._updateUniformLocation(a,e);f&&this._glContext.uniform3f(a,b,c,d)},setUniformLocationWith4f:function(a,b,c,d,e){var f=[b,c,d,e],g=this._updateUniformLocation(a,f);g&&this._glContext.uniform4f(a,b,c,d,e)},setUniformLocationWith2fv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniform2fv(a,b)},setUniformLocationWith3fv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniform3fv(a,b)},setUniformLocationWith4fv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniform4fv(a,b)},setUniformLocationWithMatrix4fv:function(a,b,c){var d=this._updateUniformLocation(a,b);d&&this._glContext.uniformMatrix4fv(a,!1,b)},setUniformLocationF32:function(){if(!(arguments.length<2))switch(arguments.length){case 2:this.setUniformLocationWith1f(arguments[0],arguments[1]);break;case 3:this.setUniformLocationWith2f(arguments[0],arguments[1],arguments[2]);break;case 4:this.setUniformLocationWith3f(arguments[0],arguments[1],arguments[2],arguments[3]);break;case 5:this.setUniformLocationWith4f(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4])}},setUniformsForBuiltins:function(){var a=new cc.math.Matrix4,b=new cc.math.Matrix4,c=new cc.math.Matrix4;if(cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,a),cc.kmGLGetMatrix(cc.KM_GL_MODELVIEW,b),cc.kmMat4Multiply(c,a,b),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],a.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],b.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],c.mat,1),this._usesTime){var d=cc.director,e=d.getTotalFrames()*d.getAnimationInterval();this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME],e/10,e,2*e,4*e),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME],e/8,e/4,e/2,Math.sin(e)),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME],e/8,e/4,e/2,Math.cos(e))}-1!==this._uniforms[cc.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())},_setUniformsForBuiltinsForRenderer:function(a){if(a&&a._renderCmd){var b=new cc.math.Matrix4,c=new cc.math.Matrix4;if(cc.kmGLGetMatrix(cc.KM_GL_PROJECTION,b),cc.kmMat4Multiply(c,b,a._renderCmd._stackMatrix),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],b.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],a._renderCmd._stackMatrix.mat,1),this.setUniformLocationWithMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],c.mat,1),this._usesTime){var d=cc.director,e=d.getTotalFrames()*d.getAnimationInterval();this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_TIME],e/10,e,2*e,4*e),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_SINTIME],e/8,e/4,e/2,Math.sin(e)),this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_COSTIME],e/8,e/4,e/2,Math.cos(e))}-1!==this._uniforms[cc.UNIFORM_RANDOM01]&&this.setUniformLocationWith4f(this._uniforms[cc.UNIFORM_RANDOM01],Math.random(),Math.random(),Math.random(),Math.random())}},setUniformForModelViewProjectionMatrix:function(){this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],!1,cc.getMat4MultiplyValue(cc.projection_matrix_stack.top,cc.modelview_matrix_stack.top))},setUniformForModelViewProjectionMatrixWithMat4:function(a){cc.kmMat4Multiply(a,cc.projection_matrix_stack.top,cc.modelview_matrix_stack.top),this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVPMATRIX],!1,a.mat)},setUniformForModelViewAndProjectionMatrixWithMat4:function(){this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],!1,cc.modelview_matrix_stack.top.mat),this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],!1,cc.projection_matrix_stack.top.mat)},_setUniformForMVPMatrixWithMat4:function(a){if(!a)throw new Error("modelView matrix is undefined.");this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_MVMATRIX],!1,a.mat),this._glContext.uniformMatrix4fv(this._uniforms[cc.UNIFORM_PMATRIX],!1,cc.projection_matrix_stack.top.mat)},vertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getVertexShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},getFragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._vertShader)},fragmentShaderLog:function(){return this._glContext.getShaderInfoLog(this._fragShader)},programLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},getProgramLog:function(){return this._glContext.getProgramInfoLog(this._programObj)},reset:function(){this._vertShader=null,this._fragShader=null,this._uniforms.length=0,this._glContext.deleteProgram(this._programObj),this._programObj=null;for(var a=0;a>1,a|=a>>2,a|=a>>4,a|=a>>8,a|=a>>16,a+1},cc.RenderTexture=cc.Node.extend({sprite:null,clearFlags:0,clearDepthVal:0,autoDraw:!1,_texture:null,_pixelFormat:0,clearStencilVal:0,_clearColor:null,_className:"RenderTexture",ctor:function(a,b,c,d){cc.Node.prototype.ctor.call(this),this._cascadeColorEnabled=!0,this._cascadeOpacityEnabled=!0,this._pixelFormat=cc.Texture2D.PIXEL_FORMAT_RGBA8888,this._clearColor=new cc.Color(0,0,0,255),void 0!==a&&void 0!==b&&(c=c||cc.Texture2D.PIXEL_FORMAT_RGBA8888,d=d||0,this.initWithWidthAndHeight(a,b,c,d)),this.setAnchorPoint(0,0)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.RenderTexture.CanvasRenderCmd(this):new cc.RenderTexture.WebGLRenderCmd(this)},cleanup:function(){cc.Node.prototype.onExit.call(this),this._renderCmd.cleanup()},getSprite:function(){return this.sprite},setSprite:function(a){this.sprite=a},setVirtualViewport:function(a,b,c){this._renderCmd.setVirtualViewport(a,b,c)},initWithWidthAndHeight:function(a,b,c,d){return this._renderCmd.initWithWidthAndHeight(a,b,c,d)},begin:function(){cc.renderer._turnToCacheMode(this.__instanceId),this._renderCmd.begin()},beginWithClear:function(a,b,c,d,e,f){var g=cc._renderContext;e=e||g.COLOR_BUFFER_BIT,f=f||g.COLOR_BUFFER_BIT|g.DEPTH_BUFFER_BIT,this._beginWithClear(a,b,c,d,e,f,g.COLOR_BUFFER_BIT|g.DEPTH_BUFFER_BIT|g.STENCIL_BUFFER_BIT)},_beginWithClear:function(a,b,c,d,e,f,g){this.begin(),this._renderCmd._beginWithClear(a,b,c,d,e,f,g)},end:function(){this._renderCmd.end()},clear:function(a,b,c,d){this.beginWithClear(a,b,c,d),this.end()},clearRect:function(a,b,c,d){this._renderCmd.clearRect(a,b,c,d)},clearDepth:function(a){this._renderCmd.clearDepth(a)},clearStencil:function(a){this._renderCmd.clearStencil(a)},getClearFlags:function(){return this.clearFlags},setClearFlags:function(a){this.clearFlags=a},getClearColor:function(){return this._clearColor},setClearColor:function(a){var b=this._clearColor;b.r=a.r,b.g=a.g,b.b=a.b,b.a=a.a,this._renderCmd.updateClearColor(a)},getClearDepth:function(){return this.clearDepthVal},setClearDepth:function(a){this.clearDepthVal=a},getClearStencil:function(){return this.clearStencilVal},setClearStencil:function(a){this.clearStencilVal=a},isAutoDraw:function(){return this.autoDraw},setAutoDraw:function(a){this.autoDraw=a},saveToFile:function(a,b){cc.log("saveToFile isn't supported on Cocos2d-Html5")},newCCImage:function(a){return cc.log("saveToFile isn't supported on cocos2d-html5"),null},listenToBackground:function(a){},listenToForeground:function(a){}});var _p=cc.RenderTexture.prototype;_p.clearColorVal,cc.defineGetterSetter(_p,"clearColorVal",_p.getClearColor,_p.setClearColor),cc.RenderTexture.create=function(a,b,c,d){return new cc.RenderTexture(a,b,c,d)},function(){cc.RenderTexture.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._clearColorStr="rgba(255,255,255,1)",this._cacheCanvas=document.createElement("canvas"),this._cacheContext=new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"))};var a=cc.RenderTexture.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.RenderTexture.CanvasRenderCmd,a.cleanup=function(){this._cacheContext=null,this._cacheCanvas=null},a.clearStencil=function(a){},a.setVirtualViewport=function(a,b,c){},a.updateClearColor=function(a){this._clearColorStr="rgba("+(0|a.r)+","+(0|a.g)+","+(0|a.b)+","+a.a/255+")"},a.initWithWidthAndHeight=function(a,b,c,d){var e=this._node,f=this._cacheCanvas,g=cc.contentScaleFactor();f.width=0|a*g,f.height=0|b*g;var h=new cc.Texture2D;h.initWithElement(f),h.handleLoadedTexture();var i=e.sprite=new cc.Sprite(h);return i.setBlendFunc(cc.ONE,cc.ONE_MINUS_SRC_ALPHA),e.autoDraw=!1,e.addChild(i),!0},a.begin=function(){},a._beginWithClear=function(a,b,c,d,e,f,g){a=a||0,b=b||0,c=c||0,d=isNaN(d)?255:d;var h=this._cacheContext.getContext(),i=this._cacheCanvas;h.setTransform(1,0,0,1,0,0),this._cacheContext.setFillStyle("rgba("+(0|a)+","+(0|b)+","+(0|c)+","+d/255+")"),h.clearRect(0,0,i.width,i.height),h.fillRect(0,0,i.width,i.height)},a.end=function(){var a=this._node,b=cc.contentScaleFactor();cc.renderer._renderingToCacheCanvas(this._cacheContext,a.__instanceId,b,b)},a.clearRect=function(a,b,c,d){this._cacheContext.clearRect(a,b,c,-d)},a.clearDepth=function(a){cc.log("clearDepth isn't supported on Cocos2d-Html5")},a.visit=function(a){var b=this._node;this._syncStatus(a),b.sprite.visit(this),this._dirtyFlag=0}}();!function(){cc.RenderTexture.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._fBO=null,this._oldFBO=null,this._textureCopy=null,this._depthRenderBuffer=null,this._rtTextureRect=new cc.Rect,this._fullRect=new cc.Rect,this._fullViewport=new cc.Rect};var a=cc.RenderTexture.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.RenderTexture.WebGLRenderCmd,a.setVirtualViewport=function(a,b,c){this._rtTextureRect.x=a.x,this._rtTextureRect.y=a.y,this._fullRect=b,this._fullViewport=c},a.rendering=function(a){var b=a||cc._renderContext,c=this._node;if(c.autoDraw){c.begin();var d=c.clearFlags;if(d){var e=[0,0,0,0],f=0,g=0;d&b.COLOR_BUFFER_BIT&&(e=b.getParameter(b.COLOR_CLEAR_VALUE),b.clearColor(c._clearColor.r/255,c._clearColor.g/255,c._clearColor.b/255,c._clearColor.a/255)),d&b.DEPTH_BUFFER_BIT&&(f=b.getParameter(b.DEPTH_CLEAR_VALUE),b.clearDepth(c.clearDepthVal)),d&b.STENCIL_BUFFER_BIT&&(g=b.getParameter(b.STENCIL_CLEAR_VALUE),b.clearStencil(c.clearStencilVal)),b.clear(d),d&b.COLOR_BUFFER_BIT&&b.clearColor(e[0],e[1],e[2],e[3]),d&b.DEPTH_BUFFER_BIT&&b.clearDepth(f),d&b.STENCIL_BUFFER_BIT&&b.clearStencil(g)}c.sortAllChildren();for(var h=c._children,i=0;il;l++)k[l]=0;this._pixelFormat=c;var m=e._texture=new cc.Texture2D;if(!e._texture)return!1;m.initWithData(k,e._pixelFormat,h,i,cc.size(a,b));var n=f.getParameter(f.RENDERBUFFER_BINDING);if(cc.configuration.checkForGLExtension("GL_QCOM")){if(this._textureCopy=new cc.Texture2D,!this._textureCopy)return!1;this._textureCopy.initWithData(k,e._pixelFormat,h,i,cc.size(a,b))}this._fBO=f.createFramebuffer(),f.bindFramebuffer(f.FRAMEBUFFER,this._fBO),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m._webTextureObj,0),0!==d&&(this._depthRenderBuffer=f.createRenderbuffer(),f.bindRenderbuffer(f.RENDERBUFFER,this._depthRenderBuffer),f.renderbufferStorage(f.RENDERBUFFER,d,h,i),d===f.DEPTH_STENCIL?f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,this._depthRenderBuffer):d===f.STENCIL_INDEX||d===f.STENCIL_INDEX8?f.framebufferRenderbuffer(f.FRAMEBUFFER,f.STENCIL_ATTACHMENT,f.RENDERBUFFER,this._depthRenderBuffer):d===f.DEPTH_COMPONENT16&&f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,this._depthRenderBuffer)),f.checkFramebufferStatus(f.FRAMEBUFFER)!==f.FRAMEBUFFER_COMPLETE&&cc.log("Could not attach texture to the framebuffer"),m.setAliasTexParameters();var o=e.sprite=new cc.Sprite(m);return o.scaleY=-1,o.setBlendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA),f.bindRenderbuffer(f.RENDERBUFFER,n),f.bindFramebuffer(f.FRAMEBUFFER,this._oldFBO),e.autoDraw=!1,e.addChild(o),!0},a.begin=function(){var a=this._node;cc.kmGLMatrixMode(cc.KM_GL_PROJECTION),cc.kmGLPushMatrix(),cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW),cc.kmGLPushMatrix();var b=cc._renderContext,c=cc.director;c.setProjection(c.getProjection());var d=a._texture.getContentSizeInPixels(),e=cc.director.getWinSizeInPixels(),f=e.width/d.width,g=e.height/d.height,h=cc.math.Matrix4.createOrthographicProjection(-1/f,1/f,-1/g,1/g,-1,1);cc.kmGLMultMatrix(h);var i=new cc.Rect(0,0,0,0);i.width=this._fullViewport.width,i.height=this._fullViewport.height;var j=i.width/this._fullRect.width,k=i.height/this._fullRect.height;i.x=(this._fullRect.x-this._rtTextureRect.x)*j,i.y=(this._fullRect.y-this._rtTextureRect.y)*k,b.viewport(i.x,i.y,i.width,i.height),this._oldFBO=b.getParameter(b.FRAMEBUFFER_BINDING),b.bindFramebuffer(b.FRAMEBUFFER,this._fBO),cc.configuration.checkForGLExtension("GL_QCOM")&&(b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this._textureCopy._webTextureObj,0),b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,a._texture._webTextureObj,0))},a._beginWithClear=function(a,b,c,d,e,f,g){a/=255,b/=255,c/=255,d/=255;var h=cc._renderContext,i=[0,0,0,0],j=0,k=0;g&h.COLOR_BUFFER_BIT&&(i=h.getParameter(h.COLOR_CLEAR_VALUE),h.clearColor(a,b,c,d)),g&h.DEPTH_BUFFER_BIT&&(j=h.getParameter(h.DEPTH_CLEAR_VALUE),h.clearDepth(e)),g&h.STENCIL_BUFFER_BIT&&(k=h.getParameter(h.STENCIL_CLEAR_VALUE),h.clearStencil(f)),h.clear(g),g&h.COLOR_BUFFER_BIT&&h.clearColor(i[0],i[1],i[2],i[3]),g&h.DEPTH_BUFFER_BIT&&h.clearDepth(j),g&h.STENCIL_BUFFER_BIT&&h.clearStencil(k)},a.end=function(){var a=this._node;cc.renderer._renderingToBuffer(a.__instanceId);var b=cc._renderContext,c=cc.director;b.bindFramebuffer(b.FRAMEBUFFER,this._oldFBO),c.setViewport(),cc.kmGLMatrixMode(cc.KM_GL_PROJECTION),cc.kmGLPopMatrix(),cc.kmGLMatrixMode(cc.KM_GL_MODELVIEW),cc.kmGLPopMatrix()},a.clearRect=function(a,b,c,d){},a.clearDepth=function(a){var b=this._node;b.begin();var c=cc._renderContext,d=c.getParameter(c.DEPTH_CLEAR_VALUE);c.clearDepth(a),c.clear(c.DEPTH_BUFFER_BIT),c.clearDepth(d),b.end()},a.visit=function(a){var b=this._node;b._visible&&(cc.kmGLPushMatrix(),this._syncStatus(a),cc.renderer.pushRenderCommand(this),b.sprite.visit(this),this._dirtyFlag=0,cc.kmGLPopMatrix())}}();cc.SpriteBatchNode=cc.Node.extend({_blendFunc:null,_descendants:null,_className:"SpriteBatchNode",ctor:function(a,b){cc.Node.prototype.ctor.call(this),this._descendants=[],this._blendFunc=new cc.BlendFunc(cc.BLEND_SRC,cc.BLEND_DST);var c;b=b||cc.SpriteBatchNode.DEFAULT_CAPACITY,cc.isString(a)?(c=cc.textureCache.getTextureForKey(a),c||(c=cc.textureCache.addImage(a))):a instanceof cc.Texture2D&&(c=a),c&&this.initWithTexture(c,b)},addSpriteWithoutQuad:function(a,b,c){if(cc.assert(a,cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad_2),!(a instanceof cc.Sprite))return cc.log(cc._LogInfos.SpriteBatchNode_addSpriteWithoutQuad),null;a.atlasIndex=b;var d,e=0,f=this._descendants;if(f&&f.length>0)for(e=0,d=f.length;d>e;e++){var g=f[e];if(g&&g.atlasIndex>=b)break}return f.splice(e,0,a),cc.Node.prototype.addChild.call(this,a,b,c),this.reorderBatch(!1),this},getTextureAtlas:function(){return this._renderCmd.getTextureAtlas()},setTextureAtlas:function(a){this._renderCmd.getTextureAtlas(a)},getDescendants:function(){return this._descendants},initWithFile:function(a,b){var c=cc.textureCache.getTextureForKey(a);return c||(c=cc.textureCache.addImage(a)),this.initWithTexture(c,b)},_setNodeDirtyForCache:function(){this._renderCmd&&this._renderCmd._setNodeDirtyForCache&&this._renderCmd._setNodeDirtyForCache()},init:function(a,b){var c=cc.textureCache.getTextureForKey(a);return c||(c=cc.textureCache.addImage(a)),this.initWithTexture(c,b)},increaseAtlasCapacity:function(){this._renderCmd.increaseAtlasCapacity()},removeChildAtIndex:function(a,b){this.removeChild(this._children[a],b)},rebuildIndexInOrder:function(a,b){var c=a.children;if(c&&c.length>0)for(var d=0;d0)for(d=0;d=0&&(b=this.rebuildIndexInOrder(e,b));return b},highestAtlasIndexInChild:function(a){var b=a.children;return b&&0!==b.length?this.highestAtlasIndexInChild(b[b.length-1]):a.atlasIndex},lowestAtlasIndexInChild:function(a){var b=a.children;return b&&0!==b.length?this.lowestAtlasIndexInChild(b[b.length-1]):a.atlasIndex},atlasIndexForChild:function(a,b){var c=a.parent,d=c.children,e=d.indexOf(a),f=c===this,g=null;return e>0&&eb?c.atlasIndex:c.atlasIndex+1:g.zIndex<0&&0>b||g.zIndex>=0&&b>=0?this.highestAtlasIndexInChild(g)+1:c.atlasIndex+1},reorderBatch:function(a){this._reorderChildDirty=a},setBlendFunc:function(a,b){void 0===b?this._blendFunc=a:this._blendFunc={src:a,dst:b}},getBlendFunc:function(){return new cc.BlendFunc(this._blendFunc.src,this._blendFunc.dst)},reorderChild:function(a,b){return cc.assert(a,cc._LogInfos.SpriteBatchNode_reorderChild_2),-1===this._children.indexOf(a)?void cc.log(cc._LogInfos.SpriteBatchNode_reorderChild):void(b!==a.zIndex&&cc.Node.prototype.reorderChild.call(this,a,b))},removeChild:function(a,b){if(null!=a){if(-1===this._children.indexOf(a))return void cc.log(cc._LogInfos.SpriteBatchNode_removeChild);this.removeSpriteFromAtlas(a),cc.Node.prototype.removeChild.call(this,a,b)}},updateQuadFromSprite:function(a,b){return cc.assert(a,cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite_2),a instanceof cc.Sprite?(this._renderCmd.checkAtlasCapacity(),a.batchNode=this,a.atlasIndex=b,a.dirty=!0,void a.updateTransform()):void cc.log(cc._LogInfos.CCSpriteBatchNode_updateQuadFromSprite)},insertQuadFromSprite:function(a,b){return cc.assert(a,cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite_2),a instanceof cc.Sprite?(this._renderCmd.insertQuad(a,b),a.batchNode=this,a.atlasIndex=b,a.dirty=!0,a.updateTransform(),void this._renderCmd.cutting(a,b)):void cc.log(cc._LogInfos.CCSpriteBatchNode_insertQuadFromSprite)},initWithTexture:function(a,b){return this._children.length=0,this._descendants.length=0,b=b||cc.SpriteBatchNode.DEFAULT_CAPACITY,this._renderCmd.initWithTexture(a,b),!0},insertChild:function(a,b){a.batchNode=this,a.atlasIndex=b,a.dirty=!0,this._renderCmd.insertQuad(a,b),this._descendants.splice(b,0,a);var c=b+1,d=this._descendants;if(d&&d.length>0)for(;cc;c++)if(e=g[c]){var h=this.atlasIndexForChild(e,e.zIndex);this.insertChild(e,h)}},appendChild:function(a){this._reorderChildDirty=!0,a.batchNode=this,a.dirty=!0,this._descendants.push(a);var b=this._descendants.length-1;a.atlasIndex=b,this._renderCmd.insertQuad(a,b);for(var c=a.children,d=0,e=c.length||0;e>d;d++)this.appendChild(c[d])},removeSpriteFromAtlas:function(a){this._renderCmd.removeQuadAtIndex(a.atlasIndex),a.batchNode=null;var b=this._descendants,c=b.indexOf(a);if(-1!==c){b.splice(c,1);for(var d=b.length;d>c;++c){var e=b[c];e.atlasIndex--}}var f=a.children;if(f)for(var g=0,h=f.length||0;h>g;g++)f[g]&&this.removeSpriteFromAtlas(f[g])},getTexture:function(){return this._renderCmd.getTexture()},setTexture:function(a){this._renderCmd.setTexture(a)},addChild:function(a,b,c){cc.assert(null!=a,cc._LogInfos.CCSpriteBatchNode_addChild_3),this._renderCmd.isValidChild(a)&&(b=null==b?a.zIndex:b,c=null==c?a.tag:c,cc.Node.prototype.addChild.call(this,a,b,c),this.appendChild(a))},removeAllChildren:function(a){var b=this._descendants;if(b&&b.length>0)for(var c=0,d=b.length;d>c;c++)b[c]&&(b[c].batchNode=null);cc.Node.prototype.removeAllChildren.call(this,a),this._descendants.length=0,this._renderCmd.removeAllQuads()},sortAllChildren:function(){if(this._reorderChildDirty){var a,b,c=this._children,d=0,e=c.length;for(a=1;e>a;a++){var f=c[a];for(d=a-1,b=c[d];d>=0&&(f._localZOrder0&&(this._arrayMakeObjectsPerformSelector(c,cc.Node._stateCallbackType.sortAllChildren),this._renderCmd.updateChildrenAtlasIndex(c)),this._reorderChildDirty=!1}},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.SpriteBatchNode.CanvasRenderCmd(this):new cc.SpriteBatchNode.WebGLRenderCmd(this)}});var _p=cc.SpriteBatchNode.prototype;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture),cc.defineGetterSetter(_p,"textureAtlas",_p.getTextureAtlas,_p.setTextureAtlas),_p.descendants,cc.defineGetterSetter(_p,"descendants",_p.getDescendants),cc.SpriteBatchNode.DEFAULT_CAPACITY=29,cc.SpriteBatchNode.create=function(a,b){return new cc.SpriteBatchNode(a,b)},cc.SpriteBatchNode.createWithTexture=cc.SpriteBatchNode.create,function(){cc.SpriteBatchNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._texture=null,this._textureToRender=null};var a=cc.SpriteBatchNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.SpriteBatchNode.CanvasRenderCmd,a.checkAtlasCapacity=function(){},a.isValidChild=function(a){return a instanceof cc.Sprite?!0:(cc.log(cc._LogInfos.Sprite_addChild_4),!1)},a.initWithTexture=function(a,b){this._textureToRender=this._texture=a},a.insertQuad=function(a,b){},a.increaseAtlasCapacity=function(){},a.removeQuadAtIndex=function(){},a.removeAllQuads=function(){},a.getTexture=function(){return this._texture},a.setTexture=function(a){this._texture=a;for(var b=this._node._children,c=0;cb;b++)this._updateAtlasIndex(a[b])},a._updateAtlasIndex=function(a){var b,c=this._node._descendants,d=a.children,e=d.length;for(b=0;e>b&&d[b]._localZOrder<0;b++)c.push(d[b]);for(c.push(a);e>b;b++)c.push(d[b])},a.getTextureAtlas=function(){},a.setTextureAtlas=function(a){},a.cutting=function(a,b){var c=this._node;c._children.splice(b,0,a)}}();!function(){cc.SpriteBatchNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._textureAtlas=null};var a=cc.SpriteBatchNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.SpriteBatchNode.WebGLRenderCmd,a.isValidChild=function(a){return a instanceof cc.Sprite?a.texture!=this.getTexture()?(cc.log(cc._LogInfos.Sprite_addChild_5),!1):!0:(cc.log(cc._LogInfos.Sprite_addChild_4),!1)},a.rendering=function(){var a=this._node;0!==this._textureAtlas.totalQuads&&(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),a._arrayMakeObjectsPerformSelector(a._children,cc.Node._stateCallbackType.updateTransform),cc.glBlendFunc(a._blendFunc.src,a._blendFunc.dst),this._textureAtlas.drawQuads())},a.visit=function(a){var b=this._node;if(b._visible){b._parent&&b._parent._renderCmd&&(this._curLevel=b._parent._renderCmd._curLevel+1);var c=cc.current_stack;c.stack.push(c.top),this._dirtyFlag&cc.Node._dirtyFlags.transformDirty||this.transform(a),this.updateStatus(a),c.top=this._stackMatrix,b.sortAllChildren(),cc.renderer.pushRenderCommand(this),this._dirtyFlag=0,c.top=c.stack.pop()}},a.checkAtlasCapacity=function(a){for(var b=this._textureAtlas;a>=b.capacity||b.capacity===b.totalQuads;)this.increaseAtlasCapacity()},a.increaseAtlasCapacity=function(){var a=this._textureAtlas.capacity,b=Math.floor(4*(a+1)/3);cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity,a,b),this._textureAtlas.resizeCapacity(b)||cc.log(cc._LogInfos.SpriteBatchNode_increaseAtlasCapacity_2)},a.initWithTexture=function(a,b){this._textureAtlas=new cc.TextureAtlas,this._textureAtlas.initWithTexture(a,b),this._updateBlendFunc(),this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)},a.insertQuad=function(a,b){var c=this._textureAtlas;c.totalQuads>=c.capacity&&this.increaseAtlasCapacity(),c.insertQuad(a.quad,b)},a.removeQuadAtIndex=function(a){this._textureAtlas.removeQuadAtIndex(a)},a.getTexture=function(){return this._textureAtlas.texture},a.setTexture=function(a){this._textureAtlas.setTexture(a),a&&this._updateBlendFunc()},a.removeAllQuads=function(){this._textureAtlas.removeAllQuads()},a._swap=function(a,b){var c=this._node._descendants,d=this._textureAtlas,e=d.quads,f=c[a],g=cc.V3F_C4B_T2F_QuadCopy(e[a]);c[b].atlasIndex=a,c[a]=c[b],d.updateQuad(e[b],a),c[b]=f,d.updateQuad(g,b)},a._updateAtlasIndex=function(a,b){var c=0,d=a.children;d&&(c=d.length);var e=0;if(0===c)e=a.atlasIndex,a.atlasIndex=b,a.arrivalOrder=0,e!==b&&this._swap(e,b),b++;else{var f=!0;d[0].zIndex>=0&&(e=a.atlasIndex,a.atlasIndex=b,a.arrivalOrder=0,e!==b&&this._swap(e,b),b++,f=!1);for(var g=0;g=0&&(e=a.atlasIndex,a.atlasIndex=b,a.arrivalOrder=0,e!==b&&this._swap(e,b),b++,f=!1),b=this._updateAtlasIndex(h,b)}f&&(e=a.atlasIndex,a.atlasIndex=b,a.arrivalOrder=0,e!==b&&this._swap(e,b),b++)}return b},a.updateChildrenAtlasIndex=function(a){for(var b=0,c=0;cg;g++){var i=b.charCodeAt(g)-a._mapStartChar.charCodeAt(0),j=parseInt(i%a._itemsPerRow,10),k=parseInt(i/a._itemsPerRow,10);if(!(0>j||0>k)){var l=cc.rect(j*e,k*f,e,f),m=d._contentSize;if(!(l.x<0||l.y<0||l.x+l.width>m.width||l.y+l.height>m.height)){h++;var n=b.charCodeAt(g),o=a.getChildByTag(g);o?32===n?(o.init(),o.setTextureRect(cc.rect(0,0,10,10),!1,cc.size(0,0))):(o.initWithTexture(d,l),o.visible=!0):(o=new cc.Sprite,32===n?(o.init(),o.setTextureRect(cc.rect(0,0,10,10),!1,cc.size(0,0))):o.initWithTexture(d,l),cc.Node.prototype.addChild.call(a,o,0,g)),o.setPosition(h*e+e/2,f/2)}}}this.updateContentSize(g,h+1)},a.updateContentSize=function(a,b){var c=this._node,d=c._contentSize;a!==b&&a*c._itemWidth===d.width&&c._itemHeight===d.height&&c.setContentSize(b*c._itemWidth,c._itemHeight)},a.setString=function(a){var b=this._node;if(b._children)for(var c=b._children,d=c.length,e=0;d>e;e++){var f=c[e];f&&!f._lateChild&&(f.visible=!1)}},a._addChild=function(){child._lateChild=!0}}(),cc.LABEL_AUTOMATIC_WIDTH=-1,cc.LabelBMFont=cc.SpriteBatchNode.extend({_opacityModifyRGB:!1,_string:"",_config:null,_fntFile:"",_initialString:"",_alignment:cc.TEXT_ALIGNMENT_CENTER,_width:-1,_lineBreakWithoutSpaces:!1,_imageOffset:null,_reusedChar:null,_textureLoaded:!1,_className:"LabelBMFont",_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.LabelBMFont.WebGLRenderCmd(this):new cc.LabelBMFont.CanvasRenderCmd(this)},_setString:function(a,b){b?this._initialString=a:this._string=a;var c=this._children;if(c)for(var d=0;dj;j++)10===h.charCodeAt(j)&&g++;var o=m*g,p=-(m-m*g),q=-1;for(j=0;i>j;j++){var r=h.charCodeAt(j);if(0!==r)if(10!==r){var s=l[q<<16|65535&r]||0,t=n[r];t||(cc.log("cocos2d: LabelBMFont: character not found "+h[j]),t={rect:{x:0,y:0,width:0,height:0},xOffset:0,yOffset:0,xAdvance:0});var u=cc.rect(t.rect.x,t.rect.y,t.rect.width,t.rect.height);u=cc.rectPixelsToPoints(u),u.x+=a._imageOffset.x,u.y+=a._imageOffset.y;var v=a.getChildByTag(j);v?this._renderCmd._updateCharTexture(v,u,r):(v=new cc.Sprite,v.initWithTexture(c,u,!1),v._newTextureWhenChangeColor=!0,this.addChild(v,0,j)),v.opacityModifyRGB=this._opacityModifyRGB,this._renderCmd._updateCharColorAndOpacity(v);var w=k.commonHeight-t.yOffset,x=cc.p(d+t.xOffset+.5*t.rect.width+s,p+w-.5*u.height*cc.contentScaleFactor());v.setPosition(cc.pointPixelsToPoints(x)),d+=t.xAdvance+s,q=r,d>f&&(f=d)}else d=0,p-=k.commonHeight}t&&t.xAdvanced;d++){var f=c[d];f&&(f.visible=!1)}b._config&&b.createFontChars(),a||b.updateLabel()},getString:function(){return this._initialString},setString:function(a,b){a=String(a),null==b&&(b=!0),null!=a&&cc.isString(a)||(a+=""),this._initialString=a,this._setString(a,b)},_setStringForSetter:function(a){this.setString(a,!1)},setCString:function(a){this.setString(a,!0)},_getCharsWidth:function(a,b){if(0>=b)return 0;var c=this.getChildByTag(a),d=this.getChildByTag(a+b);return this._getLetterPosXLeft(d)-this._getLetterPosXLeft(c)},_checkWarp:function(a,b,c,d){for(var e=this,f=a[b],g=0,h=0;b>h;h++)g+=a[h].length;g=g+b-d;var i=e._getCharsWidth(g,a[b].length-1);if(i>c&&f.length>1){for(var j,k=f.length*(c/i)|0,l=f.substr(k),m=i-this._getCharsWidth(g+k,l.length-1),n=0,o=0;m>c&&o++<100;)k*=c/m,k=0|k,l=f.substr(k),m=i-this._getCharsWidth(g+k,l.length-1);for(o=0;c>m&&o++<100;){if(l){var p=cc.LabelTTF._wordRex.exec(l);n=p?p[0].length:1,j=l}e._lineBreakWithoutSpaces&&(n=0),k+=n,l=f.substr(k),m=i-this._getCharsWidth(g+k,l.length-1)}k-=n,0===k&&(k=1,j=j.substr(1));var q,r=f.substr(0,k);cc.LabelTTF.wrapInspection&&cc.LabelTTF._symbolRex.test(j||l)&&(q=cc.LabelTTF._lastWordRex.exec(r),n=q?q[0].length:0,e._lineBreakWithoutSpaces&&(n=0),k-=n,j=f.substr(k),r=f.substr(0,k)),cc.LabelTTF._firsrEnglish.test(j)&&(q=cc.LabelTTF._lastEnglish.exec(r),q&&r!==q[0]&&(n=q[0].length,e._lineBreakWithoutSpaces&&(n=0),k-=n,j=f.substr(k),r=f.substr(0,k))),a[b]=j||l,a.splice(b,0,r)}},updateLabel:function(){var a=this;a.string=a._initialString;var b,c,d;if(a._width>0){var e=a.string.split("\n"),f="",g=0,h=0;for(b=0;b0&&(f+="\n"),f+=e[b];f+=String.fromCharCode(0),a._setString(f,!1)}if(a._alignment!==cc.TEXT_ALIGNMENT_LEFT){b=0;for(var i=0,j=a._string.length,k=[],l=0;j>l;l++)if(10!==a._string[l].charCodeAt(0)&&0!==a._string[l].charCodeAt(0))k.push(a._string[b]);else{var m=0,n=k.length;if(0===n){i++;continue}var o=b+n-1+i;if(0>o)continue;var p=a.getChildByTag(o);if(null==p)continue;m=p.getPositionX()+p._getWidth()/2;var q=0;switch(a._alignment){case cc.TEXT_ALIGNMENT_CENTER:q=a.width/2-m/2;break;case cc.TEXT_ALIGNMENT_RIGHT:q=a.width-m}if(0!==q)for(c=0;n>c;c++)o=b+c+i,0>o||(d=a.getChildByTag(o),d&&(d.x+=q));b+=n,i++,k.length=0}}},setAlignment:function(a){this._alignment=a,this.updateLabel()},_getAlignment:function(){return this._alignment},setBoundingWidth:function(a){this._width=a,this.updateLabel()},_getBoundingWidth:function(){return this._width},setLineBreakWithoutSpace:function(a){this._lineBreakWithoutSpaces=a,this.updateLabel()},setScale:function(a,b){cc.Node.prototype.setScale.call(this,a,b),this.updateLabel()},setScaleX:function(a){cc.Node.prototype.setScaleX.call(this,a),this.updateLabel()},setScaleY:function(a){cc.Node.prototype.setScaleY.call(this,a),this.updateLabel()},setFntFile:function(a){var b=this;if(null!=a&&a!==b._fntFile){var c=cc.loader.getRes(a);if(!c)return void cc.log("cc.LabelBMFont.setFntFile() : Impossible to create font. Please check file");b._fntFile=a,b._config=c;var d=cc.textureCache.addImage(c.atlasName),e=d.isLoaded();b._textureLoaded=e,b.texture=d,e?b.createFontChars():d.addEventListener("load",function(a){var b=this;b._textureLoaded=!0,b.texture=a,b.createFontChars(),b._changeTextureColor(),b.updateLabel(),b.dispatchEvent("load")},b)}},getFntFile:function(){return this._fntFile},setTexture:function(a){this._renderCmd.setTexture(a)},setAnchorPoint:function(a,b){cc.Node.prototype.setAnchorPoint.call(this,a,b),this.updateLabel()},_setAnchorX:function(a){cc.Node.prototype._setAnchorX.call(this,a),this.updateLabel()},_setAnchorY:function(a){cc.Node.prototype._setAnchorY.call(this,a),this.updateLabel()},_atlasNameFromFntFile:function(a){},_kerningAmountForFirst:function(a,b){var c=0,d=a<<16|65535&b;if(this._configuration.kerningDictionary){var e=this._configuration.kerningDictionary[d.toString()];e&&(c=e.amount)}return c},_getLetterPosXLeft:function(a){return a.getPositionX()*this._scaleX-a._getWidth()*this._scaleX*a._getAnchorX()},_getLetterPosXRight:function(a){return a.getPositionX()*this._scaleX+a._getWidth()*this._scaleX*a._getAnchorX()},_isspace_unicode:function(a){return a=a.charCodeAt(0),a>=9&&13>=a||32===a||133===a||160===a||5760===a||a>=8192&&8202>=a||8232===a||8233===a||8239===a||8287===a||12288===a},_utf8_trim_ws:function(a){var b=a.length;if(!(0>=b)){var c=b-1;if(this._isspace_unicode(a[c])){for(var d=c-1;d>=0&&this._isspace_unicode(a[d]);--d)c=d;this._utf8_trim_from(a,c)}}},_utf8_trim_from:function(a,b){var c=a.length;b>=c||0>b||a.splice(b,c)}}),function(){var a=cc.LabelBMFont.prototype;cc.EventHelper.prototype.apply(a),a.string,cc.defineGetterSetter(a,"string",a.getString,a._setStringForSetter),a.boundingWidth,cc.defineGetterSetter(a,"boundingWidth",a._getBoundingWidth,a.setBoundingWidth),a.textAlign,cc.defineGetterSetter(a,"textAlign",a._getAlignment,a.setAlignment)}(),cc.LabelBMFont.create=function(a,b,c,d,e){return new cc.LabelBMFont(a,b,c,d,e)},cc._fntLoader={INFO_EXP:/info [^\n]*(\n|$)/gi,COMMON_EXP:/common [^\n]*(\n|$)/gi,PAGE_EXP:/page [^\n]*(\n|$)/gi,CHAR_EXP:/char [^\n]*(\n|$)/gi,KERNING_EXP:/kerning [^\n]*(\n|$)/gi,ITEM_EXP:/\w+=[^ \r\n]+/gi,INT_EXP:/^[\-]?\d+$/,_parseStrToObj:function(a){var b=a.match(this.ITEM_EXP),c={};if(b)for(var d=0,e=b.length;e>d;d++){var f=b[d],g=f.indexOf("="),h=f.substring(0,g),i=f.substring(g+1);i.match(this.INT_EXP)?i=parseInt(i):'"'===i[0]&&(i=i.substring(1,i.length-1)),c[h]=i}return c},parseFnt:function(a,b){var c=this,d={},e=c._parseStrToObj(a.match(c.INFO_EXP)[0]),f=e.padding.split(","),g=({left:parseInt(f[0]),top:parseInt(f[1]),right:parseInt(f[2]),bottom:parseInt(f[3])},c._parseStrToObj(a.match(c.COMMON_EXP)[0]));if(d.commonHeight=g.lineHeight,cc._renderType===cc.game.RENDER_TYPE_WEBGL){var h=cc.configuration.getMaxTextureSize();(g.scaleW>h.width||g.scaleH>h.height)&&cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported")}1!==g.pages&&cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");var i=c._parseStrToObj(a.match(c.PAGE_EXP)[0]);0!==i.id&&cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found"),d.atlasName=cc.path.changeBasename(b,i.file);for(var j=a.match(c.CHAR_EXP),k=d.fontDefDictionary={},l=0,m=j.length;m>l;l++){var n=c._parseStrToObj(j[l]),o=n.id;k[o]={rect:{x:n.x,y:n.y,width:n.width,height:n.height},xOffset:n.xoffset,yOffset:n.yoffset,xAdvance:n.xadvance}}var p=d.kerningDict={},q=a.match(c.KERNING_EXP);if(q)for(var l=0,m=q.length;m>l;l++){var r=c._parseStrToObj(q[l]);p[r.first<<16|65535&r.second]=r.amount}return d},load:function(a,b,c,d){var e=this;cc.loader.loadTxt(a,function(a,c){return a?d(a):void d(null,e.parseFnt(c,b))})}},cc.loader.register(["fnt"],cc._fntLoader),function(){cc.LabelBMFont.CanvasRenderCmd=function(a){cc.SpriteBatchNode.CanvasRenderCmd.call(this,a),this._needDraw=!0};var a=cc.LabelBMFont.CanvasRenderCmd.prototype=Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype);a.constructor=cc.LabelBMFont.CanvasRenderCmd,a.rendering=function(){},a._updateCharTexture=function(a,b,c){32===c?a.setTextureRect(b,!1,cc.size(0,0)):(a.setTextureRect(b,!1),a.visible=!0)},a._updateCharColorAndOpacity=function(a){a._displayedColor=this._displayedColor,a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty),a._displayedOpacity=this._displayedOpacity,a._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},a.setTexture=function(a){for(var b=this._node,c=b._children,d=this._displayedColor,e=0;e0){if(!e)return;this._textureToRender=d._generateColorTexture(f.r,f.g,f.b,g)}},a._updateChildrenDisplayedOpacity=function(a){cc.Node.prototype.updateDisplayedOpacity.call(a,this._displayedOpacity)},a._updateChildrenDisplayedColor=function(a){cc.Node.prototype.updateDisplayedColor.call(a,this._displayedColor)},a._initBatchTexture=function(){}}();!function(){cc.LabelAtlas.WebGLRenderCmd=function(a){cc.AtlasNode.WebGLRenderCmd.call(this,a),this._needDraw=!0};var a=cc.LabelAtlas.WebGLRenderCmd.prototype=Object.create(cc.AtlasNode.WebGLRenderCmd.prototype);a.constructor=cc.LabelAtlas.WebGLRenderCmd,a.setCascade=function(){var a=this._node;a._cascadeOpacityEnabled=!0,a._cascadeColorEnabled=!0},a.rendering=function(a){if(cc.AtlasNode.WebGLRenderCmd.prototype.rendering.call(this,a),cc.LABELATLAS_DEBUG_DRAW){var b=this._node,c=b.getContentSize(),d=b.getBoundingBoxToWorld(),e=d.x,f=d.y;c.width=d.width,c.height=d.height;var g=[cc.p(e,f),cc.p(e+c.width,f),cc.p(c.width+e,c.height+f),cc.p(e,f+c.height)];cc._drawingUtil.drawPoly(g,4,!0)}},a.updateAtlasValues=function(){var a=this._node,b=a._string,c=b.length,d=this._textureAtlas,e=d.texture,f=e.pixelsWidth,g=e.pixelsHeight,h=a._itemWidth,i=a._itemHeight;a._ignoreContentScaleFactor||(h=a._itemWidth*cc.contentScaleFactor(),i=a._itemHeight*cc.contentScaleFactor()),c>d.getCapacity()&&cc.log("cc.LabelAtlas._updateAtlasValues(): Invalid String length");for(var j=d.quads,k=this._displayedColor,l={r:k.r,g:k.g,b:k.b,a:a._displayedOpacity},m=a._itemWidth,n=a._itemHeight,o=0,p=-1;c>o;o++){var q=b.charCodeAt(o)-a._mapStartChar.charCodeAt(0),r=q%a._itemsPerRow,s=0|q/a._itemsPerRow;if(!(0>r||0>s||r*m+m>f||s*n+n>g)){p++;var t,u,v,w;cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(t=(2*r*h+1)/(2*f),u=t+(2*h-2)/(2*f),v=(2*s*i+1)/(2*g),w=v+(2*i-2)/(2*g)):(t=r*h/f,u=t+h/f,v=s*i/g,w=v+i/g);var x=j[o],y=x.tl,z=x.tr,A=x.bl,B=x.br;y.texCoords.u=t,y.texCoords.v=v,z.texCoords.u=u,z.texCoords.v=v,A.texCoords.u=t,A.texCoords.v=w,B.texCoords.u=u,B.texCoords.v=w,A.vertices.x=p*m,A.vertices.y=0,A.vertices.z=0,B.vertices.x=p*m+m,B.vertices.y=0,B.vertices.z=0,y.vertices.x=p*m,y.vertices.y=a._itemHeight,y.vertices.z=0,z.vertices.x=p*m+m,z.vertices.y=a._itemHeight,z.vertices.z=0,y.colors=l,z.colors=l,A.colors=l,B.colors=l}}if(this.updateContentSize(o,p+1),c>0){d.dirty=!0;var C=d.totalQuads;c>C&&d.increaseTotalQuadsWith(c-C)}},a.updateContentSize=function(a,b){var c=this._node,d=c._contentSize;a!==b&&a*c._itemWidth===d.width&&c._itemHeight===d.height&&c.setContentSize(b*c._itemWidth,c._itemHeight)},a.setString=function(a){var b=a.length;b>this._textureAtlas.totalQuads&&this._textureAtlas.resizeCapacity(b)},a._addChild=function(){}}(),function(){cc.LabelBMFont.WebGLRenderCmd=function(a){cc.SpriteBatchNode.WebGLRenderCmd.call(this,a),this._needDraw=!0};var a=cc.LabelBMFont.WebGLRenderCmd.prototype=Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype);a.constructor=cc.LabelBMFont.WebGLRenderCmd,a._updateCharTexture=function(a,b,c){a.setTextureRect(b,!1),a.visible=!0},a._changeTextureColor=function(){},a._updateChildrenDisplayedOpacity=function(a){a.updateDisplayedOpacity(this._displayedOpacity)},a._updateChildrenDisplayedColor=function(a){a.updateDisplayedColor(this._displayedColor)},a._initBatchTexture=function(){var a=this._node,b=a.textureAtlas.texture;a._opacityModifyRGB=b.hasPremultipliedAlpha();var c=a._reusedChar=new cc.Sprite;c.initWithTexture(b,cc.rect(0,0,0,0),!1),c.batchNode=a},a.rendering=function(a){cc.SpriteBatchNode.WebGLRenderCmd.prototype.rendering.call(this,a);var b=this._node;if(cc.LABELBMFONT_DEBUG_DRAW){var c=b.getContentSize(),d=cc.p(0|-this._anchorPointInPoints.x,0|-this._anchorPointInPoints.y),e=[cc.p(d.x,d.y),cc.p(d.x+c.width,d.y),cc.p(d.x+c.width,d.y+c.height),cc.p(d.x,d.y+c.height)];cc._drawingUtil.setDrawColor(0,255,0,255),cc._drawingUtil.drawPoly(e,4,!0)}},a._updateCharColorAndOpacity=function(){}}();cc.MotionStreak=cc.Node.extend({texture:null,fastMode:!1,startingPositionInitialized:!1,_blendFunc:null,_stroke:0,_fadeDelta:0,_minSeg:0,_maxPoints:0,_nuPoints:0,_previousNuPoints:0,_pointVertexes:null,_pointState:null,_vertices:null,_colorPointer:null,_texCoords:null,_verticesBuffer:null,_colorPointerBuffer:null,_texCoordsBuffer:null,_className:"MotionStreak",ctor:function(a,b,c,d,e){cc.Node.prototype.ctor.call(this),this._positionR=cc.p(0,0),this._blendFunc=new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA),this.fastMode=!1,this.startingPositionInitialized=!1,this.texture=null,this._stroke=0,this._fadeDelta=0,this._minSeg=0,this._maxPoints=0,this._nuPoints=0,this._previousNuPoints=0,this._pointVertexes=null,this._pointState=null,this._vertices=null,this._colorPointer=null,this._texCoords=null,this._verticesBuffer=null,this._colorPointerBuffer=null,this._texCoordsBuffer=null,void 0!==e&&this.initWithFade(a,b,c,d,e)},getTexture:function(){return this.texture},setTexture:function(a){this.texture!==a&&(this.texture=a)},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?this._blendFunc=a:(this._blendFunc.src=a,this._blendFunc.dst=b)},getOpacity:function(){return cc.log("cc.MotionStreak.getOpacity has not been supported."),0},setOpacity:function(a){cc.log("cc.MotionStreak.setOpacity has not been supported.")},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},isFastMode:function(){return this.fastMode},setFastMode:function(a){this.fastMode=a},isStartingPositionInitialized:function(){return this.startingPositionInitialized},setStartingPositionInitialized:function(a){this.startingPositionInitialized=a},getStroke:function(){return this._stroke},setStroke:function(a){this._stroke=a},initWithFade:function(a,b,c,d,e){if(!e)throw new Error("cc.MotionStreak.initWithFade(): Invalid filename or texture");cc.isString(e)&&(e=cc.textureCache.addImage(e)),cc.Node.prototype.setPosition.call(this,cc.p(0,0)),this.anchorX=0,this.anchorY=0,this.ignoreAnchor=!0,this.startingPositionInitialized=!1,this.fastMode=!0,this._minSeg=-1===b?c/5:b,this._minSeg*=this._minSeg,this._stroke=c,this._fadeDelta=1/a;var f=(0|60*a)+2;return this._maxPoints=f,this._nuPoints=0,this._pointState=new Float32Array(f),this._pointVertexes=new Float32Array(2*f),this._vertices=new Float32Array(4*f),this._texCoords=new Float32Array(4*f),this._colorPointer=new Uint8Array(8*f),this._verticesBuffer=gl.createBuffer(),this._texCoordsBuffer=gl.createBuffer(),this._colorPointerBuffer=gl.createBuffer(),this._blendFunc.src=gl.SRC_ALPHA,this._blendFunc.dst=gl.ONE_MINUS_SRC_ALPHA,this.texture=e,this.color=d,this.scheduleUpdate(),gl.bindBuffer(gl.ARRAY_BUFFER,this._verticesBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._vertices,gl.DYNAMIC_DRAW),gl.bindBuffer(gl.ARRAY_BUFFER,this._texCoordsBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._texCoords,gl.DYNAMIC_DRAW),gl.bindBuffer(gl.ARRAY_BUFFER,this._colorPointerBuffer),gl.bufferData(gl.ARRAY_BUFFER,this._colorPointer,gl.DYNAMIC_DRAW),!0},tintWithColor:function(a){this.color=a;for(var b=this._colorPointer,c=0,d=2*this._nuPoints;d>c;c++)b[4*c]=a.r,b[4*c+1]=a.g,b[4*c+2]=a.b},reset:function(){this._nuPoints=0},setPosition:function(a,b){this.startingPositionInitialized=!0,void 0===b?(this._positionR.x=a.x,this._positionR.y=a.y):(this._positionR.x=a,this._positionR.y=b)},getPositionX:function(){return this._positionR.x},setPositionX:function(a){this._positionR.x=a,this.startingPositionInitialized||(this.startingPositionInitialized=!0)},getPositionY:function(){return this._positionR.y},setPositionY:function(a){this._positionR.y=a,this.startingPositionInitialized||(this.startingPositionInitialized=!0)},update:function(a){if(this.startingPositionInitialized){this._renderCmd._updateDisplayColor(),a*=this._fadeDelta;var b,c,d,e,f=0,g=this._nuPoints,h=this._pointState,i=this._pointVertexes,j=this._vertices,k=this._colorPointer;for(d=0;g>d;d++)if(h[d]-=a,h[d]<=0)f++;else{b=d-f,f>0?(h[b]=h[d],i[2*b]=i[2*d],i[2*b+1]=i[2*d+1],e=2*d,c=2*b,j[2*c]=j[2*e],j[2*c+1]=j[2*e+1],j[2*(c+1)]=j[2*(e+1)],j[2*(c+1)+1]=j[2*(e+1)+1],e*=4,c*=4,k[c+0]=k[e+0],k[c+1]=k[e+1],k[c+2]=k[e+2],k[c+4]=k[e+4],k[c+5]=k[e+5],k[c+6]=k[e+6]):c=8*b;var l=255*h[b];k[c+3]=l,k[c+7]=l}g-=f;var m=!0;if(g>=this._maxPoints)m=!1;else if(g>0){var n=cc.pDistanceSQ(cc.p(i[2*(g-1)],i[2*(g-1)+1]),this._positionR)0&&this.fastMode&&(g>1?cc.vertexLineToPolygon(i,this._stroke,this._vertices,g,1):cc.vertexLineToPolygon(i,this._stroke,this._vertices,0,2)),g++}if(this.fastMode||cc.vertexLineToPolygon(i,this._stroke,this._vertices,0,g),g&&this._previousNuPoints!==g){var r=1/g,s=this._texCoords;for(d=0;g>d;d++)s[4*d]=0,s[4*d+1]=r*d,s[2*(2*d+1)]=1,s[2*(2*d+1)+1]=r*d;this._previousNuPoints=g}this._nuPoints=g}},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.MotionStreak.WebGLRenderCmd(this):null}}),cc.MotionStreak.create=function(a,b,c,d,e){return new cc.MotionStreak(a,b,c,d,e)},cc.MotionStreak.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)},cc.MotionStreak.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype),cc.MotionStreak.WebGLRenderCmd.prototype.constructor=cc.Sprite.WebGLRenderCmd,cc.MotionStreak.WebGLRenderCmd.prototype.rendering=function(a){var b=this._node;b._nuPoints<=1||b.texture&&b.texture.isLoaded()&&(a=a||cc._renderContext,this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst),cc.glBindTexture2D(b.texture),a.bindBuffer(a.ARRAY_BUFFER,b._verticesBuffer),a.bufferData(a.ARRAY_BUFFER,b._vertices,a.DYNAMIC_DRAW),a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,b._texCoordsBuffer),a.bufferData(a.ARRAY_BUFFER,b._texCoords,a.DYNAMIC_DRAW),a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,0,0),a.bindBuffer(a.ARRAY_BUFFER,b._colorPointerBuffer),a.bufferData(a.ARRAY_BUFFER,b._colorPointer,a.DYNAMIC_DRAW),a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,0,0),a.drawArrays(a.TRIANGLE_STRIP,0,2*b._nuPoints),cc.g_NumberOfDraws++)};cc.NodeGrid=cc.Node.extend({grid:null,_target:null,_gridRect:null,ctor:function(a){cc.Node.prototype.ctor.call(this),void 0===a&&(a=cc.rect()),this._gridRect=a},getGrid:function(){return this.grid},setGrid:function(a){this.grid=a},setGridRect:function(a){this._gridRect=a},getGridRect:function(){return this._gridRect},setTarget:function(a){this._target=a},_transformForWebGL:function(){var a=this._transform4x4,b=cc.current_stack.top,c=this.getNodeToParentTransform(),d=a.mat;if(d[0]=c.a,d[4]=c.c,d[12]=c.tx,d[1]=c.b,d[5]=c.d,d[13]=c.ty,d[14]=this._vertexZ,b.multiply(a),!(null===this._camera||this.grid&&this.grid.isActive())){var e=this._renderCmd._anchorPointInPoints,f=e.x,g=e.y,h=0!==f||0!==g;h?(cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(f=0|f,g=0|g),cc.kmGLTranslatef(f,g,0),this._camera.locate(),cc.kmGLTranslatef(-f,-g,0)):this._camera.locate()}},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new cc.NodeGrid.WebGLRenderCmd(this):new cc.Node.CanvasRenderCmd(this)}});var _p=cc.NodeGrid.prototype;_p.grid,_p.target,cc.defineGetterSetter(_p,"target",null,_p.setTarget),cc.NodeGrid.create=function(){return new cc.NodeGrid},function(){cc.NodeGrid.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!1,this._gridBeginCommand=new cc.CustomRenderCmd(this,this.onGridBeginDraw),this._gridEndCommand=new cc.CustomRenderCmd(this,this.onGridEndDraw)};var a=cc.NodeGrid.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.NodeGrid.WebGLRenderCmd,a.visit=function(a){var b=this._node;if(b._visible){a=a||this.getParentRenderCmd(),b._parent&&b._parent._renderCmd&&(this._curLevel=b._parent._renderCmd._curLevel+1);var c=cc.current_stack;c.stack.push(c.top),this._syncStatus(a),c.top=this._stackMatrix,cc.renderer.pushRenderCommand(this._gridBeginCommand),b._target&&b._target.visit();var d=b._children;if(d&&d.length>0){var e=d.length;b.sortAllChildren();for(var f=0;e>f;f++){var g=d[f];g&&g.visit()}}cc.renderer.pushRenderCommand(this._gridEndCommand),this._dirtyFlag=0,c.top=c.stack.pop()}},a.onGridBeginDraw=function(){var a=this._node.grid;a&&a._active&&a.beforeDraw()},a.onGridEndDraw=function(){var a=this._node.grid;a&&a._active&&a.afterDraw(this._node)}}();cc.v2fzero=function(){return{x:0,y:0}},cc.v2f=function(a,b){return{x:a,y:b}},cc.v2fadd=function(a,b){return cc.v2f(a.x+b.x,a.y+b.y)},cc.v2fsub=function(a,b){return cc.v2f(a.x-b.x,a.y-b.y)},cc.v2fmult=function(a,b){return cc.v2f(a.x*b,a.y*b)},cc.v2fperp=function(a){return cc.v2f(-a.y,a.x)},cc.v2fneg=function(a){return cc.v2f(-a.x,-a.y)},cc.v2fdot=function(a,b){return a.x*b.x+a.y*b.y},cc.v2fforangle=function(a){return cc.v2f(Math.cos(a),Math.sin(a))},cc.v2fnormalize=function(a){var b=cc.pNormalize(cc.p(a.x,a.y));return cc.v2f(b.x,b.y)},cc.__v2f=function(a){return cc.v2f(a.x,a.y)},cc.__t=function(a){return{u:a.x,v:a.y}},cc.DrawNode=cc.Node.extend({_buffer:null,_blendFunc:null,_lineWidth:1,_drawColor:null,getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?(this._blendFunc.src=a.src,this._blendFunc.dst=a.dst):(this._blendFunc.src=a,this._blendFunc.dst=b)},setLineWidth:function(a){this._lineWidth=a},getLineWidth:function(){return this._lineWidth},setDrawColor:function(a){var b=this._drawColor;b.r=a.r,b.g=a.g,b.b=a.b,b.a=null==a.a?255:a.a},getDrawColor:function(){return cc.color(this._drawColor.r,this._drawColor.g,this._drawColor.b,this._drawColor.a)}}),cc.DrawNode.create=function(){return new cc.DrawNode},cc.DrawNode.TYPE_DOT=0,cc.DrawNode.TYPE_SEGMENT=1,cc.DrawNode.TYPE_POLY=2,cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){cc._renderType===cc.game.RENDER_TYPE_CANVAS?(cc._DrawNodeElement=function(a,b,c,d,e,f,g,h,i){var j=this;j.type=a,j.verts=b||null,j.fillColor=c||null,j.lineWidth=d||0,j.lineColor=e||null,j.lineCap=f||"butt",j.isClosePolygon=g||!1,j.isFill=h||!1,j.isStroke=i||!1},cc.extend(cc.DrawNode.prototype,{_className:"DrawNodeCanvas",ctor:function(){cc.Node.prototype.ctor.call(this);var a=this._renderCmd;a._buffer=this._buffer=[],a._drawColor=this._drawColor=cc.color(255,255,255,255),a._blendFunc=this._blendFunc=new cc.BlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA),this.init()},drawRect:function(a,b,c,d,e){d=null==d?this._lineWidth:d,e=e||this.getDrawColor(),null==e.a&&(e.a=255);var f=[a,cc.p(b.x,a.y),b,cc.p(a.x,b.y)],g=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);g.verts=f,g.lineWidth=d,g.lineColor=e,g.isClosePolygon=!0,g.isStroke=!0,g.lineCap="butt",g.fillColor=c,c&&(null==c.a&&(c.a=255),g.isFill=!0),this._buffer.push(g)},drawCircle:function(a,b,c,d,e,f,g){f=f||this._lineWidth,g=g||this.getDrawColor(),null==g.a&&(g.a=255);for(var h=2*Math.PI/d,i=[],j=0;d>=j;j++){var k=j*h,l=b*Math.cos(k+c)+a.x,m=b*Math.sin(k+c)+a.y;i.push(cc.p(l,m))}e&&i.push(cc.p(a.x,a.y));var n=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);n.verts=i,n.lineWidth=f,n.lineColor=g,n.isClosePolygon=!0,n.isStroke=!0,this._buffer.push(n)},drawQuadBezier:function(a,b,c,d,e,f){e=e||this._lineWidth,f=f||this.getDrawColor(),null==f.a&&(f.a=255);for(var g=[],h=0,i=0;d>i;i++){var j=Math.pow(1-h,2)*a.x+2*(1-h)*h*b.x+h*h*c.x,k=Math.pow(1-h,2)*a.y+2*(1-h)*h*b.y+h*h*c.y;g.push(cc.p(j,k)),h+=1/d}g.push(cc.p(c.x,c.y));var l=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);l.verts=g,l.lineWidth=e,l.lineColor=f,l.isStroke=!0,l.lineCap="round",this._buffer.push(l)},drawCubicBezier:function(a,b,c,d,e,f,g){f=f||this._lineWidth,g=g||this.getDrawColor(),null==g.a&&(g.a=255);for(var h=[],i=0,j=0;e>j;j++){var k=Math.pow(1-i,3)*a.x+3*Math.pow(1-i,2)*i*b.x+3*(1-i)*i*i*c.x+i*i*i*d.x,l=Math.pow(1-i,3)*a.y+3*Math.pow(1-i,2)*i*b.y+3*(1-i)*i*i*c.y+i*i*i*d.y;h.push(cc.p(k,l)),i+=1/e}h.push(cc.p(d.x,d.y));var m=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);m.verts=h,m.lineWidth=f,m.lineColor=g,m.isStroke=!0,m.lineCap="round",this._buffer.push(m)},drawCatmullRom:function(a,b,c,d){this.drawCardinalSpline(a,.5,b,c,d)},drawCardinalSpline:function(a,b,c,d,e){d=d||this._lineWidth,e=e||this.getDrawColor(),null==e.a&&(e.a=255);for(var f,g,h=[],i=1/a.length,j=0;c+1>j;j++){var k=j/c;1===k?(f=a.length-1,g=1):(f=0|k/i,g=(k-i*f)/i);var l=cc.cardinalSplineAt(cc.getControlPointAt(a,f-1),cc.getControlPointAt(a,f-0),cc.getControlPointAt(a,f+1),cc.getControlPointAt(a,f+2),b,g);h.push(l)}var m=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);m.verts=h,m.lineWidth=d,m.lineColor=e,m.isStroke=!0,m.lineCap="round",this._buffer.push(m)},drawDot:function(a,b,c){c=c||this.getDrawColor(),null==c.a&&(c.a=255);var d=new cc._DrawNodeElement(cc.DrawNode.TYPE_DOT);d.verts=[a],d.lineWidth=b,d.fillColor=c,this._buffer.push(d)},drawDots:function(a,b,c){if(a&&0!=a.length){c=c||this.getDrawColor(),null==c.a&&(c.a=255);for(var d=0,e=a.length;e>d;d++)this.drawDot(a[d],b,c)}},drawSegment:function(a,b,c,d){c=c||this._lineWidth,d=d||this.getDrawColor(),null==d.a&&(d.a=255);var e=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);e.verts=[a,b],e.lineWidth=2*c,e.lineColor=d,e.isStroke=!0,e.lineCap="round",this._buffer.push(e)},drawPoly_:function(a,b,c,d){c=null==c?this._lineWidth:c,d=d||this.getDrawColor(),null==d.a&&(d.a=255);var e=new cc._DrawNodeElement(cc.DrawNode.TYPE_POLY);e.verts=a,e.fillColor=b,e.lineWidth=c,e.lineColor=d,e.isClosePolygon=!0,e.isStroke=!0,e.lineCap="round",b&&(e.isFill=!0),this._buffer.push(e)},drawPoly:function(a,b,c,d){for(var e=[],f=0;f=h;h++){var l=h*j,m=b*Math.cos(l+c)+a.x,n=b*Math.sin(l+c)+a.y;k.push(cc.p(m,n))}for(e&&k.push(cc.p(a.x,a.y)),f*=.5,h=0,i=k.length;i-1>h;h++)this.drawSegment(k[h],k[h+1],f,g)},drawQuadBezier:function(a,b,c,d,e,f){e=e||this._lineWidth,f=f||this.getDrawColor(),null==f.a&&(f.a=255);for(var g=[],h=0,i=0;d>i;i++){var j=Math.pow(1-h,2)*a.x+2*(1-h)*h*b.x+h*h*c.x,k=Math.pow(1-h,2)*a.y+2*(1-h)*h*b.y+h*h*c.y;g.push(cc.p(j,k)),h+=1/d}g.push(cc.p(c.x,c.y)),this._drawSegments(g,e,f,!1)},drawCubicBezier:function(a,b,c,d,e,f,g){f=f||this._lineWidth,g=g||this.getDrawColor(),null==g.a&&(g.a=255);for(var h=[],i=0,j=0;e>j;j++){var k=Math.pow(1-i,3)*a.x+3*Math.pow(1-i,2)*i*b.x+3*(1-i)*i*i*c.x+i*i*i*d.x,l=Math.pow(1-i,3)*a.y+3*Math.pow(1-i,2)*i*b.y+3*(1-i)*i*i*c.y+i*i*i*d.y;h.push(cc.p(k,l)),i+=1/e}h.push(cc.p(d.x,d.y)),this._drawSegments(h,f,g,!1)},drawCatmullRom:function(a,b,c,d){this.drawCardinalSpline(a,.5,b,c,d)},drawCardinalSpline:function(a,b,c,d,e){d=d||this._lineWidth,e=e||this.getDrawColor(),null==e.a&&(e.a=255);for(var f,g,h=[],i=1/a.length,j=0;c+1>j;j++){var k=j/c;1===k?(f=a.length-1,g=1):(f=0|k/i,g=(k-i*f)/i);var l=cc.cardinalSplineAt(cc.getControlPointAt(a,f-1),cc.getControlPointAt(a,f-0),cc.getControlPointAt(a,f+1),cc.getControlPointAt(a,f+2),b,g);h.push(l)}d*=.5;for(var m=0,n=h.length;n-1>m;m++)this.drawSegment(h[m],h[m+1],d,e)},_render:function(){var a=cc._renderContext;cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),a.bindBuffer(a.ARRAY_BUFFER,this._trianglesWebBuffer),this._dirty&&(a.bufferData(a.ARRAY_BUFFER,this._trianglesArrayBuffer,a.STREAM_DRAW),this._dirty=!1);var b=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;a.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,a.FLOAT,!1,b,0),a.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,a.UNSIGNED_BYTE,!0,b,8),a.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,a.FLOAT,!1,b,12),a.drawArrays(a.TRIANGLES,0,3*this._buffer.length),cc.incrementGLDraws(1)},_ensureCapacity:function(a){var b=this,c=b._buffer;if(c.length+a>b._bufferCapacity){var d=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT;if(b._bufferCapacity+=Math.max(b._bufferCapacity,a),null==c||0===c.length)b._buffer=[],b._trianglesArrayBuffer=new ArrayBuffer(d*b._bufferCapacity),b._trianglesReader=new Uint8Array(b._trianglesArrayBuffer);else{for(var e=[],f=new ArrayBuffer(d*b._bufferCapacity),g=0;gd;d++)this.drawDot(a[d],b,c)}},drawSegment:function(a,b,c,d){d=d||this.getDrawColor(),null==d.a&&(d.a=255),c=c||.5*this._lineWidth;var e=18;this._ensureCapacity(e);var f={r:0|d.r,g:0|d.g,b:0|d.b,a:0|d.a},g=cc.__v2f(a),h=cc.__v2f(b),i=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h,g))),j=cc.v2fperp(i),k=cc.v2fmult(i,c),l=cc.v2fmult(j,c),m=cc.v2fsub(h,cc.v2fadd(k,l)),n=cc.v2fadd(h,cc.v2fsub(k,l)),o=cc.v2fsub(h,k),p=cc.v2fadd(h,k),q=cc.v2fsub(g,k),r=cc.v2fadd(g,k),s=cc.v2fsub(g,cc.v2fsub(k,l)),t=cc.v2fadd(g,cc.v2fadd(k,l)),u=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,v=this._trianglesArrayBuffer,w=this._buffer;w.push(new cc.V2F_C4B_T2F_Triangle({vertices:m,colors:f,texCoords:cc.__t(cc.v2fneg(cc.v2fadd(i,j)))},{vertices:n,colors:f,texCoords:cc.__t(cc.v2fsub(i,j))},{vertices:o,colors:f,texCoords:cc.__t(cc.v2fneg(i))},v,w.length*u)),w.push(new cc.V2F_C4B_T2F_Triangle({vertices:p,colors:f,texCoords:cc.__t(i)},{vertices:n,colors:f,texCoords:cc.__t(cc.v2fsub(i,j))},{vertices:o,colors:f,texCoords:cc.__t(cc.v2fneg(i))},v,w.length*u)),w.push(new cc.V2F_C4B_T2F_Triangle({vertices:p,colors:f,texCoords:cc.__t(i)},{vertices:q,colors:f,texCoords:cc.__t(cc.v2fneg(i))},{vertices:o,colors:f,texCoords:cc.__t(cc.v2fneg(i))},v,w.length*u)),w.push(new cc.V2F_C4B_T2F_Triangle({vertices:p,colors:f,texCoords:cc.__t(i)},{vertices:q,colors:f,texCoords:cc.__t(cc.v2fneg(i))},{vertices:r,colors:f,texCoords:cc.__t(i)},v,w.length*u)),w.push(new cc.V2F_C4B_T2F_Triangle({vertices:s,colors:f,texCoords:cc.__t(cc.v2fsub(j,i))},{vertices:q,colors:f,texCoords:cc.__t(cc.v2fneg(i))},{vertices:r,colors:f,texCoords:cc.__t(i)},v,w.length*u)),w.push(new cc.V2F_C4B_T2F_Triangle({vertices:s,colors:f,texCoords:cc.__t(cc.v2fsub(j,i))},{vertices:t,colors:f,texCoords:cc.__t(cc.v2fadd(i,j))},{vertices:r,colors:f,texCoords:cc.__t(i)},v,w.length*u)),this._dirty=!0},drawPoly:function(a,b,c,d){if(null==b)return void this._drawSegments(a,c,d,!0);null==b.a&&(b.a=255),null==d.a&&(d.a=255),c=null==c?this._lineWidth:c,c*=.5;var e,f,g,h,i={r:0|b.r,g:0|b.g,b:0|b.b,a:0|b.a},j={r:0|d.r,g:0|d.g,b:0|d.b,a:0|d.a},k=[],l=a.length;for(e=0;l>e;e++){f=cc.__v2f(a[(e-1+l)%l]),g=cc.__v2f(a[e]),h=cc.__v2f(a[(e+1)%l]);var m=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(g,f))),n=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h,g))),o=cc.v2fmult(cc.v2fadd(m,n),1/(cc.v2fdot(m,n)+1));k[e]={offset:o,n:n}}var p=c>0,q=3*l-2,r=3*q;this._ensureCapacity(r);var s=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,t=this._trianglesArrayBuffer,u=this._buffer,v=0==p?.5:0;for(e=0;l-2>e;e++)f=cc.v2fsub(cc.__v2f(a[0]),cc.v2fmult(k[0].offset,v)),g=cc.v2fsub(cc.__v2f(a[e+1]),cc.v2fmult(k[e+1].offset,v)),h=cc.v2fsub(cc.__v2f(a[e+2]),cc.v2fmult(k[e+2].offset,v)),u.push(new cc.V2F_C4B_T2F_Triangle({vertices:f,colors:i,texCoords:cc.__t(cc.v2fzero())},{vertices:g,colors:i,texCoords:cc.__t(cc.v2fzero())},{vertices:h,colors:i,texCoords:cc.__t(cc.v2fzero())},t,u.length*s));for(e=0;l>e;e++){var w=(e+1)%l;f=cc.__v2f(a[e]),g=cc.__v2f(a[w]);var x=k[e].n,y=k[e].offset,z=k[w].offset,A=p?cc.v2fsub(f,cc.v2fmult(y,c)):cc.v2fsub(f,cc.v2fmult(y,.5)),B=p?cc.v2fsub(g,cc.v2fmult(z,c)):cc.v2fsub(g,cc.v2fmult(z,.5)),C=p?cc.v2fadd(f,cc.v2fmult(y,c)):cc.v2fadd(f,cc.v2fmult(y,.5)),D=p?cc.v2fadd(g,cc.v2fmult(z,c)):cc.v2fadd(g,cc.v2fmult(z,.5));p?(u.push(new cc.V2F_C4B_T2F_Triangle({vertices:A,colors:j,texCoords:cc.__t(cc.v2fneg(x))},{vertices:B,colors:j,texCoords:cc.__t(cc.v2fneg(x))},{vertices:D,colors:j,texCoords:cc.__t(x)},t,u.length*s)),u.push(new cc.V2F_C4B_T2F_Triangle({vertices:A,colors:j,texCoords:cc.__t(cc.v2fneg(x))},{vertices:C,colors:j,texCoords:cc.__t(x)},{vertices:D,colors:j,texCoords:cc.__t(x)},t,u.length*s))):(u.push(new cc.V2F_C4B_T2F_Triangle({vertices:A,colors:i,texCoords:cc.__t(cc.v2fzero())},{vertices:B,colors:i,texCoords:cc.__t(cc.v2fzero())},{vertices:D,colors:i,texCoords:cc.__t(x)},t,u.length*s)),u.push(new cc.V2F_C4B_T2F_Triangle({vertices:A,colors:i,texCoords:cc.__t(cc.v2fzero())},{vertices:C,colors:i,texCoords:cc.__t(x)},{vertices:D,colors:i,texCoords:cc.__t(x)},t,u.length*s)))}k=null,this._dirty=!0},_drawSegments:function(a,b,c,d){if(b=null==b?this._lineWidth:b,c=c||this._drawColor,null==c.a&&(c.a=255),b*=.5,!(0>=b)){var e,f,g,h,i={r:0|c.r,g:0|c.g,b:0|c.b,a:0|c.a},j=[],k=a.length;for(e=0;k>e;e++){f=cc.__v2f(a[(e-1+k)%k]),g=cc.__v2f(a[e]),h=cc.__v2f(a[(e+1)%k]);var l=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(g,f))),m=cc.v2fnormalize(cc.v2fperp(cc.v2fsub(h,g))),n=cc.v2fmult(cc.v2fadd(l,m),1/(cc.v2fdot(l,m)+1));j[e]={offset:n,n:m}}var o=3*k-2,p=3*o;this._ensureCapacity(p);var q=cc.V2F_C4B_T2F_Triangle.BYTES_PER_ELEMENT,r=this._trianglesArrayBuffer,s=this._buffer,t=d?k:k-1;for(e=0;t>e;e++){var u=(e+1)%k;f=cc.__v2f(a[e]),g=cc.__v2f(a[u]);var v=j[e].n,w=j[e].offset,x=j[u].offset,y=cc.v2fsub(f,cc.v2fmult(w,b)),z=cc.v2fsub(g,cc.v2fmult(x,b)),A=cc.v2fadd(f,cc.v2fmult(w,b)),B=cc.v2fadd(g,cc.v2fmult(x,b));s.push(new cc.V2F_C4B_T2F_Triangle({vertices:y,colors:i,texCoords:cc.__t(cc.v2fneg(v))},{vertices:z,colors:i,texCoords:cc.__t(cc.v2fneg(v))},{vertices:B,colors:i,texCoords:cc.__t(v)},r,s.length*q)),s.push(new cc.V2F_C4B_T2F_Triangle({vertices:y,colors:i,texCoords:cc.__t(cc.v2fneg(v))},{vertices:A,colors:i,texCoords:cc.__t(v)},{vertices:B,colors:i,texCoords:cc.__t(v)},r,s.length*q))}j=null,this._dirty=!0}},clear:function(){this._buffer.length=0,this._dirty=!0},_createRenderCmd:function(){return new cc.DrawNode.WebGLRenderCmd(this)}})}),function(){cc.DrawNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._buffer=null,this._drawColor=null,this._blendFunc=null},cc.DrawNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype),cc.DrawNode.CanvasRenderCmd.prototype.constructor=cc.DrawNode.CanvasRenderCmd,cc.extend(cc.DrawNode.CanvasRenderCmd.prototype,{rendering:function(a,b,c){var d=a||cc._renderContext,e=(d.getContext(),this._node),f=e._displayedOpacity/255;if(0!==f){d.setTransform(this._worldTransform,b,c),d.setGlobalAlpha(f),this._blendFunc&&this._blendFunc.src===cc.SRC_ALPHA&&this._blendFunc.dst===cc.ONE&&d.setCompositeOperation("lighter");for(var g=this._buffer,h=0,i=g.length;i>h;h++){var j=g[h];switch(j.type){case cc.DrawNode.TYPE_DOT:this._drawDot(d,j,b,c);break;case cc.DrawNode.TYPE_SEGMENT:this._drawSegment(d,j,b,c);break;case cc.DrawNode.TYPE_POLY:this._drawPoly(d,j,b,c)}}}},_drawDot:function(a,b,c,d){var e=b.fillColor,f=b.verts[0],g=b.lineWidth,h=a.getContext();a.setFillStyle("rgba("+(0|e.r)+","+(0|e.g)+","+(0|e.b)+","+e.a/255+")"),h.beginPath(),h.arc(f.x*c,-f.y*d,g*c,0,2*Math.PI,!1),h.closePath(),h.fill()},_drawSegment:function(a,b,c,d){var e=b.lineColor,f=b.verts[0],g=b.verts[1],h=b.lineWidth,i=b.lineCap,j=a.getContext();a.setStrokeStyle("rgba("+(0|e.r)+","+(0|e.g)+","+(0|e.b)+","+e.a/255+")"),j.lineWidth=h*c,j.beginPath(),j.lineCap=i,j.moveTo(f.x*c,-f.y*d),j.lineTo(g.x*c,-g.y*d),j.stroke()},_drawPoly:function(a,b,c,d){var e=b.verts,f=b.lineCap;if(null!=e){var g=b.fillColor,h=b.lineWidth,i=b.lineColor,j=b.isClosePolygon,k=b.isFill,l=b.isStroke,m=a.getContext(),n=e[0];m.lineCap=f,g&&a.setFillStyle("rgba("+(0|g.r)+","+(0|g.g)+","+(0|g.b)+","+g.a/255+")"),h&&(m.lineWidth=h*c),i&&a.setStrokeStyle("rgba("+(0|i.r)+","+(0|i.g)+","+(0|i.b)+","+i.a/255+")"),m.beginPath(),m.moveTo(n.x*c,-n.y*d);for(var o=1,p=e.length;p>o;o++)m.lineTo(e[o].x*c,-e[o].y*d);j&&m.closePath(),k&&m.fill(),l&&m.stroke()}}})}();!function(){cc.DrawNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0},cc.DrawNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype),cc.DrawNode.WebGLRenderCmd.prototype.constructor=cc.DrawNode.WebGLRenderCmd,cc.DrawNode.WebGLRenderCmd.prototype.rendering=function(a){var b=this._node;cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst),this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),b._render()}}();cc.stencilBits=-1,cc.ClippingNode=cc.Node.extend({alphaThreshold:0,inverted:!1,_stencil:null,_className:"ClippingNode",ctor:function(a){a=a||null,cc.Node.prototype.ctor.call(this),this._stencil=a,this.alphaThreshold=1,this.inverted=!1,this._renderCmd.initStencilBits()},init:function(a){return this._stencil=a,this.alphaThreshold=1,this.inverted=!1,this._renderCmd.initStencilBits(),!0},onEnter:function(){cc.Node.prototype.onEnter.call(this),this._stencil.onEnter()},onEnterTransitionDidFinish:function(){cc.Node.prototype.onEnterTransitionDidFinish.call(this),this._stencil.onEnterTransitionDidFinish()},onExitTransitionDidStart:function(){this._stencil.onExitTransitionDidStart(),cc.Node.prototype.onExitTransitionDidStart.call(this)},onExit:function(){this._stencil.onExit(),cc.Node.prototype.onExit.call(this)},getAlphaThreshold:function(){return this.alphaThreshold},setAlphaThreshold:function(a){this.alphaThreshold=a},isInverted:function(){return this.inverted},setInverted:function(a){this.inverted=a},getStencil:function(){return this._stencil},setStencil:function(a){this._stencil!==a&&this._renderCmd.setStencil(a)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ClippingNode.CanvasRenderCmd(this):new cc.ClippingNode.WebGLRenderCmd(this)}});var _p=cc.ClippingNode.prototype;cc.defineGetterSetter(_p,"stencil",_p.getStencil,_p.setStencil),_p.stencil,cc.ClippingNode.create=function(a){return new cc.ClippingNode(a)},function(){cc.ClippingNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!1,this._godhelpme=!1,this._clipElemType=!1,this._rendererSaveCmd=new cc.CustomRenderCmd(this,this._saveCmdCallback),this._rendererClipCmd=new cc.CustomRenderCmd(this,this._clipCmdCallback),this._rendererRestoreCmd=new cc.CustomRenderCmd(this,this._restoreCmdCallback)};var a=cc.ClippingNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ClippingNode.CanvasRenderCmd,a.initStencilBits=function(){},a.setStencil=function(a){if(null!=a)if(this._node._stencil=a,a instanceof cc.DrawNode){if(a._buffer)for(var b=0;b0;k--)f.lineTo(i[k].x*c,-i[k].y*d)}}}else a._parent=this._node},a._saveCmdCallback=function(a,b,c){var d=a||cc._renderContext,e=d.getContext();if(this._clipElemType){var f=cc.ClippingNode.CanvasRenderCmd._getSharedCache(),g=e.canvas;f.width=g.width,f.height=g.height;var h=f.getContext("2d");h.drawImage(g,0,0)}else d.save(),e.beginPath(),d.setTransform(this._worldTransform,b,c),this._node.inverted&&(e.rect(0,0,e.canvas.width,-e.canvas.height),e.clip())},a._setStencilCompositionOperation=function(a){if(a){var b=this._node;if(a._renderCmd&&a._renderCmd._blendFuncStr&&(a._renderCmd._blendFuncStr=b.inverted?"destination-out":"destination-in"),a._children)for(var c=a._children,d=0,e=c.length;e>d;d++)this._setStencilCompositionOperation(c[d])}},a._clipCmdCallback=function(a){var b=this._node,c=a||cc._renderContext,d=c.getContext();this._clipElemType?this._setStencilCompositionOperation(b._stencil):d.clip()},a._restoreCmdCallback=function(a){var b=cc.ClippingNode.CanvasRenderCmd._getSharedCache(),c=a||cc._renderContext,d=c.getContext();this._clipElemType?(d.save(),d.setTransform(1,0,0,1,0,0),d.globalCompositeOperation="destination-over",d.drawImage(b,0,0),d.restore(),this._dirtyFlag=0):c.restore()},a.transform=function(a,b){cc.Node.CanvasRenderCmd.prototype.transform.call(this,a,b);var c=this._node;c._stencil&&c._stencil._renderCmd&&c._stencil._renderCmd.transform(this,b)},a._cangodhelpme=function(a){return(a===!0||a===!1)&&(cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme=a),cc.ClippingNode.CanvasRenderCmd.prototype._godhelpme},a.visit=function(a){var b=this._node;if(b._visible){a=a||this.getParentRenderCmd(),a&&(this._curLevel=a._curLevel+1);var c=this;if(this._clipElemType=!(!this._cangodhelpme()&&b._stencil instanceof cc.DrawNode),!b._stencil||!b._stencil.visible)return void(this.inverted&&cc.Node.CanvasRenderCmd.prototype.visit.call(this,a));if(this._syncStatus(a),cc.renderer.pushRenderCommand(this._rendererSaveCmd),this._clipElemType?cc.Node.CanvasRenderCmd.prototype.visit.call(this,a):b._stencil.visit(this),cc.renderer.pushRenderCommand(this._rendererClipCmd),this._clipElemType)b._stencil.visit(c);else{var d,e=b._children;this._cangodhelpme(!0);var f=e.length;if(f>0)for(b.sortAllChildren(),d=0;f>d;d++)e[d]._renderCmd.visit(this);this._cangodhelpme(!1)}cc.renderer.pushRenderCommand(this._rendererRestoreCmd),this._dirtyFlag=0}},cc.ClippingNode.CanvasRenderCmd._sharedCache=null,cc.ClippingNode.CanvasRenderCmd._getSharedCache=function(){return cc.ClippingNode.CanvasRenderCmd._sharedCache||(cc.ClippingNode.CanvasRenderCmd._sharedCache=document.createElement("canvas"))}}();!function(){cc.ClippingNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!1,this._beforeVisitCmd=new cc.CustomRenderCmd(this,this._onBeforeVisit),this._afterDrawStencilCmd=new cc.CustomRenderCmd(this,this._onAfterDrawStencil),this._afterVisitCmd=new cc.CustomRenderCmd(this,this._onAfterVisit),this._currentStencilFunc=null,this._currentStencilRef=null,this._currentStencilValueMask=null,this._currentStencilFail=null,this._currentStencilPassDepthFail=null,this._currentStencilPassDepthPass=null,this._currentStencilWriteMask=null,this._currentStencilEnabled=null,this._currentDepthWriteMask=null,this._mask_layer_le=null};var a=cc.ClippingNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ClippingNode.WebGLRenderCmd,cc.ClippingNode.WebGLRenderCmd._init_once=null,cc.ClippingNode.WebGLRenderCmd._visit_once=null,cc.ClippingNode.WebGLRenderCmd._layer=-1,a.initStencilBits=function(){cc.ClippingNode.WebGLRenderCmd._init_once=!0,cc.ClippingNode.WebGLRenderCmd._init_once&&(cc.stencilBits=cc._renderContext.getParameter(cc._renderContext.STENCIL_BITS),cc.stencilBits<=0&&cc.log("Stencil buffer is not enabled."),cc.ClippingNode.WebGLRenderCmd._init_once=!1)},a.transform=function(a,b){var c=this._node;cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,b),c._stencil&&c._stencil._renderCmd.transform(this,b)},a.visit=function(a){var b=this._node;if(b._visible){if(b._parent&&b._parent._renderCmd&&(this._curLevel=b._parent._renderCmd._curLevel+1),cc.stencilBits<1)return void cc.Node.WebGLRenderCmd.prototype.visit.call(this,a);if(!b._stencil||!b._stencil.visible)return void(b.inverted&&cc.Node.WebGLRenderCmd.prototype.visit.call(this,a));if(cc.ClippingNode.WebGLRenderCmd._layer+1===cc.stencilBits)return cc.ClippingNode.WebGLRenderCmd._visit_once=!0,cc.ClippingNode.WebGLRenderCmd._visit_once&&(cc.log("Nesting more than "+cc.stencilBits+"stencils is not supported. Everything will be drawn without stencil for this node and its children."),cc.ClippingNode.WebGLRenderCmd._visit_once=!1),void cc.Node.WebGLRenderCmd.prototype.visit.call(this,a);cc.renderer.pushRenderCommand(this._beforeVisitCmd);var c=cc.current_stack;c.stack.push(c.top),this._syncStatus(a),c.top=this._stackMatrix,b._stencil._renderCmd.visit(this),cc.renderer.pushRenderCommand(this._afterDrawStencilCmd);var d=b._children;if(d&&d.length>0){var e=d.length;b.sortAllChildren();for(var f=0;e>f;f++)d[f]._renderCmd.visit(this)}cc.renderer.pushRenderCommand(this._afterVisitCmd),this._dirtyFlag=0,c.top=c.stack.pop()}},a.setStencil=function(a){var b=this._node;b._stencil&&(b._stencil._parent=null),b._stencil=a,b._stencil&&(b._stencil._parent=b)},a._drawFullScreenQuadClearStencil=function(){var a=cc.projection_matrix_stack;a.push(),a.top.identity();var b=cc.modelview_matrix_stack;b.push(),b.top.identity(),cc._drawingUtil.drawSolidRect(cc.p(-1,-1),cc.p(1,1),cc.color(255,255,255,255)),a.pop(),b.pop()},a._onBeforeVisit=function(a){var b=a||cc._renderContext,c=this._node;cc.ClippingNode.WebGLRenderCmd._layer++;var d=1<0){for(var a=this._originalVertices,b=this._vertices,c=0,d=this._vertices.length;d>c;c++)a[c]=b[c];--this._reuseGrid}},calculateVertexPoints:function(){var a=cc._renderContext,b=this._texture.pixelsWidth,c=this._texture.pixelsHeight,d=this._texture.getContentSizeInPixels().height,e=this._gridSize,f=(e.width+1)*(e.height+1);this._vertices=new Float32Array(3*f),this._texCoordinates=new Float32Array(2*f),this._indices=new Uint16Array(e.width*e.height*6),this._verticesBuffer&&a.deleteBuffer(this._verticesBuffer),this._verticesBuffer=a.createBuffer(),this._texCoordinateBuffer&&a.deleteBuffer(this._texCoordinateBuffer),this._texCoordinateBuffer=a.createBuffer(),this._indicesBuffer&&a.deleteBuffer(this._indicesBuffer),this._indicesBuffer=a.createBuffer();var g,h,i,j=this._indices,k=this._texCoordinates,l=this._isTextureFlipped,m=this._vertices;for(g=0;gi;++i)m[w[i]]=B[i].x,m[w[i]+1]=B[i].y,m[w[i]+2]=B[i].z,k[C[i]]=D[i].x/b,l?k[C[i]+1]=(d-D[i].y)/c:k[C[i]+1]=D[i].y/c}this._originalVertices=new Float32Array(this._vertices),a.bindBuffer(a.ARRAY_BUFFER,this._verticesBuffer),a.bufferData(a.ARRAY_BUFFER,this._vertices,a.DYNAMIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this._texCoordinateBuffer),a.bufferData(a.ARRAY_BUFFER,this._texCoordinates,a.DYNAMIC_DRAW),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indicesBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW),this._dirty=!0},setNeedDepthTestForBlit:function(a){this._needDepthTestForBlit=a},getNeedDepthTestForBlit:function(){return this._needDepthTestForBlit}}),cc.Grid3D.create=function(a,b,c){return new cc.Grid3D(a,b,c)},cc.TiledGrid3D=cc.GridBase.extend({_texCoordinates:null,_vertices:null,_originalVertices:null,_indices:null,_texCoordinateBuffer:null,_verticesBuffer:null,_indicesBuffer:null,ctor:function(a,b,c,d){cc.GridBase.prototype.ctor.call(this),this._texCoordinates=null,this._vertices=null,this._originalVertices=null,this._indices=null,this._texCoordinateBuffer=null,this._verticesBuffer=null,this._indicesBuffer=null,void 0!==a&&this.initWithSize(a,b,c,d)},tile:function(a){return this.getTile(a)},getTile:function(a){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.TiledGrid3D.tile() : Numbers must be integers");var b=4*(this._gridSize.height*a.x+a.y)*3,c=this._vertices;return new cc.Quad3(new cc.Vertex3F(c[b],c[b+1],c[b+2]),new cc.Vertex3F(c[b+3],c[b+4],c[b+5]),new cc.Vertex3F(c[b+6],c[b+7],c[b+8]),new cc.Vertex3F(c[b+9],c[b+10],c[b+11]))},getOriginalTile:function(a){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.TiledGrid3D.originalTile() : Numbers must be integers");var b=4*(this._gridSize.height*a.x+a.y)*3,c=this._originalVertices;return new cc.Quad3(new cc.Vertex3F(c[b],c[b+1],c[b+2]),new cc.Vertex3F(c[b+3],c[b+4],c[b+5]),new cc.Vertex3F(c[b+6],c[b+7],c[b+8]),new cc.Vertex3F(c[b+9],c[b+10],c[b+11]))},originalTile:function(a){return this.getOriginalTile(a)},setTile:function(a,b){(a.x!==(0|a.x)||a.y!==(0|a.y))&&cc.log("cc.TiledGrid3D.setTile() : Numbers must be integers");var c=12*(this._gridSize.height*a.x+a.y),d=this._vertices;d[c]=b.bl.x,d[c+1]=b.bl.y,d[c+2]=b.bl.z,d[c+3]=b.br.x,d[c+4]=b.br.y,d[c+5]=b.br.z,d[c+6]=b.tl.x,d[c+7]=b.tl.y,d[c+8]=b.tl.z,d[c+9]=b.tr.x,d[c+10]=b.tr.y,d[c+11]=b.tr.z,this._dirty=!0},blit:function(a){var b=this._gridSize.width*this._gridSize.height;this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(a._renderCmd._stackMatrix);var c=cc._renderContext,d=this._dirty;cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION|cc.VERTEX_ATTRIB_FLAG_TEX_COORDS),c.bindBuffer(c.ARRAY_BUFFER,this._verticesBuffer),d&&c.bufferData(c.ARRAY_BUFFER,this._vertices,c.DYNAMIC_DRAW),c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,c.FLOAT,!1,0,this._vertices),c.bindBuffer(c.ARRAY_BUFFER,this._texCoordinateBuffer),d&&c.bufferData(c.ARRAY_BUFFER,this._texCoordinates,c.DYNAMIC_DRAW),c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,c.FLOAT,!1,0,this._texCoordinates),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indicesBuffer),d&&c.bufferData(c.ELEMENT_ARRAY_BUFFER,this._indices,c.STATIC_DRAW),c.drawElements(c.TRIANGLES,6*b,c.UNSIGNED_SHORT,0),d&&(this._dirty=!1),cc.incrementGLDraws(1)},reuse:function(){if(this._reuseGrid>0){for(var a=this._vertices,b=this._originalVertices,c=0;cg;g++)t[6*g+0]=4*g+0,t[6*g+1]=4*g+1,t[6*g+2]=4*g+2,t[6*g+3]=4*g+1,t[6*g+4]=4*g+2,t[6*g+5]=4*g+3;this._originalVertices=new Float32Array(this._vertices),f.bindBuffer(f.ARRAY_BUFFER,this._verticesBuffer),f.bufferData(f.ARRAY_BUFFER,this._vertices,f.DYNAMIC_DRAW),f.bindBuffer(f.ARRAY_BUFFER,this._texCoordinateBuffer),f.bufferData(f.ARRAY_BUFFER,this._texCoordinates,f.DYNAMIC_DRAW),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this._indicesBuffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,this._indices,f.DYNAMIC_DRAW),this._dirty=!0}}),cc.TiledGrid3D.create=function(a,b,c){return new cc.TiledGrid3D(a,b,c)},cc.Grabber=cc.Class.extend({_FBO:null,_oldFBO:null,_oldClearColor:null,_gl:null,ctor:function(){cc.sys._checkWebGLRenderMode(),this._gl=cc._renderContext,this._oldClearColor=[0,0,0,0],this._oldFBO=null,this._FBO=this._gl.createFramebuffer()},grab:function(a){var b=this._gl;this._oldFBO=b.getParameter(b.FRAMEBUFFER_BINDING),b.bindFramebuffer(b.FRAMEBUFFER,this._FBO),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,a._webTextureObj,0);var c=b.checkFramebufferStatus(b.FRAMEBUFFER);c!==b.FRAMEBUFFER_COMPLETE&&cc.log("Frame Grabber: could not attach texture to frmaebuffer"),b.bindFramebuffer(b.FRAMEBUFFER,this._oldFBO)},beforeRender:function(a){var b=this._gl;this._oldFBO=b.getParameter(b.FRAMEBUFFER_BINDING),b.bindFramebuffer(b.FRAMEBUFFER,this._FBO),this._oldClearColor=b.getParameter(b.COLOR_CLEAR_VALUE),b.clearColor(0,0,0,0),b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)},afterRender:function(a){var b=this._gl;b.bindFramebuffer(b.FRAMEBUFFER,this._oldFBO),b.colorMask(!0,!0,!0,!0)},destroy:function(){this._gl.deleteFramebuffer(this._FBO)}});cc.GridAction=cc.ActionInterval.extend({_gridSize:null,_gridNodeTarget:null,ctor:function(a,b){cc.sys._checkWebGLRenderMode(),cc.ActionInterval.prototype.ctor.call(this),this._gridSize=cc.size(0,0),b&&this.initWithDuration(a,b)},_cacheTargetAsGridNode:function(a){this._gridNodeTarget=a},clone:function(){var a=new cc.GridAction,b=this._gridSize;return a.initWithDuration(this._duration,cc.size(b.width,b.height)),a},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),cc.renderer.childrenOrderDirty=!0,this._cacheTargetAsGridNode(a);var b=this.getGrid(),c=this._gridNodeTarget.getGrid();if(c&&c.getReuseGrid()>0){var d=c.getGridSize();c.isActive()&&d.width===this._gridSize.width&&d.height===this._gridSize.height&&c.reuse()}else c&&c.isActive()&&c.setActive(!1),this._gridNodeTarget.setGrid(b),this._gridNodeTarget.getGrid().setActive(!0)},reverse:function(){return new cc.ReverseTime(this)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._gridSize.width=b.width,this._gridSize.height=b.height,!0):!1},getGrid:function(){cc.log("cc.GridAction.getGrid(): it should be overridden in subclass.")}}),cc.gridAction=function(a,b){return new cc.GridAction(a,b)},cc.GridAction.create=cc.gridAction,cc.Grid3DAction=cc.GridAction.extend({getGrid:function(){return new cc.Grid3D(this._gridSize,void 0,void 0,this._gridNodeTarget.getGridRect())},getGridRect:function(){return this._gridNodeTarget.getGridRect()},vertex:function(a){return this.getVertex(a)},getVertex:function(a){return this.target.grid.getVertex(a)},originalVertex:function(a){return this.getOriginalVertex(a)},getOriginalVertex:function(a){return this.target.grid.originalVertex(a)},setVertex:function(a,b){this.target.grid.setVertex(a,b)}}),cc.grid3DAction=function(a,b){return new cc.Grid3DAction(a,b)},cc.Grid3DAction.create=cc.grid3DAction,cc.TiledGrid3DAction=cc.GridAction.extend({tile:function(a){return this.getTile(a)},getTile:function(a){return this.target.grid.tile(a)},originalTile:function(a){return this.getOriginalTile(a)},getOriginalTile:function(a){return this.target.grid.originalTile(a)},setTile:function(a,b){this.target.grid.setTile(a,b)},getGrid:function(){return new cc.TiledGrid3D(this._gridSize,void 0,void 0,this._gridNodeTarget.getGridRect())}}),cc.tiledGrid3DAction=function(a,b){return new cc.TiledGrid3DAction(a,b)},cc.TiledGrid3DAction.create=cc.tiledGrid3DAction,cc.StopGrid=cc.ActionInstant.extend({startWithTarget:function(a){cc.ActionInstant.prototype.startWithTarget.call(this,a),cc.renderer.childrenOrderDirty=!0;var b=this.target.grid;b&&b.isActive()&&b.setActive(!1)}}),cc.stopGrid=function(){return new cc.StopGrid},cc.StopGrid.create=cc.stopGrid,cc.ReuseGrid=cc.ActionInstant.extend({_times:null,ctor:function(a){cc.ActionInstant.prototype.ctor.call(this),void 0!==a&&this.initWithTimes(a)},initWithTimes:function(a){return this._times=a,!0},startWithTarget:function(a){cc.ActionInstant.prototype.startWithTarget.call(this,a),cc.renderer.childrenOrderDirty=!0,this.target.grid&&this.target.grid.isActive()&&this.target.grid.setReuseGrid(this.target.grid.getReuseGrid()+this._times)}}),cc.reuseGrid=function(a){return new cc.ReuseGrid(a)},cc.ReuseGrid.create=cc.reuseGrid,cc.Waves3D=cc.Grid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=c,this._amplitude=d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b=this._gridSize,c=this._amplitude,d=cc.p(0,0),e=this._amplitudeRate,f=this._waves,g=0;go?(i=cc.p(0,0),j=cc.p(0,1),k=cc.p(1,0),l=cc.p(1,1),h=n):(k=cc.p(0,0),l=cc.p(0,1),i=cc.p(1,0),j=cc.p(1,1),h=o),e.x=h-h*d,e.z=Math.abs(parseFloat(h*c/4));var p=this.originalVertex(i);p.x=e.x,p.z+=e.z,this.setVertex(i,p),p=this.originalVertex(j),p.x=e.x,p.z+=e.z,this.setVertex(j,p),p=this.originalVertex(k),p.x-=e.x,p.z-=e.z,this.setVertex(k,p),p=this.originalVertex(l),p.x-=e.x,p.z-=e.z,this.setVertex(l,p)}}),cc.flipX3D=function(a){return new cc.FlipX3D(a)},cc.FlipX3D.create=cc.flipX3D,cc.FlipY3D=cc.FlipX3D.extend({ctor:function(a){void 0!==a?cc.GridAction.prototype.ctor.call(this,a,cc.size(1,1)):cc.GridAction.prototype.ctor.call(this)},update:function(a){var b=Math.PI*a,c=Math.sin(b);b/=2;var d=Math.cos(b),e=new cc.Vertex3F,f=cc.p(0,0);f.x=f.y=1;var g=this.originalVertex(f);f.x=f.y=0;var h,i,j,k,l,m=this.originalVertex(f),n=g.y,o=m.y;n>o?(i=cc.p(0,0),j=cc.p(0,1),k=cc.p(1,0),l=cc.p(1,1),h=n):(j=cc.p(0,0),i=cc.p(0,1),l=cc.p(1,0),k=cc.p(1,1),h=o),e.y=h-h*d,e.z=Math.abs(parseFloat(h*c)/4);var p=this.originalVertex(i);p.y=e.y,p.z+=e.z,this.setVertex(i,p),p=this.originalVertex(j),p.y-=e.y,p.z-=e.z,this.setVertex(j,p),p=this.originalVertex(k),p.y=e.y,p.z+=e.z,this.setVertex(k,p),p=this.originalVertex(l),p.y-=e.y,p.z-=e.z,this.setVertex(l,p)}}),cc.flipY3D=function(a){return new cc.FlipY3D(a)},cc.FlipY3D.create=cc.flipY3D,cc.Lens3D=cc.Grid3DAction.extend({_position:null,_radius:0,_lensEffect:0,_concave:!1,_dirty:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this),this._position=cc.p(0,0),void 0!==d&&this.initWithDuration(a,b,c,d)},getLensEffect:function(){return this._lensEffect},setLensEffect:function(a){this._lensEffect=a},setConcave:function(a){this._concave=a},getPosition:function(){return this._position},setPosition:function(a){cc.pointEqualToPoint(a,this._position)||(this._position.x=a.x,this._position.y=a.y,this._dirty=!0)},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this.setPosition(c),this._radius=d,this._lensEffect=.7,this._dirty=!0,!0):!1},update:function(a){if(this._dirty){for(var b,c,d,e,f,g=this._gridSize.width,h=this._gridSize.height,i=this._radius,j=this._lensEffect,k=cc.p(0,0),l=cc.p(0,0),m=0;g+1>m;++m)for(var n=0;h+1>n;++n)k.x=m,k.y=n,b=this.originalVertex(k),l.x=this._position.x-b.x,l.y=this._position.y-b.y,c=cc.pLength(l),i>c&&(c=i-c,f=c/i,0===f&&(f=.001),d=Math.log(f)*j,e=Math.exp(d)*i,c=cc.pLength(l),c>0&&(l.x=l.x/c,l.y=l.y/c,l.x=l.x*e,l.y=l.y*e,b.z+=cc.pLength(l)*j)),this.setVertex(k,b);this._dirty=!1}}}),cc.lens3D=function(a,b,c,d){return new cc.Lens3D(a,b,c,d)},cc.Lens3D.create=cc.lens3D,cc.Ripple3D=cc.Grid3DAction.extend({_position:null,_radius:0,_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d,e,f){cc.GridAction.prototype.ctor.call(this),this._position=cc.p(0,0),void 0!==f&&this.initWithDuration(a,b,c,d,e,f)},getPosition:function(){return this._position},setPosition:function(a){this._position.x=a.x,this._position.y=a.y},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d,e,f){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this.setPosition(c),this._radius=d,this._waves=e,this._amplitude=f,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c,d=this._gridSize.width,e=this._gridSize.height,f=cc.p(0,0),g=this._radius,h=this._waves,i=this._amplitude,j=this._amplitudeRate,k=cc.p(0,0),l=0;d+1>l;++l)for(var m=0;e+1>m;++m){if(f.x=l,f.y=m,b=this.originalVertex(f),k.x=this._position.x-b.x,k.y=this._position.y-b.y,c=cc.pLength(k),g>c){c=g-c;var n=Math.pow(c/g,2);b.z+=Math.sin(a*Math.PI*h*2+.1*c)*i*j*n}this.setVertex(f,b)}}}),cc.ripple3D=function(a,b,c,d,e,f){return new cc.Ripple3D(a,b,c,d,e,f)},cc.Ripple3D.create=cc.ripple3D,cc.Shaky3D=cc.Grid3DAction.extend({_randRange:0,_shakeZ:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._randRange=c,this._shakeZ=d,!0):!1},update:function(a){for(var b,c=this._gridSize.width,d=this._gridSize.height,e=this._randRange,f=this._shakeZ,g=cc.p(0,0),h=0;c+1>h;++h)for(var i=0;d+1>i;++i)g.x=h,g.y=i,b=this.originalVertex(g),b.x+=cc.rand()%(2*e)-e,b.y+=cc.rand()%(2*e)-e,f&&(b.z+=cc.rand()%(2*e)-e),this.setVertex(g,b)}}),cc.shaky3D=function(a,b,c,d){return new cc.Shaky3D(a,b,c,d)},cc.Shaky3D.create=cc.shaky3D,cc.Liquid=cc.Grid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=c,this._amplitude=d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c=this._gridSize.width,d=this._gridSize.height,e=cc.p(0,0),f=this._waves,g=this._amplitude,h=this._amplitudeRate,i=1;c>i;++i)for(var j=1;d>j;++j)e.x=i,e.y=j,b=this.originalVertex(e),b.x=b.x+Math.sin(a*Math.PI*f*2+.01*b.x)*g*h,b.y=b.y+Math.sin(a*Math.PI*f*2+.01*b.y)*g*h,this.setVertex(e,b)}}),cc.liquid=function(a,b,c,d){return new cc.Liquid(a,b,c,d)},cc.Liquid.create=cc.liquid,cc.Waves=cc.Grid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,_vertical:!1,_horizontal:!1,ctor:function(a,b,c,d,e,f){cc.GridAction.prototype.ctor.call(this),void 0!==f&&this.initWithDuration(a,b,c,d,e,f)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d,e,f){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=c,this._amplitude=d,this._amplitudeRate=1,this._horizontal=e,this._vertical=f,!0):!1},update:function(a){for(var b,c=this._gridSize.width,d=this._gridSize.height,e=cc.p(0,0),f=this._vertical,g=this._horizontal,h=this._waves,i=this._amplitude,j=this._amplitudeRate,k=0;c+1>k;++k)for(var l=0;d+1>l;++l)e.x=k,e.y=l,b=this.originalVertex(e),f&&(b.x=b.x+Math.sin(a*Math.PI*h*2+.01*b.y)*i*j),g&&(b.y=b.y+Math.sin(a*Math.PI*h*2+.01*b.x)*i*j),this.setVertex(e,b)}}),cc.waves=function(a,b,c,d,e,f){return new cc.Waves(a,b,c,d,e,f)},cc.Waves.create=cc.waves,cc.Twirl=cc.Grid3DAction.extend({_position:null,_twirls:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d,e){cc.GridAction.prototype.ctor.call(this),this._position=cc.p(0,0),void 0!==e&&this.initWithDuration(a,b,c,d,e)},getPosition:function(){return this._position},setPosition:function(a){this._position.x=a.x,this._position.y=a.y},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d,e){return cc.Grid3DAction.prototype.initWithDuration.call(this,a,b)?(this.setPosition(c),this._twirls=d,this._amplitude=e,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c,d,e,f=this._position,g=this._gridSize.width,h=this._gridSize.height,i=cc.p(0,0),j=.1*this._amplitude*this._amplitudeRate,k=this._twirls,l=cc.p(0,0),m=0;g+1>m;++m)for(var n=0;h+1>n;++n)i.x=m,i.y=n,b=this.originalVertex(i),l.x=m-g/2,l.y=n-h/2,c=cc.pLength(l)*Math.cos(Math.PI/2+a*Math.PI*k*2)*j,d=Math.sin(c)*(b.y-f.y)+Math.cos(c)*(b.x-f.x),e=Math.cos(c)*(b.y-f.y)-Math.sin(c)*(b.x-f.x),b.x=f.x+d,b.y=f.y+e,this.setVertex(i,b)}}),cc.twirl=function(a,b,c,d,e){return new cc.Twirl(a,b,c,d,e)},cc.Twirl.create=cc.twirl,cc.ShakyTiles3D=cc.TiledGrid3DAction.extend({_randRange:0,_shakeZ:!1,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(a,b,c,d)},initWithDuration:function(a,b,c,d){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._randRange=c,this._shakeZ=d,!0):!1},update:function(a){for(var b=this._gridSize,c=this._randRange,d=cc.p(0,0),e=0;e=0;c--){var d=0|cc.rand()%(c+1),e=a[c];a[c]=a[d],a[d]=e}},getDelta:function(a){var b=this._gridSize,c=a.width*b.height+a.height;return cc.size(this._tilesOrder[c]/b.height-a.width,this._tilesOrder[c]%b.height-a.height)},placeTile:function(a,b){var c=this.originalTile(a),d=this.target.grid.getStep(),e=b.position;c.bl.x+=e.x*d.x,c.bl.y+=e.y*d.y,c.br.x+=e.x*d.x,c.br.y+=e.y*d.y,c.tl.x+=e.x*d.x,c.tl.y+=e.y*d.y,c.tr.x+=e.x*d.x,c.tr.y+=e.y*d.y,this.setTile(a,c)},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a);var b=this._gridSize;this._tilesCount=b.width*b.height;var c=this._tilesOrder;c.length=0;for(var d=0;db?this.transformTile(d,b):this.turnOnTile(d)}}),cc.fadeOutTRTiles=function(a,b){return new cc.FadeOutTRTiles(a,b)},cc.FadeOutTRTiles.create=cc.fadeOutTRTiles,cc.FadeOutBLTiles=cc.FadeOutTRTiles.extend({testFunc:function(a,b){var c=this._gridSize.width*(1-b),d=this._gridSize.height*(1-b);return c+d===0?0:a.x+a.y===0?1:Math.pow((c+d)/(a.x+a.y),6)}}),cc.fadeOutBLTiles=function(a,b){return new cc.FadeOutBLTiles(a,b)},cc.FadeOutBLTiles.create=cc.fadeOutBLTiles,cc.FadeOutUpTiles=cc.FadeOutTRTiles.extend({testFunc:function(a,b){var c=this._gridSize.height*b;return c===this._gridSize.height?0:0===c?1:Math.pow(a.y/c,6)},transformTile:function(a,b){var c=this.originalTile(a),d=this.target.grid.getStep();c.bl.y+=d.y/2*(1-b),c.br.y+=d.y/2*(1-b),c.tl.y-=d.y/2*(1-b),c.tr.y-=d.y/2*(1-b),this.setTile(a,c)}}),cc.fadeOutUpTiles=function(a,b){return new cc.FadeOutUpTiles(a,b)},cc.FadeOutUpTiles.create=cc.fadeOutUpTiles,cc.FadeOutDownTiles=cc.FadeOutUpTiles.extend({testFunc:function(a,b){var c=this._gridSize.height*(1-b);return 0===c?0:0===a.y?1:Math.pow(c/a.y,6)}}),cc.fadeOutDownTiles=function(a,b){return new cc.FadeOutDownTiles(a,b)},cc.FadeOutDownTiles.create=cc.fadeOutDownTiles,cc.TurnOffTiles=cc.TiledGrid3DAction.extend({_seed:null,_tilesCount:0,_tilesOrder:null,ctor:function(a,b,c){cc.GridAction.prototype.ctor.call(this),this._tilesOrder=[],void 0!==b&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._seed=c||0,this._tilesOrder.length=0,!0):!1},shuffle:function(a,b){for(var c=b-1;c>=0;c--){var d=0|cc.rand()%(c+1),e=a[c];a[c]=a[d],a[d]=e}},turnOnTile:function(a){this.setTile(a,this.originalTile(a))},turnOffTile:function(a){this.setTile(a,new cc.Quad3)},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a),this._tilesCount=this._gridSize.width*this._gridSize.height;var b=this._tilesOrder;b.length=0;for(var c=0;cg?this.turnOffTile(e):this.turnOnTile(e)}}),cc.turnOffTiles=function(a,b,c){return new cc.TurnOffTiles(a,b,c)},cc.TurnOffTiles.create=cc.turnOffTiles,cc.WavesTiles3D=cc.TiledGrid3DAction.extend({_waves:0,_amplitude:0,_amplitudeRate:0,ctor:function(a,b,c,d){cc.GridAction.prototype.ctor.call(this),void 0!==d&&this.initWithDuration(a,b,c,d)},getAmplitude:function(){return this._amplitude},setAmplitude:function(a){this._amplitude=a},getAmplitudeRate:function(){return this._amplitudeRate},setAmplitudeRate:function(a){this._amplitudeRate=a},initWithDuration:function(a,b,c,d){return cc.TiledGrid3DAction.prototype.initWithDuration.call(this,a,b)?(this._waves=c,this._amplitude=d,this._amplitudeRate=1,!0):!1},update:function(a){for(var b,c=this._gridSize,d=this._waves,e=this._amplitude,f=this._amplitudeRate,g=cc.p(0,0),h=0;hg;++g)f.x=g,b=this.originalTile(f),c=1,g%2===0&&(c=-1),b.bl.y+=c*e*a,b.br.y+=c*e*a,b.tl.y+=c*e*a,b.tr.y+=c*e*a,this.setTile(f,b);cc.renderer.childrenOrderDirty=!0},startWithTarget:function(a){cc.TiledGrid3DAction.prototype.startWithTarget.call(this,a),this._winSize=cc.director.getWinSizeInPixels()}}),cc.splitCols=function(a,b){return new cc.SplitCols(a,b)},cc.SplitCols.create=cc.splitCols,cc.PageTurn3D=cc.Grid3DAction.extend({getGrid:function(){var a=new cc.Grid3D(this._gridSize,void 0,void 0,this._gridNodeTarget.getGridRect());return a.setNeedDepthTestForBlit(!0),a},clone:function(){var a=new cc.PageTurn3D;return a.initWithDuration(this._duration,this._gridSize),a},update:function(a){for(var b=Math.max(0,a-.25),c=b*b*500,d=-100-c,e=Math.sqrt(a),f=e>.5?Math.PI/2*e:Math.PI/2*(1-e),g=(2-a)*Math.PI,h=Math.sin(f),i=Math.cos(f),j=this._gridSize,k=cc.p(0,0),l=0;l<=j.width;++l)for(var m=0;m<=j.height;++m){k.x=l,k.y=m;var n=this.getOriginalVertex(k);n.x-=this.getGridRect().x;var o=Math.sqrt(n.x*n.x+(n.y-d)*(n.y-d)),p=o*h,q=Math.asin(n.x/o),r=q/h,s=Math.cos(r);r<=Math.PI?n.x=p*Math.sin(r):n.x=0,n.y=o+d-p*(1-s)*h,n.z=p*(1-s)*i,n.x=n.z*Math.sin(g)+n.x*Math.cos(g),n.z=n.z*Math.cos(g)-n.x*Math.cos(g),n.z/=7,n.z<.5&&(n.z=.5),n.x+=this.getGridRect().x,this.setVertex(k,n)}}}),cc.pageTurn3D=function(a,b){return new cc.PageTurn3D(a,b)},cc.PageTurn3D.create=cc.pageTurn3D;cc.ProgressTimer=cc.Node.extend({_type:null,_percentage:0,_sprite:null,_midPoint:null,_barChangeRate:null,_reverseDirection:!1,_className:"ProgressTimer",ctor:function(a){cc.Node.prototype.ctor.call(this),this._type=cc.ProgressTimer.TYPE_RADIAL,this._percentage=0,this._midPoint=cc.p(0,0),this._barChangeRate=cc.p(0,0),this._reverseDirection=!1,this._sprite=null,a&&this.initWithSprite(a)},getMidpoint:function(){return cc.p(this._midPoint.x,this._midPoint.y)},setMidpoint:function(a){this._midPoint=cc.pClamp(a,cc.p(0,0),cc.p(1,1))},getBarChangeRate:function(){return cc.p(this._barChangeRate.x,this._barChangeRate.y)},setBarChangeRate:function(a){this._barChangeRate=cc.pClamp(a,cc.p(0,0),cc.p(1,1))},getType:function(){return this._type},getPercentage:function(){return this._percentage},getSprite:function(){return this._sprite},setPercentage:function(a){this._percentage!==a&&(this._percentage=cc.clampf(a,0,100),this._renderCmd._updateProgress())},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1},isReverseDirection:function(){return this._reverseDirection},setColor:function(a){this._sprite.color=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.colorDirty)},setOpacity:function(a){this._sprite.opacity=a,this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.opacityDirty)},getColor:function(){return this._sprite.color},getOpacity:function(){return this._sprite.opacity},setReverseProgress:function(a){this._reverseDirection!==a&&(this._reverseDirection=a,this._renderCmd.releaseData())},setSprite:function(a){this._sprite!==a&&(this._sprite=a,a?this.setContentSize(a.width,a.height):this.setContentSize(0,0),this._renderCmd.releaseData())},setType:function(a){a!==this._type&&(this._type=a,this._renderCmd.releaseData())},setReverseDirection:function(a){this._reverseDirection!==a&&(this._reverseDirection=a,this._renderCmd.releaseData())},initWithSprite:function(a){return this.percentage=0,this.setAnchorPoint(.5,.5),this._type=cc.ProgressTimer.TYPE_RADIAL,this._reverseDirection=!1,this.midPoint=cc.p(.5,.5),this.barChangeRate=cc.p(1,1),this.setSprite(a),this._renderCmd.initCmd(),!0},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ProgressTimer.CanvasRenderCmd(this):new cc.ProgressTimer.WebGLRenderCmd(this)}});var _p=cc.ProgressTimer.prototype;_p.midPoint,cc.defineGetterSetter(_p,"midPoint",_p.getMidpoint,_p.setMidpoint),_p.barChangeRate,cc.defineGetterSetter(_p,"barChangeRate",_p.getBarChangeRate,_p.setBarChangeRate),_p.type,cc.defineGetterSetter(_p,"type",_p.getType,_p.setType),_p.percentage,cc.defineGetterSetter(_p,"percentage",_p.getPercentage,_p.setPercentage),_p.sprite,cc.defineGetterSetter(_p,"sprite",_p.getSprite,_p.setSprite),_p.reverseDir,cc.defineGetterSetter(_p,"reverseDir",_p.isReverseDirection,_p.setReverseDirection),cc.ProgressTimer.create=function(a){return new cc.ProgressTimer(a)},cc.ProgressTimer.TEXTURE_COORDS_COUNT=4,cc.ProgressTimer.TEXTURE_COORDS=75,cc.ProgressTimer.TYPE_RADIAL=0,cc.ProgressTimer.TYPE_BAR=1,function(){cc.ProgressTimer.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._PI180=Math.PI/180,this._barRect=cc.rect(0,0,0,0),this._origin=cc.p(0,0),this._radius=0,this._startAngle=270,this._endAngle=270,this._counterClockWise=!1};var a=cc.ProgressTimer.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ProgressTimer.CanvasRenderCmd,a.rendering=function(a,b,c){var d=a||cc._renderContext,e=d.getContext(),f=this._node,g=f._sprite,h=g._renderCmd._textureCoord,i=g._renderCmd._displayedOpacity/255;if(0!==h.width&&0!==h.height&&g._texture&&h.validRect&&0!==i){d.setTransform(this._worldTransform,b,c),d.setCompositeOperation(g._blendFuncStr),d.setGlobalAlpha(i);var j=g._rect,k=g._offsetPosition,l=k.x,m=-k.y-j.height,n=j.width,o=j.height;if(d.save(),g._flippedX&&(l=-l-n,e.scale(-1,1)),g._flippedY&&(m=k.y,e.scale(1,-1)),f._type===cc.ProgressTimer.TYPE_BAR){var p=this._barRect;e.beginPath(),e.rect(p.x*b,p.y*c,p.width*b,p.height*c),e.clip(),e.closePath()}else if(f._type===cc.ProgressTimer.TYPE_RADIAL){var q=this._origin.x*b,r=this._origin.y*c;e.beginPath(),e.arc(q,r,this._radius*c,this._PI180*this._startAngle,this._PI180*this._endAngle,this._counterClockWise),e.lineTo(q,r),e.clip(),e.closePath()}var s=g._texture.getHtmlElementObj();g._renderCmd._colorized?e.drawImage(s,0,0,h.width,h.height,l*b,m*c,n*b,o*c):e.drawImage(s,h.renderX,h.renderY,h.width,h.height,l*b,m*c,n*b,o*c),d.restore(),cc.g_NumberOfDraws++}},a.releaseData=function(){},a.initCmd=function(){},a._updateProgress=function(){var a=this._node,b=a._sprite,c=b.width,d=b.height,e=a._midPoint;if(a._type===cc.ProgressTimer.TYPE_RADIAL){this._radius=Math.round(Math.sqrt(c*c+d*d));var f,g,h=!1,i=this._origin;i.x=c*e.x,i.y=-d*e.y,a._reverseDirection?(g=270,f=270-3.6*a._percentage):(f=-90,g=-90+3.6*a._percentage),b._flippedX&&(i.x-=c*(2*a._midPoint.x),f=-f,g=-g,f-=180,g-=180,h=!h),b._flippedY&&(i.y+=d*(2*a._midPoint.y),h=!h,f=-f,g=-g),this._startAngle=f,this._endAngle=g,this._counterClockWise=h}else{var j=a._barChangeRate,k=a._percentage/100,l=this._barRect,m=cc.size(c*(1-j.x),d*(1-j.y)),n=cc.size((c-m.width)*k,(d-m.height)*k),o=cc.size(m.width+n.width,m.height+n.height),p=cc.p(c*e.x,d*e.y),q=p.x-o.width/2;e.x>.5&&o.width/2>=c-p.x&&(q=c-o.width);var r=p.y-o.height/2;e.y>.5&&o.height/2>=d-p.y&&(r=d-o.height),l.x=0;var s=1;b._flippedX&&(l.x-=o.width,s=-1),q>0&&(l.x+=q*s),l.y=0;var t=1;b._flippedY&&(l.y+=o.height,t=-1),r>0&&(l.y-=r*t),l.width=o.width,l.height=-o.height}},a._updateColor=function(){},a._syncStatus=function(a){var b=this._node;if(b._sprite){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=c.colorDirty),e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty),a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty),this._dirtyFlag=d;var f=b._sprite._renderCmd,g=f._dirtyFlag,h=g&c.colorDirty,i=g&c.opacityDirty;h&&f._syncDisplayColor(),i&&f._syncDisplayOpacity(),(h||i)&&f._updateColor(),d&c.transformDirty&&this.transform(a),d&c.orderDirty&&(this._dirtyFlag=this._dirtyFlag&c.orderDirty^this._dirtyFlag)}},a.updateStatus=function(){var a=this._node;if(a._sprite){var b=cc.Node._dirtyFlags,c=this._dirtyFlag,d=a._sprite._renderCmd,e=d._dirtyFlag,f=e&b.colorDirty,g=e&b.opacityDirty;f&&d._updateDisplayColor(),g&&d._updateDisplayOpacity(),(f||g)&&d._updateColor(),c&b.transformDirty&&this.transform(this.getParentRenderCmd(),!0),this._dirtyFlag=0}}}(),cc.ProgressTo=cc.ActionInterval.extend({_to:0,_from:0,ctor:function(a,b){cc.ActionInterval.prototype.ctor.call(this),this._to=0,this._from=0,void 0!==b&&this.initWithDuration(a,b)},initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=b,!0):!1},clone:function(){var a=new cc.ProgressTo;return a.initWithDuration(this._duration,this._to),a},reverse:function(){return cc.log("cc.ProgressTo.reverse(): reverse hasn't been supported."),null},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a),this._from=a.percentage},update:function(a){this.target instanceof cc.ProgressTimer&&(this.target.percentage=this._from+(this._to-this._from)*a)}}),cc.progressTo=function(a,b){return new cc.ProgressTo(a,b)},cc.ProgressTo.create=cc.progressTo,cc.ProgressFromTo=cc.ActionInterval.extend({_to:0,_from:0,ctor:function(a,b,c){cc.ActionInterval.prototype.ctor.call(this),this._to=0,this._from=0,void 0!==c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=c,this._from=b,!0):!1},clone:function(){var a=new cc.ProgressFromTo;return a.initWithDuration(this._duration,this._from,this._to),a},reverse:function(){return cc.progressFromTo(this._duration,this._to,this._from)},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a)},update:function(a){this.target instanceof cc.ProgressTimer&&(this.target.percentage=this._from+(this._to-this._from)*a)}}),cc.progressFromTo=function(a,b,c){return new cc.ProgressFromTo(a,b,c)},cc.ProgressFromTo.create=cc.progressFromTo;!function(){cc.ProgressTimer.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._vertexWebGLBuffer=cc._renderContext.createBuffer(),this._vertexDataCount=0,this._vertexData=null,this._vertexArrayBuffer=null,this._vertexDataDirty=!1};var a=cc.ProgressTimer.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ProgressTimer.WebGLRenderCmd,a.rendering=function(a){var b=this._node,c=a||cc._renderContext;if(this._vertexData&&b._sprite){this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);var d=b._sprite._blendFunc;cc.glBlendFunc(d.src,d.dst),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),cc.glBindTexture2D(b._sprite.texture),c.bindBuffer(c.ARRAY_BUFFER,this._vertexWebGLBuffer),this._vertexDataDirty&&(c.bufferData(c.ARRAY_BUFFER,this._vertexArrayBuffer,c.DYNAMIC_DRAW),this._vertexDataDirty=!1);var e=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT;c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,c.FLOAT,!1,e,0),c.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,c.UNSIGNED_BYTE,!0,e,8),c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,c.FLOAT,!1,e,12),b._type===cc.ProgressTimer.TYPE_RADIAL?c.drawArrays(c.TRIANGLE_FAN,0,this._vertexDataCount):b._type===cc.ProgressTimer.TYPE_BAR&&(b._reverseDirection?(c.drawArrays(c.TRIANGLE_STRIP,0,this._vertexDataCount/2),c.drawArrays(c.TRIANGLE_STRIP,4,this._vertexDataCount/2),cc.g_NumberOfDraws++):c.drawArrays(c.TRIANGLE_STRIP,0,this._vertexDataCount)),cc.g_NumberOfDraws++}},a._syncStatus=function(a){var b=this._node;if(b._sprite){var c=cc.Node._dirtyFlags,d=this._dirtyFlag,e=a?a._node:null;e&&e._cascadeColorEnabled&&a._dirtyFlag&c.colorDirty&&(d|=c.colorDirty),e&&e._cascadeOpacityEnabled&&a._dirtyFlag&c.opacityDirty&&(d|=c.opacityDirty),a&&a._dirtyFlag&c.transformDirty&&(d|=c.transformDirty),this._dirtyFlag=d;var f=b._sprite._renderCmd,g=f._dirtyFlag,h=g&c.colorDirty,i=g&c.opacityDirty;h&&f._syncDisplayColor(),i&&f._syncDisplayOpacity(),(h||i)&&(f._updateColor(),this._updateColor()),this.transform(a),f._dirtyFlag=0}},a.updateStatus=function(){var a=this._node;if(a._sprite){var b=cc.Node._dirtyFlags,c=this._dirtyFlag,d=a._sprite._renderCmd,e=d._dirtyFlag,f=e&b.colorDirty,g=e&b.opacityDirty;f&&(d._updateDisplayColor(),this._dirtyFlag=this._dirtyFlag&b.colorDirty^this._dirtyFlag),g&&(d._updateDisplayOpacity(),this._dirtyFlag=this._dirtyFlag&b.opacityDirty^this._dirtyFlag),(f||g)&&(d._updateColor(),this._updateColor()),c&b.transformDirty&&this.transform(this.getParentRenderCmd(),!0),c&b.orderDirty&&(this._dirtyFlag=this._dirtyFlag&b.orderDirty^this._dirtyFlag)}},a.releaseData=function(){this._vertexData&&(this._vertexData=null,this._vertexArrayBuffer=null,this._vertexDataCount=0)},a.initCmd=function(){this._vertexData=null,this._vertexArrayBuffer=null,this._vertexDataCount=0,this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)},a._updateProgress=function(){var a=this._node,b=a._type;b===cc.ProgressTimer.TYPE_RADIAL?this._updateRadial():b===cc.ProgressTimer.TYPE_BAR&&this._updateBar(),this._vertexDataDirty=!0},a._updateBar=function(){var a=this._node;if(a._sprite){var b,c=a._percentage/100,d=a._barChangeRate,e=cc.pMult(cc.p(1-d.x+c*d.x,1-d.y+c*d.y),.5),f=cc.pSub(a._midPoint,e),g=cc.pAdd(a._midPoint,e);f.x<0&&(g.x+=-f.x,f.x=0),g.x>1&&(f.x-=g.x-1,g.x=1),f.y<0&&(g.y+=-f.y,f.y=0),g.y>1&&(f.y-=g.y-1,g.y=1);var h;if(this._reverseDirection){if(!this._vertexData){this._vertexDataCount=8;var i=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT,j=8;this._vertexArrayBuffer=new ArrayBuffer(j*i);var k=[];for(b=0;j>b;b++)k[b]=new cc.V2F_C4B_T2F(null,null,null,this._vertexArrayBuffer,b*i);k[0].texCoords=this._textureCoordFromAlphaPoint(cc.p(0,1)),k[0].vertices=this._vertexFromAlphaPoint(cc.p(0,1)),k[1].texCoords=this._textureCoordFromAlphaPoint(cc.p(0,0)),k[1].vertices=this._vertexFromAlphaPoint(cc.p(0,0)),k[6].texCoords=this._textureCoordFromAlphaPoint(cc.p(1,1)),k[6].vertices=this._vertexFromAlphaPoint(cc.p(1,1)),k[7].texCoords=this._textureCoordFromAlphaPoint(cc.p(1,0)),k[7].vertices=this._vertexFromAlphaPoint(cc.p(1,0)),this._vertexData=k}h=this._vertexData,h[2].texCoords=this._textureCoordFromAlphaPoint(cc.p(f.x,g.y)),h[2].vertices=this._vertexFromAlphaPoint(cc.p(f.x,g.y)),h[3].texCoords=this._textureCoordFromAlphaPoint(cc.p(f.x,f.y)),h[3].vertices=this._vertexFromAlphaPoint(cc.p(f.x,f.y)),h[4].texCoords=this._textureCoordFromAlphaPoint(cc.p(g.x,g.y)),h[4].vertices=this._vertexFromAlphaPoint(cc.p(g.x,g.y)),h[5].texCoords=this._textureCoordFromAlphaPoint(cc.p(g.x,f.y)),h[5].vertices=this._vertexFromAlphaPoint(cc.p(g.x,f.y))}else{if(!this._vertexData){this._vertexDataCount=4;var l=cc.V2F_C4B_T2F.BYTES_PER_ELEMENT,m=4;for(this._vertexArrayBuffer=new ArrayBuffer(m*l),this._vertexData=[],b=0;m>b;b++)this._vertexData[b]=new cc.V2F_C4B_T2F(null,null,null,this._vertexArrayBuffer,b*l)}h=this._vertexData,h[0].texCoords=this._textureCoordFromAlphaPoint(cc.p(f.x,g.y)),h[0].vertices=this._vertexFromAlphaPoint(cc.p(f.x,g.y)),h[1].texCoords=this._textureCoordFromAlphaPoint(cc.p(f.x,f.y)),h[1].vertices=this._vertexFromAlphaPoint(cc.p(f.x,f.y)),h[2].texCoords=this._textureCoordFromAlphaPoint(cc.p(g.x,g.y)),h[2].vertices=this._vertexFromAlphaPoint(cc.p(g.x,g.y)),h[3].texCoords=this._textureCoordFromAlphaPoint(cc.p(g.x,f.y)),h[3].vertices=this._vertexFromAlphaPoint(cc.p(g.x,f.y))}this._updateColor()}},a._updateRadial=function(){var a=this._node;if(a._sprite){var b,c,d=a._midPoint,e=a._percentage/100,f=2*cc.PI*(a._reverseDirection?e:1-e),g=cc.p(d.x,1),h=cc.pRotateByAngle(g,d,f),i=0;if(0===e)c=g,i=0;else if(1===e)c=g,i=4;else{var j=cc.FLT_MAX,k=cc.ProgressTimer.TEXTURE_COORDS_COUNT;for(b=0;k>=b;++b){var l=(b+(k-1))%k,m=this._boundaryTexCoord(b%k),n=this._boundaryTexCoord(l);0===b?n=cc.pLerp(m,n,1-d.x):4===b&&(m=cc.pLerp(m,n,1-d.x));var o=cc.p(0,0);if(cc.pLineIntersect(m,n,d,h,o)){if(!(0!==b&&4!==b||0<=o.x&&o.x<=1))continue;o.y>=0&&o.yb;b++)s[b]=new cc.V2F_C4B_T2F(null,null,null,this._vertexArrayBuffer,b*r);if(this._vertexData=s,!this._vertexData)return void cc.log("cc.ProgressTimer._updateRadial() : Not enough memory")}this._updateColor();var t=this._vertexData;if(!p)for(t[0].texCoords=this._textureCoordFromAlphaPoint(d),t[0].vertices=this._vertexFromAlphaPoint(d),t[1].texCoords=this._textureCoordFromAlphaPoint(g),t[1].vertices=this._vertexFromAlphaPoint(g),b=0;i>b;b++){var u=this._boundaryTexCoord(b);t[b+2].texCoords=this._textureCoordFromAlphaPoint(u),t[b+2].vertices=this._vertexFromAlphaPoint(u)}t[this._vertexDataCount-1].texCoords=this._textureCoordFromAlphaPoint(c),t[this._vertexDataCount-1].vertices=this._vertexFromAlphaPoint(c)}},a._boundaryTexCoord=function(a){if(a>7-(a<<1)&1,b>>7-((a<<1)+1)&1):cc.p(b>>(a<<1)+1&1,b>>(a<<1)&1)}return cc.p(0,0)},a._textureCoordFromAlphaPoint=function(a){var b=this._node._sprite;if(!b)return{u:0,v:0};var c=b.quad,d=cc.p(c.bl.texCoords.u,c.bl.texCoords.v),e=cc.p(c.tr.texCoords.u,c.tr.texCoords.v);if(b.textureRectRotated){var f=a.x;a.x=a.y,a.y=f}return{u:d.x*(1-a.x)+e.x*a.x,v:d.y*(1-a.y)+e.y*a.y}},a._vertexFromAlphaPoint=function(a){var b=this._node._sprite;if(!b)return{x:0,y:0};var c=b.quad,d=cc.p(c.bl.vertices.x,c.bl.vertices.y),e=cc.p(c.tr.vertices.x,c.tr.vertices.y);return{x:d.x*(1-a.x)+e.x*a.x,y:d.y*(1-a.y)+e.y*a.y}},a._updateColor=function(){var a=this._node;if(a._sprite&&this._vertexData){for(var b=a._sprite.quad.tl.colors,c=this._vertexData,d=0,e=this._vertexDataCount;e>d;++d)c[d].colors=b;this._vertexDataDirty=!0}}}();cc.SCENE_FADE=4208917214,cc.TRANSITION_ORIENTATION_LEFT_OVER=0,cc.TRANSITION_ORIENTATION_RIGHT_OVER=1,cc.TRANSITION_ORIENTATION_UP_OVER=0,cc.TRANSITION_ORIENTATION_DOWN_OVER=1,cc.TransitionScene=cc.Scene.extend({_inScene:null,_outScene:null,_duration:null,_isInSceneOnTop:!1,_isSendCleanupToScene:!1,_className:"TransitionScene",ctor:function(a,b){cc.Scene.prototype.ctor.call(this),void 0!==a&&void 0!==b&&this.initWithDuration(a,b)},_setNewScene:function(a){this.unschedule(this._setNewScene);var b=cc.director;this._isSendCleanupToScene=b.isSendCleanupToScene(),b.runScene(this._inScene),cc.eventManager.setEnabled(!0),this._outScene.visible=!0},_sceneOrder:function(){this._isInSceneOnTop=!0},visit:function(){this._isInSceneOnTop?(this._outScene.visit(),this._inScene.visit()):(this._inScene.visit(),this._outScene.visit()),cc.Node.prototype.visit.call(this)},onEnter:function(){cc.Node.prototype.onEnter.call(this),cc.eventManager.setEnabled(!1),this._outScene.onExitTransitionDidStart(),this._inScene.onEnter()},onExit:function(){cc.Node.prototype.onExit.call(this),cc.eventManager.setEnabled(!0),this._outScene.onExit(),this._inScene.onEnterTransitionDidFinish()},cleanup:function(){cc.Node.prototype.cleanup.call(this),this._isSendCleanupToScene&&this._outScene.cleanup()},initWithDuration:function(a,b){if(!b)throw new Error("cc.TransitionScene.initWithDuration(): Argument scene must be non-nil");if(this.init()){if(this._duration=a,this.attr({x:0,y:0,anchorX:0,anchorY:0}),this._inScene=b,this._outScene=cc.director.getRunningScene(),this._outScene||(this._outScene=new cc.Scene,this._outScene.init()),this._inScene===this._outScene)throw new Error("cc.TransitionScene.initWithDuration(): Incoming scene must be different from the outgoing scene");return this._sceneOrder(),!0}return!1},finish:function(){this._inScene.attr({visible:!0,x:0,y:0,scale:1,rotation:0}),cc._renderType===cc.game.RENDER_TYPE_WEBGL&&this._inScene.getCamera().restore(),this._outScene.attr({visible:!1,x:0,y:0,scale:1,rotation:0}),cc._renderType===cc.game.RENDER_TYPE_WEBGL&&this._outScene.getCamera().restore(),this.schedule(this._setNewScene,0)},hideOutShowIn:function(){this._inScene.visible=!0,this._outScene.visible=!1}}),cc.TransitionScene.create=function(a,b){return new cc.TransitionScene(a,b)},cc.TransitionSceneOriented=cc.TransitionScene.extend({_orientation:0,ctor:function(a,b,c){cc.TransitionScene.prototype.ctor.call(this),void 0!=c&&this.initWithDuration(a,b,c)},initWithDuration:function(a,b,c){return cc.TransitionScene.prototype.initWithDuration.call(this,a,b)&&(this._orientation=c),!0}}),cc.TransitionSceneOriented.create=function(a,b,c){return new cc.TransitionSceneOriented(a,b,c)},cc.TransitionRotoZoom=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this._inScene.attr({scale:.001,anchorX:.5,anchorY:.5}),this._outScene.attr({scale:1,anchorX:.5,anchorY:.5});var a=cc.sequence(cc.spawn(cc.scaleBy(this._duration/2,.001),cc.rotateBy(this._duration/2,720)),cc.delayTime(this._duration/2));this._outScene.runAction(a),this._inScene.runAction(cc.sequence(a.reverse(),cc.callFunc(this.finish,this)))}}),cc.TransitionRotoZoom.create=function(a,b){return new cc.TransitionRotoZoom(a,b)},cc.TransitionJumpZoom=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a=cc.director.getWinSize();this._inScene.attr({scale:.5,x:a.width,y:0,anchorX:.5,anchorY:.5}),this._outScene.anchorX=.5,this._outScene.anchorY=.5;var b=cc.jumpBy(this._duration/4,cc.p(-a.width,0),a.width/4,2),c=cc.scaleTo(this._duration/4,1),d=cc.scaleTo(this._duration/4,.5),e=cc.sequence(d,b),f=cc.sequence(b,c),g=cc.delayTime(this._duration/2);this._outScene.runAction(e),this._inScene.runAction(cc.sequence(g,f,cc.callFunc(this.finish,this)))}}),cc.TransitionJumpZoom.create=function(a,b){return new cc.TransitionJumpZoom(a,b)},cc.TransitionMoveInL=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this.initScenes();var a=this.action();this._inScene.runAction(cc.sequence(this.easeActionWithAction(a),cc.callFunc(this.finish,this)))},initScenes:function(){this._inScene.setPosition(-cc.director.getWinSize().width,0)},action:function(){return cc.moveTo(this._duration,cc.p(0,0))},easeActionWithAction:function(a){return new cc.EaseOut(a,2)}}),cc.TransitionMoveInL.create=function(a,b){return new cc.TransitionMoveInL(a,b)},cc.TransitionMoveInR=cc.TransitionMoveInL.extend({ctor:function(a,b){cc.TransitionMoveInL.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},initScenes:function(){this._inScene.setPosition(cc.director.getWinSize().width,0)}}),cc.TransitionMoveInR.create=function(a,b){return new cc.TransitionMoveInR(a,b)},cc.TransitionMoveInT=cc.TransitionMoveInL.extend({ctor:function(a,b){cc.TransitionMoveInL.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},initScenes:function(){this._inScene.setPosition(0,cc.director.getWinSize().height)}}),cc.TransitionMoveInT.create=function(a,b){return new cc.TransitionMoveInT(a,b)},cc.TransitionMoveInB=cc.TransitionMoveInL.extend({ctor:function(a,b){cc.TransitionMoveInL.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},initScenes:function(){this._inScene.setPosition(0,-cc.director.getWinSize().height)}}),cc.TransitionMoveInB.create=function(a,b){return new cc.TransitionMoveInB(a,b)},cc.ADJUST_FACTOR=.5,cc.TransitionSlideInL=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this.initScenes();var a=this.action(),b=this.action(),c=cc.sequence(this.easeActionWithAction(a),cc.callFunc(this.finish,this)),d=this.easeActionWithAction(b);this._inScene.runAction(c),this._outScene.runAction(d)},initScenes:function(){this._inScene.setPosition(-cc.director.getWinSize().width+cc.ADJUST_FACTOR,0)},action:function(){return cc.moveBy(this._duration,cc.p(cc.director.getWinSize().width-cc.ADJUST_FACTOR,0))},easeActionWithAction:function(a){return new cc.EaseInOut(a,2)}}),cc.TransitionSlideInL.create=function(a,b){return new cc.TransitionSlideInL(a,b)},cc.TransitionSlideInR=cc.TransitionSlideInL.extend({ctor:function(a,b){cc.TransitionSlideInL.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!0},initScenes:function(){this._inScene.setPosition(cc.director.getWinSize().width-cc.ADJUST_FACTOR,0)},action:function(){return cc.moveBy(this._duration,cc.p(-(cc.director.getWinSize().width-cc.ADJUST_FACTOR),0))}}),cc.TransitionSlideInR.create=function(a,b){return new cc.TransitionSlideInR(a,b)},cc.TransitionSlideInB=cc.TransitionSlideInL.extend({ctor:function(a,b){cc.TransitionSlideInL.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},initScenes:function(){this._inScene.setPosition(0,-(cc.director.getWinSize().height-cc.ADJUST_FACTOR))},action:function(){return cc.moveBy(this._duration,cc.p(0,cc.director.getWinSize().height-cc.ADJUST_FACTOR))}}),cc.TransitionSlideInB.create=function(a,b){return new cc.TransitionSlideInB(a,b)},cc.TransitionSlideInT=cc.TransitionSlideInL.extend({ctor:function(a,b){cc.TransitionSlideInL.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!0},initScenes:function(){this._inScene.setPosition(0,cc.director.getWinSize().height-cc.ADJUST_FACTOR)},action:function(){return cc.moveBy(this._duration,cc.p(0,-(cc.director.getWinSize().height-cc.ADJUST_FACTOR)))}}),cc.TransitionSlideInT.create=function(a,b){return new cc.TransitionSlideInT(a,b)},cc.TransitionShrinkGrow=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this._inScene.attr({scale:.001,anchorX:2/3,anchorY:.5}),this._outScene.attr({scale:1,anchorX:1/3,anchorY:.5});var a=cc.scaleTo(this._duration,.01),b=cc.scaleTo(this._duration,1);this._inScene.runAction(cc.sequence(this.easeActionWithAction(b),cc.callFunc(this.finish,this))),this._outScene.runAction(this.easeActionWithAction(a))},easeActionWithAction:function(a){return new cc.EaseOut(a,2)}}),cc.TransitionShrinkGrow.create=function(a,b){return new cc.TransitionShrinkGrow(a,b)},cc.TransitionFlipX=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this),null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d,e,f;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(c=90,d=270,e=90,f=0):(c=-90,d=90,e=-90,f=0),a=cc.sequence(cc.delayTime(this._duration/2),cc.show(),cc.orbitCamera(this._duration/2,1,0,d,c,0,0),cc.callFunc(this.finish,this)),b=cc.sequence(cc.orbitCamera(this._duration/2,1,0,f,e,0,0),cc.hide(),cc.delayTime(this._duration/2)),this._inScene.runAction(a),this._outScene.runAction(b)}}),cc.TransitionFlipX.create=function(a,b,c){return new cc.TransitionFlipX(a,b,c)},cc.TransitionFlipY=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this),null==c&&(c=cc.TRANSITION_ORIENTATION_UP_OVER),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d,e,f;this._orientation===cc.TRANSITION_ORIENTATION_UP_OVER?(c=90,d=270,e=90,f=0):(c=-90,d=90,e=-90,f=0),a=cc.sequence(cc.delayTime(this._duration/2),cc.show(),cc.orbitCamera(this._duration/2,1,0,d,c,90,0),cc.callFunc(this.finish,this)),b=cc.sequence(cc.orbitCamera(this._duration/2,1,0,f,e,90,0),cc.hide(),cc.delayTime(this._duration/2)),this._inScene.runAction(a),this._outScene.runAction(b)}}),cc.TransitionFlipY.create=function(a,b,c){return new cc.TransitionFlipY(a,b,c)},cc.TransitionFlipAngular=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this),null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d,e,f;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(c=90,d=270,e=90,f=0):(c=-90,d=90,e=-90,f=0),a=cc.sequence(cc.delayTime(this._duration/2),cc.show(),cc.orbitCamera(this._duration/2,1,0,d,c,-45,0),cc.callFunc(this.finish,this)),b=cc.sequence(cc.orbitCamera(this._duration/2,1,0,f,e,45,0),cc.hide(),cc.delayTime(this._duration/2)),this._inScene.runAction(a),this._outScene.runAction(b)}}),cc.TransitionFlipAngular.create=function(a,b,c){return new cc.TransitionFlipAngular(a,b,c)},cc.TransitionZoomFlipX=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this),null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d,e,f;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(c=90,d=270,e=90,f=0):(c=-90,d=90,e=-90,f=0),a=cc.sequence(cc.delayTime(this._duration/2),cc.spawn(cc.orbitCamera(this._duration/2,1,0,d,c,0,0),cc.scaleTo(this._duration/2,1),cc.show()),cc.callFunc(this.finish,this)),b=cc.sequence(cc.spawn(cc.orbitCamera(this._duration/2,1,0,f,e,0,0),cc.scaleTo(this._duration/2,.5)),cc.hide(),cc.delayTime(this._duration/2)),this._inScene.scale=.5,this._inScene.runAction(a),this._outScene.runAction(b)}}),cc.TransitionZoomFlipX.create=function(a,b,c){return new cc.TransitionZoomFlipX(a,b,c)},cc.TransitionZoomFlipY=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this),null==c&&(c=cc.TRANSITION_ORIENTATION_UP_OVER),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d,e,f;this._orientation===cc.TRANSITION_ORIENTATION_UP_OVER?(c=90,d=270,e=90,f=0):(c=-90,d=90,e=-90,f=0),a=cc.sequence(cc.delayTime(this._duration/2),cc.spawn(cc.orbitCamera(this._duration/2,1,0,d,c,90,0),cc.scaleTo(this._duration/2,1),cc.show()),cc.callFunc(this.finish,this)),b=cc.sequence(cc.spawn(cc.orbitCamera(this._duration/2,1,0,f,e,90,0),cc.scaleTo(this._duration/2,.5)),cc.hide(),cc.delayTime(this._duration/2)),this._inScene.scale=.5,this._inScene.runAction(a),this._outScene.runAction(b)}}),cc.TransitionZoomFlipY.create=function(a,b,c){return new cc.TransitionZoomFlipY(a,b,c)},cc.TransitionZoomFlipAngular=cc.TransitionSceneOriented.extend({ctor:function(a,b,c){cc.TransitionSceneOriented.prototype.ctor.call(this),null==c&&(c=cc.TRANSITION_ORIENTATION_RIGHT_OVER),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b;this._inScene.visible=!1;var c,d,e,f;this._orientation===cc.TRANSITION_ORIENTATION_RIGHT_OVER?(c=90,d=270,e=90,f=0):(c=-90,d=90,e=-90,f=0),a=cc.sequence(cc.delayTime(this._duration/2),cc.spawn(cc.orbitCamera(this._duration/2,1,0,d,c,-45,0),cc.scaleTo(this._duration/2,1),cc.show()),cc.show(),cc.callFunc(this.finish,this)),b=cc.sequence(cc.spawn(cc.orbitCamera(this._duration/2,1,0,f,e,45,0),cc.scaleTo(this._duration/2,.5)),cc.hide(),cc.delayTime(this._duration/2)),this._inScene.scale=.5,this._inScene.runAction(a),this._outScene.runAction(b)}}),cc.TransitionZoomFlipAngular.create=function(a,b,c){return new cc.TransitionZoomFlipAngular(a,b,c)},cc.TransitionFade=cc.TransitionScene.extend({_color:null,ctor:function(a,b,c){cc.TransitionScene.prototype.ctor.call(this),this._color=cc.color(),b&&this.initWithDuration(a,b,c)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a=new cc.LayerColor(this._color);this._inScene.visible=!1,this.addChild(a,2,cc.SCENE_FADE);var b=this.getChildByTag(cc.SCENE_FADE),c=cc.sequence(cc.fadeIn(this._duration/2),cc.callFunc(this.hideOutShowIn,this),cc.fadeOut(this._duration/2),cc.callFunc(this.finish,this));b.runAction(c)},onExit:function(){cc.TransitionScene.prototype.onExit.call(this),this.removeChildByTag(cc.SCENE_FADE,!1)},initWithDuration:function(a,b,c){return c=c||cc.color.BLACK,cc.TransitionScene.prototype.initWithDuration.call(this,a,b)&&(this._color.r=c.r,this._color.g=c.g,this._color.b=c.b,this._color.a=0),!0}}),cc.TransitionFade.create=function(a,b,c){return new cc.TransitionFade(a,b,c)},cc.TransitionCrossFade=cc.TransitionScene.extend({ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a=cc.color(0,0,0,0),b=cc.director.getWinSize(),c=new cc.LayerColor(a),d=new cc.RenderTexture(b.width,b.height);d.sprite.anchorX=.5,d.sprite.anchorY=.5,d.attr({x:b.width/2,y:b.height/2,anchorX:.5,anchorY:.5}),d.begin(),this._inScene.visit(),d.end();var e=new cc.RenderTexture(b.width,b.height);e.setPosition(b.width/2,b.height/2),e.sprite.anchorX=e.anchorX=.5,e.sprite.anchorY=e.anchorY=.5,e.begin(),this._outScene.visit(),e.end(),d.sprite.setBlendFunc(cc.ONE,cc.ONE),e.sprite.setBlendFunc(cc.SRC_ALPHA,cc.ONE_MINUS_SRC_ALPHA),c.addChild(d),c.addChild(e),d.sprite.opacity=255,e.sprite.opacity=255;var f=cc.sequence(cc.fadeTo(this._duration,0),cc.callFunc(this.hideOutShowIn,this),cc.callFunc(this.finish,this));e.sprite.runAction(f),this.addChild(c,2,cc.SCENE_FADE)},onExit:function(){this.removeChildByTag(cc.SCENE_FADE,!1),cc.TransitionScene.prototype.onExit.call(this)},visit:function(){cc.Node.prototype.visit.call(this)},draw:function(){}}),cc.TransitionCrossFade.create=function(a,b){return new cc.TransitionCrossFade(a,b)},cc.TransitionTurnOffTiles=cc.TransitionScene.extend({_gridProxy:null,ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),this._gridProxy=new cc.NodeGrid,b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this._gridProxy.setTarget(this._outScene),this._gridProxy.onEnter();var a=cc.director.getWinSize(),b=a.width/a.height,c=0|12*b,d=12,e=cc.turnOffTiles(this._duration,cc.size(c,d)),f=this.easeActionWithAction(e);this._gridProxy.runAction(cc.sequence(f,cc.callFunc(this.finish,this),cc.stopGrid()))},visit:function(){this._inScene.visit(),this._gridProxy.visit()},easeActionWithAction:function(a){return a}}),cc.TransitionTurnOffTiles.create=function(a,b){return new cc.TransitionTurnOffTiles(a,b)},cc.TransitionSplitCols=cc.TransitionScene.extend({_gridProxy:null,_switchTargetToInscene:function(){this._gridProxy.setTarget(this._inScene)},ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),this._gridProxy=new cc.NodeGrid,b&&this.initWithDuration(a,b)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this._gridProxy.setTarget(this._outScene),this._gridProxy.onEnter();var a=this.action(),b=cc.sequence(a,cc.callFunc(this._switchTargetToInscene,this),a.reverse());this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(b),cc.callFunc(this.finish,this),cc.stopGrid()))},onExit:function(){this._gridProxy.setTarget(null),this._gridProxy.onExit(),cc.TransitionScene.prototype.onExit.call(this)},visit:function(){this._gridProxy.visit()},easeActionWithAction:function(a){return new cc.EaseInOut(a,3)},action:function(){return cc.splitCols(this._duration/2,3)}}),cc.TransitionSplitCols.create=function(a,b){return new cc.TransitionSplitCols(a,b)},cc.TransitionSplitRows=cc.TransitionSplitCols.extend({ctor:function(a,b){cc.TransitionSplitCols.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},action:function(){return cc.splitRows(this._duration/2,3)}}),cc.TransitionSplitRows.create=function(a,b){return new cc.TransitionSplitRows(a,b)},cc.TransitionFadeTR=cc.TransitionScene.extend({_gridProxy:null,ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),this._gridProxy=new cc.NodeGrid,b&&this.initWithDuration(a,b)},_sceneOrder:function(){this._isInSceneOnTop=!1},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this._gridProxy.setTarget(this._outScene),this._gridProxy.onEnter();var a=cc.director.getWinSize(),b=a.width/a.height,c=0|12*b,d=12,e=this.actionWithSize(cc.size(c,d));this._gridProxy.runAction(cc.sequence(this.easeActionWithAction(e),cc.callFunc(this.finish,this),cc.stopGrid()))},visit:function(){this._inScene.visit(),this._gridProxy.visit()},easeActionWithAction:function(a){return a},actionWithSize:function(a){return cc.fadeOutTRTiles(this._duration,a)}}),cc.TransitionFadeTR.create=function(a,b){return new cc.TransitionFadeTR(a,b)},cc.TransitionFadeBL=cc.TransitionFadeTR.extend({ctor:function(a,b){cc.TransitionFadeTR.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},actionWithSize:function(a){return cc.fadeOutBLTiles(this._duration,a)}}),cc.TransitionFadeBL.create=function(a,b){return new cc.TransitionFadeBL(a,b)},cc.TransitionFadeUp=cc.TransitionFadeTR.extend({ctor:function(a,b){cc.TransitionFadeTR.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},actionWithSize:function(a){return new cc.FadeOutUpTiles(this._duration,a)}}),cc.TransitionFadeUp.create=function(a,b){return new cc.TransitionFadeUp(a,b)},cc.TransitionFadeDown=cc.TransitionFadeTR.extend({ctor:function(a,b){cc.TransitionFadeTR.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},actionWithSize:function(a){return cc.fadeOutDownTiles(this._duration,a)}}),cc.TransitionFadeDown.create=function(a,b){return new cc.TransitionFadeDown(a,b)},cc.SCENE_RADIAL=49153,cc.TransitionProgress=cc.TransitionScene.extend({_to:0,_from:0,_sceneToBeModified:null,_className:"TransitionProgress",ctor:function(a,b){cc.TransitionScene.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_setAttrs:function(a,b,c){a.attr({x:b,y:c,anchorX:.5,anchorY:.5})},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this),this._setupTransition();var a=cc.director.getWinSize(),b=new cc.RenderTexture(a.width,a.height);b.sprite.anchorX=.5,b.sprite.anchorY=.5,this._setAttrs(b,a.width/2,a.height/2),b.clear(0,0,0,1),b.begin(),this._sceneToBeModified.visit(),b.end(),this._sceneToBeModified===this._outScene&&this.hideOutShowIn();var c=this._progressTimerNodeWithRenderTexture(b),d=cc.sequence(cc.progressFromTo(this._duration,this._from,this._to),cc.callFunc(this.finish,this));c.runAction(d),this.addChild(c,2,cc.SCENE_RADIAL)},onExit:function(){this.removeChildByTag(cc.SCENE_RADIAL,!0),cc.TransitionScene.prototype.onExit.call(this)},_setupTransition:function(){this._sceneToBeModified=this._outScene,this._from=100,this._to=0},_progressTimerNodeWithRenderTexture:function(a){return cc.log("cc.TransitionProgress._progressTimerNodeWithRenderTexture(): should be overridden in subclass"),null},_sceneOrder:function(){this._isInSceneOnTop=!1}}),cc.TransitionProgress.create=function(a,b){return new cc.TransitionProgress(a,b)},cc.TransitionProgressRadialCCW=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize(),c=new cc.ProgressTimer(a.sprite);return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(c.sprite.flippedY=!0),c.type=cc.ProgressTimer.TYPE_RADIAL,c.reverseDir=!1,c.percentage=100,this._setAttrs(c,b.width/2,b.height/2),c}}),cc.TransitionProgressRadialCCW.create=function(a,b){return new cc.TransitionProgressRadialCCW(a,b)},cc.TransitionProgressRadialCW=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize(),c=new cc.ProgressTimer(a.sprite);return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(c.sprite.flippedY=!0),c.type=cc.ProgressTimer.TYPE_RADIAL,c.reverseDir=!0,c.percentage=100,this._setAttrs(c,b.width/2,b.height/2),c}}),cc.TransitionProgressRadialCW.create=function(a,b){var c=new cc.TransitionProgressRadialCW;return null!==c&&c.initWithDuration(a,b)?c:new cc.TransitionProgressRadialCW(a,b)},cc.TransitionProgressHorizontal=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize(),c=new cc.ProgressTimer(a.sprite);return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(c.sprite.flippedY=!0),c.type=cc.ProgressTimer.TYPE_BAR,c.midPoint=cc.p(1,0),c.barChangeRate=cc.p(1,0),c.percentage=100,this._setAttrs(c,b.width/2,b.height/2),c}}),cc.TransitionProgressHorizontal.create=function(a,b){return new cc.TransitionProgressHorizontal(a,b)},cc.TransitionProgressVertical=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize(),c=new cc.ProgressTimer(a.sprite);return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(c.sprite.flippedY=!0),c.type=cc.ProgressTimer.TYPE_BAR,c.midPoint=cc.p(0,0),c.barChangeRate=cc.p(0,1),c.percentage=100,this._setAttrs(c,b.width/2,b.height/2),c}}),cc.TransitionProgressVertical.create=function(a,b){return new cc.TransitionProgressVertical(a,b)},cc.TransitionProgressInOut=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize(),c=new cc.ProgressTimer(a.sprite);return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(c.sprite.flippedY=!0),c.type=cc.ProgressTimer.TYPE_BAR,c.midPoint=cc.p(.5,.5),c.barChangeRate=cc.p(1,1),c.percentage=0,this._setAttrs(c,b.width/2,b.height/2),c},_sceneOrder:function(){this._isInSceneOnTop=!1},_setupTransition:function(){this._sceneToBeModified=this._inScene,this._from=0,this._to=100}}),cc.TransitionProgressInOut.create=function(a,b){return new cc.TransitionProgressInOut(a,b)},cc.TransitionProgressOutIn=cc.TransitionProgress.extend({ctor:function(a,b){cc.TransitionProgress.prototype.ctor.call(this),b&&this.initWithDuration(a,b)},_progressTimerNodeWithRenderTexture:function(a){var b=cc.director.getWinSize(),c=new cc.ProgressTimer(a.sprite);return cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(c.sprite.flippedY=!0),c.type=cc.ProgressTimer.TYPE_BAR,c.midPoint=cc.p(.5,.5),c.barChangeRate=cc.p(1,1),c.percentage=100,this._setAttrs(c,b.width/2,b.height/2),c}}),cc.TransitionProgressOutIn.create=function(a,b){return new cc.TransitionProgressOutIn(a,b)},cc.TransitionPageTurn=cc.TransitionScene.extend({ctor:function(a,b,c){cc.TransitionScene.prototype.ctor.call(this),this._gridProxy=new cc.NodeGrid,this.initWithDuration(a,b,c)},_back:!0,_gridProxy:null,_className:"TransitionPageTurn",initWithDuration:function(a,b,c){return this._back=c,cc.TransitionScene.prototype.initWithDuration.call(this,a,b),!0},actionWithSize:function(a){return this._back?cc.reverseTime(cc.pageTurn3D(this._duration,a)):cc.pageTurn3D(this._duration,a)},onEnter:function(){cc.TransitionScene.prototype.onEnter.call(this);var a,b,c=cc.director.getWinSize();c.width>c.height?(a=16,b=12):(a=12,b=16);var d=this.actionWithSize(cc.size(a,b)),e=this._gridProxy;this._back?(e.setTarget(this._inScene),e.onEnter(),this._inScene.visible=!1,e.runAction(cc.sequence(d,cc.callFunc(this.finish,this),cc.stopGrid())),this._inScene.runAction(cc.show())):(e.setTarget(this._outScene),e.onEnter(),e.runAction(cc.sequence(d,cc.callFunc(this.finish,this),cc.stopGrid())))},visit:function(){this._back?this._outScene.visit():this._inScene.visit(),this._gridProxy.visit()},_sceneOrder:function(){this._isInSceneOnTop=this._back}}),cc.TransitionPageTurn.create=function(a,b,c){return new cc.TransitionPageTurn(a,b,c)};cc.Codec={name:"Jacob__Codec"},cc.unzip=function(){return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,arguments)},cc.unzipBase64=function(){var a=cc.Codec.Base64.decode.apply(cc.Codec.Base64,arguments);return cc.Codec.GZip.gunzip.apply(cc.Codec.GZip,[a])},cc.unzipBase64AsArray=function(a,b){b=b||1;var c,d,e,f=this.unzipBase64(a),g=[];for(c=0,e=f.length/b;e>c;c++)for(g[c]=0,d=b-1;d>=0;--d)g[c]+=f.charCodeAt(c*b+d)<<8*d;return g},cc.unzipAsArray=function(a,b){b=b||1;var c,d,e,f=this.unzip(a),g=[];for(c=0,e=f.length/b;e>c;c++)for(g[c]=0,d=b-1;d>=0;--d)g[c]+=f.charCodeAt(c*b+d)<<8*d;return g},cc.StringToArray=function(a){var b,c=a.split(","),d=[];for(b=0;b>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i.push(String.fromCharCode(b)),64!==g&&i.push(String.fromCharCode(c)),64!==h&&i.push(String.fromCharCode(d));return i=i.join("")},cc.Codec.Base64.decodeAsArray=function(a,b){var c,d,e,f=this.decode(a),g=[];for(c=0,e=f.length/b;e>c;c++)for(g[c]=0,d=b-1;d>=0;--d)g[c]+=f.charCodeAt(c*b+d)<<8*d;return g},cc.uint8ArrayToUint32Array=function(a){if(a.length%4!==0)return null;for(var b=a.length/4,c=window.Uint32Array?new Uint32Array(b):[],d=0;b>d;d++){var e=4*d;c[d]=a[e]+256*a[e+1]+65536*a[e+2]+a[e+3]*(1<<24)}return c},cc.Codec.GZip=function(a){this.data=a,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(cc.Codec.GZip.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0},cc.Codec.GZip.gunzip=function(a){a.constructor===Array||a.constructor===String;var b=new cc.Codec.GZip(a);return b.gunzip()[0][0]},cc.Codec.GZip.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},cc.Codec.GZip.LITERALS=288,cc.Codec.GZip.NAMEMAX=256,cc.Codec.GZip.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],cc.Codec.GZip.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],cc.Codec.GZip.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],cc.Codec.GZip.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],cc.Codec.GZip.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],cc.Codec.GZip.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],cc.Codec.GZip.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},cc.Codec.GZip.prototype.readByte=function(){return this.bits+=8,this.bytepos>=1,0===this.bb&&(this.bb=this.readByte(),a=1&this.bb,this.bb=this.bb>>1|128),a},cc.Codec.GZip.prototype.readBits=function(a){for(var b=0,c=a;c--;)b=b<<1|this.readBit();return a&&(b=cc.Codec.GZip.bitReverse[b]>>8-a),b},cc.Codec.GZip.prototype.flushBuffer=function(){this.bIdx=0},cc.Codec.GZip.prototype.addBuffer=function(a){this.buf32k[this.bIdx++]=a,this.outputArr.push(String.fromCharCode(a)),32768===this.bIdx&&(this.bIdx=0)},cc.Codec.GZip.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},cc.Codec.GZip.prototype.Rec=function(){var a,b=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,a=this.IsPat(),a>=0)b.b0=a;else if(b.b0=32768,this.Rec())return-1;if(a=this.IsPat(),a>=0)b.b1=a,b.jump=null;else if(b.b1=32768,b.jump=this.Places[this.treepos],b.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},cc.Codec.GZip.prototype.CreateTree=function(a,b,c,d){var e;for(this.Places=a,this.treepos=0,this.flens=c,this.fmax=b,e=0;17>e;e++)this.fpos[e]=0;return this.len=0,this.Rec()?-1:0},cc.Codec.GZip.prototype.DecodeValue=function(a){for(var b,c,d,e=0,f=a[e];;)if(d=this.readBit()){if(!(32768&f.b1))return f.b1;for(f=f.jump,b=a.length,c=0;b>c;c++)if(a[c]===f){e=c;break}}else{if(!(32768&f.b0))return f.b0;e++,f=a[e]}return-1},cc.Codec.GZip.prototype.DeflateLoop=function(){var a,b,c,d,e;do if(a=this.readBit(),c=this.readBits(2),0===c){var f,g;for(this.byteAlign(),f=this.readByte(),f|=this.readByte()<<8,g=this.readByte(),g|=this.readByte()<<8,65535&(f^~g)&&document.write("BlockLen checksum mismatch\n");f--;)b=this.readByte(),this.addBuffer(b)}else if(1===c)for(var h;;)if(h=cc.Codec.GZip.bitReverse[this.readBits(7)]>>1,h>23?(h=h<<1|this.readBit(),h>199?(h-=128,h=h<<1|this.readBit()):(h-=48,h>143&&(h+=136))):h+=256,256>h)this.addBuffer(h);else{if(256===h)break;var e,i;for(h-=257,e=this.readBits(cc.Codec.GZip.cplext[h])+cc.Codec.GZip.cplens[h],h=cc.Codec.GZip.bitReverse[this.readBits(5)]>>3,cc.Codec.GZip.cpdext[h]>8?(i=this.readBits(8),i|=this.readBits(cc.Codec.GZip.cpdext[h]-8)<<8):i=this.readBits(cc.Codec.GZip.cpdext[h]),i+=cc.Codec.GZip.cpdist[h],h=0;e>h;h++){var b=this.buf32k[this.bIdx-i&32767];this.addBuffer(b)}}else if(2===c){var h,j,k,l,m,n=new Array(320);for(k=257+this.readBits(5),l=1+this.readBits(5),m=4+this.readBits(4),h=0;19>h;h++)n[h]=0;for(h=0;m>h;h++)n[cc.Codec.GZip.border[h]]=this.readBits(3);for(e=this.distanceTree.length,d=0;e>d;d++)this.distanceTree[d]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.distanceTree,19,n,0))return this.flushBuffer(),1;j=k+l,d=0;for(var o=-1;j>d;)if(o++,h=this.DecodeValue(this.distanceTree),16>h)n[d++]=h;else if(16===h){var p;if(h=3+this.readBits(2),d+h>j)return this.flushBuffer(),1;for(p=d?n[d-1]:0;h--;)n[d++]=p}else{if(h=17===h?3+this.readBits(3):11+this.readBits(7),d+h>j)return this.flushBuffer(),1;for(;h--;)n[d++]=0}for(e=this.literalTree.length,d=0;e>d;d++)this.literalTree[d]=new cc.Codec.GZip.HufNode;if(this.CreateTree(this.literalTree,k,n,0))return this.flushBuffer(),1;for(e=this.literalTree.length,d=0;e>d;d++)this.distanceTree[d]=new cc.Codec.GZip.HufNode;var q=new Array;for(d=k;d=256){var e,i;if(h-=256,0===h)break;for(h--,e=this.readBits(cc.Codec.GZip.cplext[h])+cc.Codec.GZip.cplens[h],h=this.DecodeValue(this.distanceTree),cc.Codec.GZip.cpdext[h]>8?(i=this.readBits(8),i|=this.readBits(cc.Codec.GZip.cpdext[h]-8)<<8):i=this.readBits(cc.Codec.GZip.cpdext[h]),i+=cc.Codec.GZip.cpdist[h];e--;){var b=this.buf32k[this.bIdx-i&32767];this.addBuffer(b)}}else this.addBuffer(h)}while(!a);return this.flushBuffer(),this.byteAlign(),0},cc.Codec.GZip.prototype.unzipFile=function(a){var b;for(this.gunzip(),b=0;bh;)g=this.readByte(),h++;8===b&&(this.DeflateLoop(),this.unzipped[this.files]=[this.outputArr.join(""),this.nameBuf.join("")],this.files++),this.skipdir()}},cc.Codec.GZip.prototype.skipdir=function(){var a,b,c,d,e,f=[];if(8&this.gpflags&&(f[0]=this.readByte(),f[1]=this.readByte(),f[2]=this.readByte(),f[3]=this.readByte(),a=this.readByte(),a|=this.readByte()<<8,a|=this.readByte()<<16,a|=this.readByte()<<24,b=this.readByte(),b|=this.readByte()<<8,b|=this.readByte()<<16,b|=this.readByte()<<24),this.modeZIP&&this.nextFile(),f[0]=this.readByte(),8!==f[0])return 0;if(this.gpflags=this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),this.readByte(),c=this.readByte(),4&this.gpflags)for(f[0]=this.readByte(),f[2]=this.readByte(),this.len=f[0]+256*f[1],d=0;db;b++)d[b]=(255&d[b].charCodeAt(0))>>>0;a=d}for(var e,f=1,g=0,h=a.length,i=0;h>0;){e=h>1024?1024:h,h-=e;do f+=a[i++],g+=f;while(--e);f%=65521,g%=65521}return(g<<16|f)>>>0}function d(b,c){this.index="number"==typeof c?c:0,this.i=0,this.buffer=b instanceof(v?Uint8Array:Array)?b:new(v?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&a(Error("invalid index")),this.buffer.length<=this.index&&this.f()}function e(a){this.buffer=new(v?Uint16Array:Array)(2*a),this.length=0}function f(a){var b,c,d,e,f,g,h,i,j,k=a.length,l=0,m=Number.POSITIVE_INFINITY;for(i=0;k>i;++i)a[i]>l&&(l=a[i]),a[i]=d;){for(i=0;k>i;++i)if(a[i]===d){for(g=0,h=e,j=0;d>j;++j)g=g<<1|1&h,h>>=1;for(j=g;b>j;j+=f)c[j]=d<<16|i;++e}++d,e<<=1,f<<=1}return[c,l,m]}function g(a,b){this.h=E,this.w=0,this.input=a,this.b=0,b&&(b.lazy&&(this.w=b.lazy),"number"==typeof b.compressionType&&(this.h=b.compressionType),b.outputBuffer&&(this.a=v&&b.outputBuffer instanceof Array?new Uint8Array(b.outputBuffer):b.outputBuffer),"number"==typeof b.outputIndex&&(this.b=b.outputIndex)),this.a||(this.a=new(v?Uint8Array:Array)(32768))}function h(a,b){this.length=a,this.G=b}function i(){var b=H;switch(t){case 3===b:return[257,b-3,0];case 4===b:return[258,b-4,0];case 5===b:return[259,b-5,0];case 6===b:return[260,b-6,0];case 7===b:return[261,b-7,0];case 8===b:return[262,b-8,0];case 9===b:return[263,b-9,0];case 10===b:return[264,b-10,0];case 12>=b:return[265,b-11,1];case 14>=b:return[266,b-13,1];case 16>=b:return[267,b-15,1];case 18>=b:return[268,b-17,1];case 22>=b:return[269,b-19,2];case 26>=b:return[270,b-23,2];case 30>=b:return[271,b-27,2];case 34>=b:return[272,b-31,2];case 42>=b:return[273,b-35,3];case 50>=b:return[274,b-43,3];case 58>=b:return[275,b-51,3];case 66>=b:return[276,b-59,3];case 82>=b:return[277,b-67,4];case 98>=b:return[278,b-83,4];case 114>=b:return[279,b-99,4];case 130>=b:return[280,b-115,4];case 162>=b:return[281,b-131,5];case 194>=b:return[282,b-163,5];case 226>=b:return[283,b-195,5];case 257>=b:return[284,b-227,5];case 258===b:return[285,b-258,0];default:a("invalid length: "+b)}}function j(b,c){function d(b,c){var d,e=b.G,f=[],g=0;d=K[b.length],f[g++]=65535&d,f[g++]=d>>16&255,f[g++]=d>>24;var h;switch(t){case 1===e:h=[0,e-1,0];break;case 2===e:h=[1,e-2,0];break;case 3===e:h=[2,e-3,0];break;case 4===e:h=[3,e-4,0];break;case 6>=e:h=[4,e-5,1];break;case 8>=e:h=[5,e-7,1];break;case 12>=e:h=[6,e-9,2];break;case 16>=e:h=[7,e-13,2];break;case 24>=e:h=[8,e-17,3];break;case 32>=e:h=[9,e-25,3];break;case 48>=e:h=[10,e-33,4];break;case 64>=e:h=[11,e-49,4];break;case 96>=e:h=[12,e-65,5];break;case 128>=e:h=[13,e-97,5];break;case 192>=e:h=[14,e-129,6];break;case 256>=e:h=[15,e-193,6];break;case 384>=e:h=[16,e-257,7];break;case 512>=e:h=[17,e-385,7];break;case 768>=e:h=[18,e-513,8];break;case 1024>=e:h=[19,e-769,8];break;case 1536>=e:h=[20,e-1025,9];break;case 2048>=e:h=[21,e-1537,9];break;case 3072>=e:h=[22,e-2049,10];break;case 4096>=e:h=[23,e-3073,10];break;case 6144>=e:h=[24,e-4097,11];break;case 8192>=e:h=[25,e-6145,11];break;case 12288>=e:h=[26,e-8193,12];break;case 16384>=e:h=[27,e-12289,12];break;case 24576>=e:h=[28,e-16385,13];break;case 32768>=e:h=[29,e-24577,13];break;default:a("invalid distance")}d=h,f[g++]=d[0],f[g++]=d[1],f[g++]=d[2];var i,j;for(i=0,j=f.length;j>i;++i)p[q++]=f[i];u[f[0]]++,w[f[3]]++,r=b.length+c-1,m=null}var e,f,g,i,j,k,l,m,n,o={},p=v?new Uint16Array(2*c.length):[],q=0,r=0,u=new(v?Uint32Array:Array)(286),w=new(v?Uint32Array:Array)(30),x=b.w;if(!v){for(g=0;285>=g;)u[g++]=0;for(g=0;29>=g;)w[g++]=0}for(u[256]=1,e=0,f=c.length;f>e;++e){for(g=j=0,i=3;i>g&&e+g!==f;++g)j=j<<8|c[e+g];if(o[j]===s&&(o[j]=[]),k=o[j],!(0=f){for(m&&d(m,-1),g=0,i=f-e;i>g;++g)n=c[e+g],p[q++]=n,++u[n];break}if(0C;C++){if(y=k[E-C-1],B=3,A>3){for(D=A;D>3;D--)if(c[y+D-1]!==c[e+D-1])continue a;B=A}for(;258>B&&F>e+B&&c[y+B]===c[e+B];)++B;if(B>A&&(z=y,A=B),258===B)break}l=new h(A,e-z),m?m.lengthh;h++)l[h]=0;for(h=0;j>h;++h)0h;++h)d[h]=k.pop(),f[h]=d[h].value;var m,n,o,p,q,r=f.length,s=new(v?Uint16Array:Array)(b),t=new(v?Uint8Array:Array)(b),u=new(v?Uint8Array:Array)(r),w=Array(b),x=Array(b),y=Array(b),z=(1<n;++n)A>z?t[n]=0:(t[n]=1,z-=A),z<<=1,s[b-2-n]=(s[b-1-n]/2|0)+r;for(s[0]=t[0],w[0]=Array(s[0]),x[0]=Array(s[0]),n=1;b>n;++n)s[n]>2*s[n-1]+t[n]&&(s[n]=2*s[n-1]+t[n]),w[n]=Array(s[n]),x[n]=Array(s[n]);for(m=0;r>m;++m)u[m]=b;for(o=0;om;++m)y[m]=0;for(1===t[b-1]&&(--u[0],++y[b-1]),n=b-2;n>=0;--n){for(p=m=0,q=y[n+1],o=0;of[m]?(w[n][o]=p,x[n][o]=r,q+=2):(w[n][o]=f[m],x[n][o]=m,++m);y[n]=0,1===t[n]&&c(n)}for(g=u,h=0,i=d.length;i>h;++h)l[d[h].index]=g[h];return l}function l(b){var c,d,e,f,g=new(v?Uint16Array:Array)(b.length),h=[],i=[],j=0;for(c=0,d=b.length;d>c;c++)h[b[c]]=(0|h[b[c]])+1;for(c=1,d=16;d>=c;c++)i[c]=j,j+=0|h[c],j>1<j&&a("undercommitted"),c=0,d=b.length;d>c;c++)for(j=i[b[c]],i[b[c]]+=1,e=g[c]=0,f=b[c];f>e;e++)g[c]=g[c]<<1|1&j,j>>>=1;return g}function m(a,b){this.input=a,this.a=new(v?Uint8Array:Array)(32768),this.h=L.j;var c,d={};!b&&(b={})||"number"!=typeof b.compressionType||(this.h=b.compressionType);for(c in b)d[c]=b[c];d.outputBuffer=this.a,this.z=new g(this.input,d)}function n(b,c){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=v?new Uint8Array(b):b,this.s=!1,this.m=N,this.B=!1,(c||!(c={}))&&(c.index&&(this.c=c.index),c.bufferSize&&(this.l=c.bufferSize),c.bufferType&&(this.m=c.bufferType),c.resize&&(this.B=c.resize)),this.m){case M:this.b=32768,this.a=new(v?Uint8Array:Array)(32768+this.l+258);break;case N:this.b=0,this.a=new(v?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:a(Error("invalid inflate mode"))}}function o(b,c){for(var d,e=b.g,f=b.e,g=b.input,h=b.c;c>f;)d=g[h++],d===s&&a(Error("input buffer is broken")),e|=d<>>c,b.e=f-c,b.c=h,d}function p(b,c){for(var d,e,f,g=b.g,h=b.e,i=b.input,j=b.c,k=c[0],l=c[1];l>h;)d=i[j++],d===s&&a(Error("input buffer is broken")),g|=d<>>16,b.g=g>>f,b.e=h-f,b.c=j,65535&e}function q(a){function b(a,b,c){var d,e,f,g;for(g=0;a>g;)switch(d=p(this,b)){case 16:for(f=3+o(this,2);f--;)c[g++]=e;break;case 17:for(f=3+o(this,3);f--;)c[g++]=0;e=0;break;case 18:for(f=11+o(this,7);f--;)c[g++]=0;e=0;break;default:e=c[g++]=d}return c}var c,d,e,g,h=o(a,5)+257,i=o(a,5)+1,j=o(a,4)+4,k=new(v?Uint8Array:Array)(S.length);for(g=0;j>g;++g)k[S[g]]=o(a,3);c=f(k),d=new(v?Uint8Array:Array)(h),e=new(v?Uint8Array:Array)(i),a.o(f(b.call(a,h,c,d)),f(b.call(a,i,c,e)))}function r(b,c){var d,e;switch(this.input=b,this.c=0,(c||!(c={}))&&(c.index&&(this.c=c.index),c.verify&&(this.M=c.verify)),d=b[this.c++],e=b[this.c++],15&d){case qa:this.method=qa;break;default:a(Error("unsupported compression method"))}0!==((d<<8)+e)%31&&a(Error("invalid fcheck flag:"+((d<<8)+e)%31)),32&e&&a(Error("fdict flag is not supported")),this.A=new n(b,{index:this.c,bufferSize:c.bufferSize,bufferType:c.bufferType,resize:c.resize})}var s=void 0,t=!0,u=this,v="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array;d.prototype.f=function(){var a,b=this.buffer,c=b.length,d=new(v?Uint8Array:Array)(c<<1);if(v)d.set(b);else for(a=0;c>a;++a)d[a]=b[a];return this.buffer=d},d.prototype.d=function(a,b,c){var d,e=this.buffer,f=this.index,g=this.i,h=e[f];if(c&&b>1&&(a=b>8?(B[255&a]<<24|B[a>>>8&255]<<16|B[a>>>16&255]<<8|B[a>>>24&255])>>32-b:B[a]>>8-b),8>b+g)h=h<d;++d)h=h<<1|a>>b-d-1&1,8===++g&&(g=0,e[f++]=B[h],h=0,f===e.length&&(e=this.f()));e[f]=h,this.buffer=e,this.i=g,this.index=f},d.prototype.finish=function(){var a,b=this.buffer,c=this.index;return 0w;++w){for(var y=w,z=y,A=7,y=y>>>1;y;y>>>=1)z<<=1,z|=1&y,--A;x[w]=(z<>>0}var B=x,C=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];v&&new Uint32Array(C),e.prototype.getParent=function(a){return 2*((a-2)/4|0)},e.prototype.push=function(a,b){var c,d,e,f=this.buffer;for(c=this.length,f[this.length++]=b,f[this.length++]=a;c>0&&(d=this.getParent(c),f[c]>f[d]);)e=f[c],f[c]=f[d],f[d]=e,e=f[c+1],f[c+1]=f[d+1],f[d+1]=e,c=d;return this.length},e.prototype.pop=function(){var a,b,c,d,e,f=this.buffer;for(b=f[0],a=f[1],this.length-=2,f[0]=f[this.length],f[1]=f[this.length+1],e=0;(d=2*e+2,!(d>=this.length))&&(d+2f[d]&&(d+=2),f[d]>f[e]);)c=f[e],f[e]=f[d],f[d]=c,c=f[e+1],f[e+1]=f[d+1],f[d+1]=c,e=d;return{index:a,value:b,length:this.length}};var D,E=2,F={NONE:0,r:1,j:E,N:3},G=[];for(D=0;288>D;D++)switch(t){case 143>=D:G.push([D+48,8]);break;case 255>=D:G.push([D-144+400,9]);break;case 279>=D:G.push([D-256+0,7]);break;case 287>=D:G.push([D-280+192,8]);break;default:a("invalid literal: "+D)}g.prototype.n=function(){var b,c,e,f,g=this.input;switch(this.h){case 0:for(e=0,f=g.length;f>e;){c=v?g.subarray(e,e+65535):g.slice(e,e+65535),e+=c.length;var h=c,i=e===f,m=s,n=s,o=s,p=s,q=s,r=this.a,u=this.b;if(v){for(r=new Uint8Array(this.a.buffer);r.length<=u+h.length+5;)r=new Uint8Array(r.length<<1);r.set(this.a)}if(m=i?1:0,r[u++]=0|m,n=h.length,o=~n+65536&65535,r[u++]=255&n,r[u++]=n>>>8&255,r[u++]=255&o,r[u++]=o>>>8&255,v)r.set(h,u),u+=h.length,r=r.subarray(0,u);else{for(p=0,q=h.length;q>p;++p)r[u++]=h[p];r.length=u}this.b=u,this.a=r}break;case 1:var w=new d(new Uint8Array(this.a.buffer),this.b);w.d(1,1,t),w.d(1,2,t);var x,y,z,A=j(this,g);for(x=0,y=A.length;y>x;x++)if(z=A[x],d.prototype.d.apply(w,G[z]),z>256)w.d(A[++x],A[++x],t),w.d(A[++x],5),w.d(A[++x],A[++x],t);else if(256===z)break;this.a=w.finish(),this.b=this.a.length;break;case E:var B,C,D,F,H,I,J,K,L,M,N,O,P,Q,R,S=new d(new Uint8Array(this.a),this.b),T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],U=Array(19);for(B=E,S.d(1,1,t),S.d(B,2,t),C=j(this,g),I=k(this.L,15),J=l(I),K=k(this.K,7),L=l(K),D=286;D>257&&0===I[D-1];D--);for(F=30;F>1&&0===K[F-1];F--);var V,W,X,Y,Z,$,_=D,aa=F,ba=new(v?Uint32Array:Array)(_+aa),ca=new(v?Uint32Array:Array)(316),da=new(v?Uint8Array:Array)(19);for(V=W=0;_>V;V++)ba[W++]=I[V];for(V=0;aa>V;V++)ba[W++]=K[V];if(!v)for(V=0,Y=da.length;Y>V;++V)da[V]=0;for(V=Z=0,Y=ba.length;Y>V;V+=W){for(W=1;Y>V+W&&ba[V+W]===ba[V];++W);if(X=W,0===ba[V])if(3>X)for(;00;)$=138>X?X:138,$>X-3&&X>$&&($=X-3),10>=$?(ca[Z++]=17,ca[Z++]=$-3,da[17]++):(ca[Z++]=18,ca[Z++]=$-11,da[18]++),X-=$;else if(ca[Z++]=ba[V],da[ba[V]]++,X--,3>X)for(;00;)$=6>X?X:6,$>X-3&&X>$&&($=X-3),ca[Z++]=16,ca[Z++]=$-3,da[16]++,X-=$}for(b=v?ca.subarray(0,Z):ca.slice(0,Z),M=k(da,7),Q=0;19>Q;Q++)U[Q]=M[T[Q]];for(H=19;H>4&&0===U[H-1];H--);for(N=l(M),S.d(D-257,5,t),S.d(F-1,5,t),S.d(H-4,4,t),Q=0;H>Q;Q++)S.d(U[Q],3,t);for(Q=0,R=b.length;R>Q;Q++)if(O=b[Q],S.d(N[O],M[O],t),O>=16){switch(Q++,O){case 16:P=2;break;case 17:P=3;break;case 18:P=7;break;default:a("invalid code: "+O)}S.d(b[Q],P,t)}var ea,fa,ga,ha,ia,ja,ka,la,ma=[J,I],na=[L,K];for(ia=ma[0],ja=ma[1],ka=na[0],la=na[1],ea=0,fa=C.length;fa>ea;++ea)if(ga=C[ea],S.d(ia[ga],ja[ga],t),ga>256)S.d(C[++ea],C[++ea],t),ha=C[++ea],S.d(ka[ha],la[ha],t),S.d(C[++ea],C[++ea],t);else if(256===ga)break;this.a=S.finish(),this.b=this.a.length;break;default:a("invalid compression type")}return this.a};var H,I,J=[];for(H=3;258>=H;H++)I=i(),J[H]=I[2]<<24|I[1]<<16|I[0];var K=v?new Uint32Array(J):J,L=F;m.prototype.n=function(){var b,d,e,f,g,h,i,j=0;switch(i=this.a,b=qa){case qa:d=Math.LOG2E*Math.log(32768)-8;break;default:a(Error("invalid compression method"))}switch(e=d<<4|b,i[j++]=e,b){case qa:switch(this.h){case L.NONE:g=0;break;case L.r:g=1;break;case L.j:g=2;break;default:a(Error("unsupported compression type"))}break;default:a(Error("invalid compression method"))}return f=g<<6|0,i[j++]=f|31-(256*e+f)%31,h=c(this.input),this.z.b=j,i=this.z.n(),j=i.length,v&&(i=new Uint8Array(i.buffer),i.length<=j+4&&(this.a=new Uint8Array(i.length+4),this.a.set(i),i=this.a),i=i.subarray(0,j+4)),i[j++]=h>>24&255,i[j++]=h>>16&255,i[j++]=h>>8&255,i[j++]=255&h,i},b("Zlib.Deflate",m),b("Zlib.Deflate.compress",function(a,b){return new m(a,b).n()}),b("Zlib.Deflate.CompressionType",L),b("Zlib.Deflate.CompressionType.NONE",L.NONE),b("Zlib.Deflate.CompressionType.FIXED",L.r),b("Zlib.Deflate.CompressionType.DYNAMIC",L.j);var M=0,N=1,O={D:M,C:N};n.prototype.p=function(){for(;!this.s;){var b=o(this,3);switch(1&b&&(this.s=t),b>>>=1){case 0:var c=this.input,d=this.c,e=this.a,f=this.b,g=s,h=s,i=s,j=e.length,k=s;switch(this.e=this.g=0,g=c[d++],g===s&&a(Error("invalid uncompressed block header: LEN (first byte)")),h=g,g=c[d++],g===s&&a(Error("invalid uncompressed block header: LEN (second byte)")),h|=g<<8,g=c[d++],g===s&&a(Error("invalid uncompressed block header: NLEN (first byte)")),i=g,g=c[d++],g===s&&a(Error("invalid uncompressed block header: NLEN (second byte)")),i|=g<<8,h===~i&&a(Error("invalid uncompressed block header: length verify")),d+h>c.length&&a(Error("input buffer is broken")),this.m){case M:for(;f+h>e.length;){if(k=j-f,h-=k,v)e.set(c.subarray(d,d+k),f),f+=k,d+=k;else for(;k--;)e[f++]=c[d++];this.b=f,e=this.f(),f=this.b}break;case N:for(;f+h>e.length;)e=this.f({v:2});break;default:a(Error("invalid inflate mode"))}if(v)e.set(c.subarray(d,d+h),f),f+=h,d+=h;else for(;h--;)e[f++]=c[d++];this.c=d,this.b=f,this.a=e;break;case 1:this.o(ca,ea);break;case 2:q(this);break;default:a(Error("unknown BTYPE: "+b))}}return this.t()};var P,Q,R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S=v?new Uint16Array(R):R,T=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],U=v?new Uint16Array(T):T,V=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],W=v?new Uint8Array(V):V,X=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Y=v?new Uint16Array(X):X,Z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],$=v?new Uint8Array(Z):Z,_=new(v?Uint8Array:Array)(288);for(P=0,Q=_.length;Q>P;++P)_[P]=143>=P?8:255>=P?9:279>=P?7:8;var aa,ba,ca=f(_),da=new(v?Uint8Array:Array)(30);for(aa=0,ba=da.length;ba>aa;++aa)da[aa]=5;var ea=f(da);n.prototype.o=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e,f,g,h,i=c.length-258;256!==(e=p(this,a));)if(256>e)d>=i&&(this.b=d,c=this.f(),d=this.b),c[d++]=e;else for(f=e-257,h=U[f],0=i&&(this.b=d,c=this.f(),d=this.b);h--;)c[d]=c[d++-g];for(;8<=this.e;)this.e-=8,this.c--;this.b=d},n.prototype.I=function(a,b){var c=this.a,d=this.b;this.u=a;for(var e,f,g,h,i=c.length;256!==(e=p(this,a));)if(256>e)d>=i&&(c=this.f(),i=c.length),c[d++]=e;else for(f=e-257,h=U[f],0i&&(c=this.f(),i=c.length);h--;)c[d]=c[d++-g];for(;8<=this.e;)this.e-=8,this.c--;this.b=d},n.prototype.f=function(){var a,b,c=new(v?Uint8Array:Array)(this.b-32768),d=this.b-32768,e=this.a;if(v)c.set(e.subarray(32768,c.length));else for(a=0,b=c.length;b>a;++a)c[a]=e[a+32768];if(this.k.push(c),this.q+=c.length,v)e.set(e.subarray(d,d+32768));else for(a=0;32768>a;++a)e[a]=e[d+a];return this.b=32768,e},n.prototype.J=function(a){var b,c,d,e,f=this.input.length/this.c+1|0,g=this.input,h=this.a;return a&&("number"==typeof a.v&&(f=a.v),"number"==typeof a.F&&(f+=a.F)),2>f?(c=(g.length-this.c)/this.u[2],e=258*(c/2)|0,d=eb;++b)for(a=h[b],d=0,e=a.length;e>d;++d)i[f++]=a[d];for(b=32768,c=this.b;c>b;++b)i[f++]=g[b];return this.k=[],this.buffer=i},n.prototype.H=function(){var a,b=this.b;return v?this.B?(a=new Uint8Array(b),a.set(this.a.subarray(0,b))):a=this.a.subarray(0,b):(this.a.length>b&&(this.a.length=b),a=this.a),this.buffer=a},r.prototype.p=function(){var b,d,e=this.input;return b=this.A.p(),this.c=this.A.c,this.M&&(d=(e[this.c++]<<24|e[this.c++]<<16|e[this.c++]<<8|e[this.c++])>>>0,d!==c(b)&&a(Error("invalid adler-32 checksum"))),b},b("Zlib.Inflate",r),b("Zlib.Inflate.BufferType",O),O.ADAPTIVE=O.C,O.BLOCK=O.D,b("Zlib.Inflate.prototype.decompress",r.prototype.p);var fa=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];v&&new Uint16Array(fa);var ga=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258];v&&new Uint16Array(ga);var ha=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0];v&&new Uint8Array(ha);var ia=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577];v&&new Uint16Array(ia);var ja=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];v&&new Uint8Array(ja);var ka,la,ma=new(v?Uint8Array:Array)(288);for(ka=0,la=ma.length;la>ka;++ka)ma[ka]=143>=ka?8:255>=ka?9:279>=ka?7:8;f(ma);var na,oa,pa=new(v?Uint8Array:Array)(30);for(na=0,oa=pa.length;oa>na;++na)pa[na]=5;f(pa);var qa=8}.call(this);var _p=window;_p=_p.Zlib=_p.Zlib,_p.Deflate=_p.Deflate,_p.Deflate.compress=_p.Deflate.compress,_p.Inflate=_p.Inflate,_p.Inflate.BufferType=_p.Inflate.BufferType,_p.Inflate.prototype.decompress=_p.Inflate.prototype.decompress;cc.PNGReader=cc.Class.extend({ctor:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o;for(this.data=a,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},f=null;;){switch(b=this.readUInt32(),j=function(){var a,b;for(b=[],g=a=0;4>a;g=++a)b.push(String.fromCharCode(this.data[this.pos++]));return b}.call(this).join("")){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(b);break;case"fcTL":f&&this.animation.frames.push(f),this.pos+=4,f={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},e=this.readUInt16(),d=this.readUInt16()||100,f.delay=1e3*e/d,f.disposeOp=this.data[this.pos++],f.blendOp=this.data[this.pos++],f.data=[];break;case"IDAT":case"fdAT":for("fdAT"===j&&(this.pos+=4,b-=4),a=(null!=f?f.data:void 0)||this.imgData,g=m=0;b>=0?b>m:m>b;g=b>=0?++m:--m)a.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(b),k=255-this.transparency.indexed.length,k>0)for(g=n=0;k>=0?k>n:n>k;g=k>=0?++n:--n)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(b)[0];break;case 2:this.transparency.rgb=this.read(b)}break;case"tEXt":l=this.read(b),h=l.indexOf(0),i=String.fromCharCode.apply(String,l.slice(0,h)),this.text[i]=String.fromCharCode.apply(String,l.slice(h+1));break;case"IEND":return f&&this.animation.frames.push(f),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(o=this.colorType)||6===o,c=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*c,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(Uint8Array!=Array&&(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=b}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}},read:function(a){var b,c,d;for(d=[],b=c=0;a>=0?a>c:c>a;b=a>=0?++c:--c)d.push(this.data[this.pos++]);return d},readUInt32:function(){var a,b,c,d;return a=this.data[this.pos++]<<24,b=this.data[this.pos++]<<16,c=this.data[this.pos++]<<8,d=this.data[this.pos++],a|b|c|d},readUInt16:function(){var a,b;return a=this.data[this.pos++]<<8,b=this.data[this.pos++],a|b},decodePixels:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;if(null==a&&(a=this.imgData),0===a.length)return new Uint8Array(0);var y=new Zlib.Inflate(a,{index:0,verify:!1});for(a=y.decompress(),m=this.pixelBitlength/8,q=m*this.width,n=new Uint8Array(q*this.height),g=a.length,p=0,o=0,c=0;g>o;){switch(a[o++]){case 0:for(e=t=0;q>t;e=t+=1)n[c++]=a[o++];break;case 1:for(e=u=0;q>u;e=u+=1)b=a[o++],f=m>e?0:n[c-m],n[c++]=(b+f)%256;break;case 2:for(e=v=0;q>v;e=v+=1)b=a[o++],d=(e-e%m)/m,r=p&&n[(p-1)*q+d*m+e%m],n[c++]=(r+b)%256;break;case 3:for(e=w=0;q>w;e=w+=1)b=a[o++],d=(e-e%m)/m,f=m>e?0:n[c-m],r=p&&n[(p-1)*q+d*m+e%m],n[c++]=(b+Math.floor((f+r)/2))%256;break;case 4:for(e=x=0;q>x;e=x+=1)b=a[o++],d=(e-e%m)/m,f=m>e?0:n[c-m],0===p?r=s=0:(r=n[(p-1)*q+d*m+e%m],s=d&&n[(p-1)*q+(d-1)*m+e%m]),h=f+r-s,i=Math.abs(h-f),k=Math.abs(h-r),l=Math.abs(h-s),j=k>=i&&l>=i?f:l>=k?r:s,n[c++]=(b+j)%256;break;default:throw new Error("Invalid filter algorithm: "+a[o-1])}p++}return n},copyToImageData:function(a,b){var c,d,e,f,g,h,i,j,k,l,m;if(d=this.colors,k=null,c=this.hasAlphaChannel,this.palette.length&&(k=null!=(m=this._decodedPalette)?m:this._decodedPalette=this.decodePalette(),d=4,c=!0),e=a.data||a,j=e.length,g=k||b,f=h=0,1===d)for(;j>f;)i=k?4*b[f/4]:h,l=g[i++],e[f++]=l,e[f++]=l,e[f++]=l,e[f++]=c?g[i++]:255,h=i;else for(;j>f;)i=k?4*b[f/4]:h,e[f++]=g[i++],e[f++]=g[i++],e[f++]=g[i++],e[f++]=c?g[i++]:255,h=i},decodePalette:function(){var a,b,c,d,e,f,g,h,i;for(c=this.palette,f=this.transparency.indexed||[],e=new Uint8Array((f.length||0)+c.length),d=0,a=0,b=g=0,h=c.length;h>g;b=g+=3)e[d++]=c[b],e[d++]=c[b+1],e[d++]=c[b+2],e[d++]=null!=(i=f[a++])?i:255;return e},render:function(a){var b,c;return a.width=this.width,a.height=this.height,b=a.getContext("2d"),c=b.createImageData(this.width,this.height),this.copyToImageData(c,this.decodePixels()),b.putImageData(c,0,0)}}),cc.tiffReader={_littleEndian:!1,_tiffData:null,_fileDirectories:[],getUint8:function(a){return this._tiffData[a]},getUint16:function(a){return this._littleEndian?this._tiffData[a+1]<<8|this._tiffData[a]:this._tiffData[a]<<8|this._tiffData[a+1]},getUint32:function(a){var b=this._tiffData;return this._littleEndian?b[a+3]<<24|b[a+2]<<16|b[a+1]<<8|b[a]:b[a]<<24|b[a+1]<<16|b[a+2]<<8|b[a+3]},checkLittleEndian:function(){var a=this.getUint16(0);if(18761===a)this.littleEndian=!0;else{if(19789!==a)throw console.log(a),TypeError("Invalid byte order value.");this.littleEndian=!1}return this.littleEndian},hasTowel:function(){if(42!==this.getUint16(2))throw RangeError("You forgot your towel!");return!0},getFieldTypeName:function(a){var b=this.fieldTypeNames;return a in b?b[a]:null},getFieldTagName:function(a){var b=this.fieldTagNames;return a in b?b[a]:(console.log("Unknown Field Tag:",a),"Tag"+a)},getFieldTypeLength:function(a){return-1!==["BYTE","ASCII","SBYTE","UNDEFINED"].indexOf(a)?1:-1!==["SHORT","SSHORT"].indexOf(a)?2:-1!==["LONG","SLONG","FLOAT"].indexOf(a)?4:-1!==["RATIONAL","SRATIONAL","DOUBLE"].indexOf(a)?8:null},getFieldValues:function(a,b,c,d){var e=[],f=this.getFieldTypeLength(b),g=f*c;if(4>=g)this.littleEndian===!1?e.push(d>>>8*(4-f)):e.push(d);else for(var h=0;c>h;h++){var i=f*h;f>=8?-1!==["RATIONAL","SRATIONAL"].indexOf(b)?(e.push(this.getUint32(d+i)),e.push(this.getUint32(d+i+4))):cc.log("Can't handle this field type or size"):e.push(this.getBytes(f,d+i))}return"ASCII"===b&&e.forEach(function(a,b,c){c[b]=String.fromCharCode(a)}),e},getBytes:function(a,b){if(0>=a)cc.log("No bytes requested");else{if(1>=a)return this.getUint8(b);if(2>=a)return this.getUint16(b);if(3>=a)return this.getUint32(b)>>>8;if(4>=a)return this.getUint32(b);cc.log("Too many bytes requested")}},getBits:function(a,b,c){c=c||0;var d,e,f=Math.floor(c/8),g=b+f,h=c+a,i=32-a;return 0>=h?console.log("No bits requested"):8>=h?(d=24+c,e=this.getUint8(g)):16>=h?(d=16+c,e=this.getUint16(g)):32>=h?(d=c,e=this.getUint32(g)):console.log("Too many bits requested"),{bits:e<>>i,byteOffset:g+Math.floor(h/8),bitOffset:h%8}},parseFileDirectory:function(a){for(var b=this.getUint16(a),c=[],d=a+2,e=0;b>e;d+=12,e++){var f=this.getUint16(d),g=this.getUint16(d+2),h=this.getUint32(d+4),i=this.getUint32(d+8),j=this.getFieldTagName(f),k=this.getFieldTypeName(g),l=this.getFieldValues(j,k,h,i);c[j]={type:k,values:l}}this._fileDirectories.push(c);var m=this.getUint32(d);0!==m&&this.parseFileDirectory(m)},clampColorSample:function(a,b){var c=Math.pow(2,8-b);return Math.floor(a*c+(c-1))},parseTIFF:function(a,b){if(b=b||document.createElement("canvas"),this._tiffData=a,this.canvas=b,this.checkLittleEndian(),this.hasTowel()){var c=this.getUint32(4);this._fileDirectories.length=0,this.parseFileDirectory(c);var d=this._fileDirectories[0],e=d.ImageWidth.values[0],f=d.ImageLength.values[0];this.canvas.width=e,this.canvas.height=f;var g=[],h=d.Compression?d.Compression.values[0]:1,i=d.SamplesPerPixel.values[0],j=[],k=0,l=!1;if(d.BitsPerSample.values.forEach(function(a,b,c){j[b]={bitsPerSample:a,hasBytesPerSample:!1,bytesPerSample:void 0},a%8===0&&(j[b].hasBytesPerSample=!0,j[b].bytesPerSample=a/8),k+=a},this),k%8===0){l=!0;var m=k/8}var n=d.StripOffsets.values,o=n.length;if(d.StripByteCounts)var p=d.StripByteCounts.values;else{if(cc.log("Missing StripByteCounts!"),1!==o)throw Error("Cannot recover from missing StripByteCounts");var p=[Math.ceil(e*f*k/8)]}for(var q=0;o>q;q++){var r=n[q];g[q]=[];for(var s=p[q],t=0,u=0,v=1,w=!0,x=[],y=0,z=0,A=0;s>t;t+=v)switch(h){case 1:for(var B=0,x=[];i>B;B++){if(!j[B].hasBytesPerSample){var C=this.getBits(j[B].bitsPerSample,r+t,u);throw x.push(C.bits),t=C.byteOffset-r,u=C.bitOffset,RangeError("Cannot handle sub-byte bits per sample")}var D=j[B].bytesPerSample*B;x.push(this.getBytes(j[B].bytesPerSample,r+t+D))}if(g[q].push(x),!l)throw v=0,RangeError("Cannot handle sub-byte bits per pixel");v=m;break;case 2:break;case 3:break;case 4:break;case 5:break;case 6:break;case 7:break;case 32773:if(w){w=!1;var E=1,F=1,G=this.getInt8(r+t);G>=0&&127>=G?E=G+1:G>=-127&&-1>=G?F=-G+1:w=!0}else{for(var H=this.getUint8(r+t),B=0;F>B;B++){if(!j[z].hasBytesPerSample)throw RangeError("Cannot handle sub-byte bits per sample");A=A<<8*y|H,y++,y===j[z].bytesPerSample&&(x.push(A),A=y=0,z++),z===i&&(g[q].push(x),x=[],z=0)}E--,0===E&&(w=!0)}v=1}}if(b.getContext){var I=this.canvas.getContext("2d");I.fillStyle="rgba(255, 255, 255, 0)";var J=d.RowsPerStrip?d.RowsPerStrip.values[0]:f,K=g.length,L=f%J,M=0===L?J:L,N=J,O=0,P=d.PhotometricInterpretation.values[0],Q=[],R=0;if(d.ExtraSamples&&(Q=d.ExtraSamples.values,R=Q.length),d.ColorMap)var S=d.ColorMap.values,T=Math.pow(2,j[0].bitsPerSample);for(var q=0;K>q;q++){q+1===K&&(N=M);for(var U=g[q].length,V=O*q,W=0,X=0;U>X;W++)for(var Y=0;e>Y;Y++,X++){var Z=g[q][X],$=0,_=0,aa=0,ba=1;if(R>0)for(var ca=0;R>ca;ca++)if(1===Q[ca]||2===Q[ca]){ba=Z[3+ca]/256;break}switch(P){case 0:if(j[0].hasBytesPerSample)var da=Math.pow(16,2*j[0].bytesPerSample);Z.forEach(function(a,b,c){c[b]=da-a});case 1:$=_=aa=this.clampColorSample(Z[0],j[0].bitsPerSample);break;case 2:$=this.clampColorSample(Z[0],j[0].bitsPerSample),_=this.clampColorSample(Z[1],j[1].bitsPerSample),aa=this.clampColorSample(Z[2],j[2].bitsPerSample);break;case 3:if(void 0===S)throw Error("Palette image missing color map");var ea=Z[0];$=this.clampColorSample(S[ea],16),_=this.clampColorSample(S[T+ea],16),aa=this.clampColorSample(S[2*T+ea],16);break;default:throw RangeError("Unknown Photometric Interpretation:",P)}I.fillStyle="rgba("+$+", "+_+", "+aa+", "+ba+")",I.fillRect(Y,V+W,1,1)}O=N}}return this.canvas}},fieldTagNames:{315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop"},fieldTypeNames:{1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE"}},cc.Particle=function(a,b,c,d,e,f,g,h,i,j,k,l){this.pos=a?a:cc.p(0,0),this.startPos=b?b:cc.p(0,0),this.color=c?c:{r:0,g:0,b:0,a:255},this.deltaColor=d?d:{r:0,g:0,b:0,a:255},this.size=e||0,this.deltaSize=f||0,this.rotation=g||0,this.deltaRotation=h||0,this.timeToLive=i||0,this.atlasIndex=j||0,this.modeA=k?k:new cc.Particle.ModeA,this.modeB=l?l:new cc.Particle.ModeB,this.isChangeColor=!1,this.drawPos=cc.p(0,0)},cc.Particle.ModeA=function(a,b,c){this.dir=a?a:cc.p(0,0),this.radialAccel=b||0,this.tangentialAccel=c||0},cc.Particle.ModeB=function(a,b,c,d){this.angle=a||0,this.degreesPerSecond=b||0,this.radius=c||0,this.deltaRadius=d||0},cc.Particle.TemporaryPoints=[cc.p(),cc.p(),cc.p(),cc.p()],cc.ParticleSystem=cc.Node.extend({_className:"ParticleSystem",_plistFile:"",_elapsed:0,_dontTint:!1,modeA:null,modeB:null,_pointZeroForParticle:cc.p(0,0),_particles:null,_emitCounter:0,_particleIdx:0,_batchNode:null,atlasIndex:0,_transformSystemDirty:!1,_allocatedParticles:0,_isActive:!1,particleCount:0,duration:0,_sourcePosition:null,_posVar:null,life:0,lifeVar:0,angle:0,angleVar:0,startSize:0,startSizeVar:0,endSize:0,endSizeVar:0,_startColor:null,_startColorVar:null,_endColor:null,_endColorVar:null,startSpin:0,startSpinVar:0,endSpin:0,endSpinVar:0,emissionRate:0,_totalParticles:0,_texture:null,_blendFunc:null,_opacityModifyRGB:!1,positionType:null,autoRemoveOnFinish:!1,emitterMode:0,_textureLoaded:null,ctor:function(a){if(cc.Node.prototype.ctor.call(this),this.emitterMode=cc.ParticleSystem.MODE_GRAVITY,this.modeA=new cc.ParticleSystem.ModeA,this.modeB=new cc.ParticleSystem.ModeB,this._blendFunc={src:cc.BLEND_SRC,dst:cc.BLEND_DST},this._particles=[],this._sourcePosition=cc.p(0,0),this._posVar=cc.p(0,0),this._startColor=cc.color(255,255,255,255),this._startColorVar=cc.color(255,255,255,255),this._endColor=cc.color(255,255,255,255),this._endColorVar=cc.color(255,255,255,255),this._plistFile="",this._elapsed=0,this._dontTint=!1,this._pointZeroForParticle=cc.p(0,0),this._emitCounter=0,this._particleIdx=0,this._batchNode=null,this.atlasIndex=0,this._transformSystemDirty=!1,this._allocatedParticles=0,this._isActive=!1,this.particleCount=0,this.duration=0,this.life=0,this.lifeVar=0,this.angle=0,this.angleVar=0,this.startSize=0,this.startSizeVar=0,this.endSize=0,this.endSizeVar=0,this.startSpin=0,this.startSpinVar=0,this.endSpin=0,this.endSpinVar=0,this.emissionRate=0,this._totalParticles=0,this._texture=null,this._opacityModifyRGB=!1,this.positionType=cc.ParticleSystem.TYPE_FREE,this.autoRemoveOnFinish=!1,this._textureLoaded=!0,!a||cc.isNumber(a)){var b=a||100;this.setDrawMode(cc.ParticleSystem.TEXTURE_MODE),this.initWithTotalParticles(b)}else cc.isString(a)?this.initWithFile(a):cc.isObject(a)&&this.initWithDictionary(a,"")},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ParticleSystem.CanvasRenderCmd(this):new cc.ParticleSystem.WebGLRenderCmd(this)},ignoreColor:function(a){this._dontTint=a},initTexCoordsWithRect:function(a){this._renderCmd.initTexCoordsWithRect(a)},getBatchNode:function(){return this._batchNode},setBatchNode:function(a){this._renderCmd.setBatchNode(a)},getAtlasIndex:function(){return this.atlasIndex},setAtlasIndex:function(a){this.atlasIndex=a},getDrawMode:function(){return this._renderCmd.getDrawMode()},setDrawMode:function(a){this._renderCmd.setDrawMode(a)},getShapeType:function(){return this._renderCmd.getShapeType()},setShapeType:function(a){this._renderCmd.setShapeType(a)},isActive:function(){return this._isActive},getParticleCount:function(){return this.particleCount},setParticleCount:function(a){this.particleCount=a},getDuration:function(){return this.duration},setDuration:function(a){this.duration=a},getSourcePosition:function(){return{x:this._sourcePosition.x,y:this._sourcePosition.y}},setSourcePosition:function(a){this._sourcePosition=a},getPosVar:function(){return{x:this._posVar.x,y:this._posVar.y}},setPosVar:function(a){this._posVar=a},getLife:function(){return this.life},setLife:function(a){this.life=a},getLifeVar:function(){return this.lifeVar},setLifeVar:function(a){this.lifeVar=a},getAngle:function(){return this.angle},setAngle:function(a){this.angle=a},getAngleVar:function(){return this.angleVar},setAngleVar:function(a){this.angleVar=a},getGravity:function(){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getGravity() : Particle Mode should be Gravity");var a=this.modeA.gravity;return cc.p(a.x,a.y)},setGravity:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setGravity() : Particle Mode should be Gravity"),this.modeA.gravity=a},getSpeed:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getSpeed() : Particle Mode should be Gravity"),this.modeA.speed},setSpeed:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setSpeed() : Particle Mode should be Gravity"),this.modeA.speed=a},getSpeedVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getSpeedVar() : Particle Mode should be Gravity"),this.modeA.speedVar},setSpeedVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setSpeedVar() : Particle Mode should be Gravity"),this.modeA.speedVar=a},getTangentialAccel:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getTangentialAccel() : Particle Mode should be Gravity"),this.modeA.tangentialAccel},setTangentialAccel:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setTangentialAccel() : Particle Mode should be Gravity"),this.modeA.tangentialAccel=a},getTangentialAccelVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getTangentialAccelVar() : Particle Mode should be Gravity"),this.modeA.tangentialAccelVar},setTangentialAccelVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setTangentialAccelVar() : Particle Mode should be Gravity"),this.modeA.tangentialAccelVar=a},getRadialAccel:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRadialAccel() : Particle Mode should be Gravity"),this.modeA.radialAccel},setRadialAccel:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setRadialAccel() : Particle Mode should be Gravity"),this.modeA.radialAccel=a},getRadialAccelVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRadialAccelVar() : Particle Mode should be Gravity"),this.modeA.radialAccelVar},setRadialAccelVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setRadialAccelVar() : Particle Mode should be Gravity"),this.modeA.radialAccelVar=a},getRotationIsDir:function(){return this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.getRotationIsDir() : Particle Mode should be Gravity"),this.modeA.rotationIsDir},setRotationIsDir:function(a){this.emitterMode!==cc.ParticleSystem.MODE_GRAVITY&&cc.log("cc.ParticleBatchNode.setRotationIsDir() : Particle Mode should be Gravity"),this.modeA.rotationIsDir=a},getStartRadius:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getStartRadius() : Particle Mode should be Radius"),this.modeB.startRadius},setStartRadius:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setStartRadius() : Particle Mode should be Radius"),this.modeB.startRadius=a},getStartRadiusVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getStartRadiusVar() : Particle Mode should be Radius"),this.modeB.startRadiusVar},setStartRadiusVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setStartRadiusVar() : Particle Mode should be Radius"),this.modeB.startRadiusVar=a},getEndRadius:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getEndRadius() : Particle Mode should be Radius"),this.modeB.endRadius},setEndRadius:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setEndRadius() : Particle Mode should be Radius"),this.modeB.endRadius=a},getEndRadiusVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getEndRadiusVar() : Particle Mode should be Radius"),this.modeB.endRadiusVar},setEndRadiusVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setEndRadiusVar() : Particle Mode should be Radius"),this.modeB.endRadiusVar=a},getRotatePerSecond:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getRotatePerSecond() : Particle Mode should be Radius"),this.modeB.rotatePerSecond},setRotatePerSecond:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setRotatePerSecond() : Particle Mode should be Radius"),this.modeB.rotatePerSecond=a},getRotatePerSecondVar:function(){return this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.getRotatePerSecondVar() : Particle Mode should be Radius"),this.modeB.rotatePerSecondVar},setRotatePerSecondVar:function(a){this.emitterMode!==cc.ParticleSystem.MODE_RADIUS&&cc.log("cc.ParticleBatchNode.setRotatePerSecondVar() : Particle Mode should be Radius"),this.modeB.rotatePerSecondVar=a},setScale:function(a,b){this._transformSystemDirty=!0,cc.Node.prototype.setScale.call(this,a,b)},setRotation:function(a){this._transformSystemDirty=!0,cc.Node.prototype.setRotation.call(this,a)},setScaleX:function(a){this._transformSystemDirty=!0,cc.Node.prototype.setScaleX.call(this,a)},setScaleY:function(a){this._transformSystemDirty=!0,cc.Node.prototype.setScaleY.call(this,a)},getStartSize:function(){return this.startSize},setStartSize:function(a){this.startSize=a},getStartSizeVar:function(){return this.startSizeVar},setStartSizeVar:function(a){this.startSizeVar=a},getEndSize:function(){return this.endSize},setEndSize:function(a){this.endSize=a},getEndSizeVar:function(){return this.endSizeVar},setEndSizeVar:function(a){this.endSizeVar=a},getStartColor:function(){return cc.color(this._startColor.r,this._startColor.g,this._startColor.b,this._startColor.a)},setStartColor:function(a){this._startColor=cc.color(a)},getStartColorVar:function(){return cc.color(this._startColorVar.r,this._startColorVar.g,this._startColorVar.b,this._startColorVar.a)},setStartColorVar:function(a){this._startColorVar=cc.color(a)},getEndColor:function(){return cc.color(this._endColor.r,this._endColor.g,this._endColor.b,this._endColor.a)},setEndColor:function(a){this._endColor=cc.color(a)},getEndColorVar:function(){return cc.color(this._endColorVar.r,this._endColorVar.g,this._endColorVar.b,this._endColorVar.a)},setEndColorVar:function(a){this._endColorVar=cc.color(a)},getStartSpin:function(){return this.startSpin},setStartSpin:function(a){this.startSpin=a},getStartSpinVar:function(){return this.startSpinVar},setStartSpinVar:function(a){this.startSpinVar=a},getEndSpin:function(){return this.endSpin},setEndSpin:function(a){this.endSpin=a},getEndSpinVar:function(){return this.endSpinVar},setEndSpinVar:function(a){this.endSpinVar=a},getEmissionRate:function(){return this.emissionRate},setEmissionRate:function(a){this.emissionRate=a},getTotalParticles:function(){return this._totalParticles},setTotalParticles:function(a){this._renderCmd.setTotalParticles(a)},getTexture:function(){return this._texture},setTexture:function(a){a&&(a.isLoaded()?this.setTextureWithRect(a,cc.rect(0,0,a.width,a.height)):(this._textureLoaded=!1,a.addEventListener("load",function(a){this._textureLoaded=!0,this.setTextureWithRect(a,cc.rect(0,0,a.width,a.height))},this)))},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){void 0===b?this._blendFunc!==a&&(this._blendFunc=a,this._updateBlendFunc()):(this._blendFunc.src!==a||this._blendFunc.dst!==b)&&(this._blendFunc={src:a,dst:b},this._updateBlendFunc())},isOpacityModifyRGB:function(){return this._opacityModifyRGB},setOpacityModifyRGB:function(a){this._opacityModifyRGB=a},isBlendAdditive:function(){return this._blendFunc.src===cc.SRC_ALPHA&&this._blendFunc.dst===cc.ONE||this._blendFunc.src===cc.ONE&&this._blendFunc.dst===cc.ONE},setBlendAdditive:function(a){var b=this._blendFunc;a?(b.src=cc.SRC_ALPHA,b.dst=cc.ONE):this._renderCmd._setBlendAdditive()},getPositionType:function(){return this.positionType},setPositionType:function(a){this.positionType=a},isAutoRemoveOnFinish:function(){return this.autoRemoveOnFinish},setAutoRemoveOnFinish:function(a){this.autoRemoveOnFinish=a},getEmitterMode:function(){return this.emitterMode},setEmitterMode:function(a){this.emitterMode=a},init:function(){return this.initWithTotalParticles(150)},initWithFile:function(a){this._plistFile=a;var b=cc.loader.getRes(a);return b?this.initWithDictionary(b,""):(cc.log("cc.ParticleSystem.initWithFile(): Particles: file not found"),!1)},getBoundingBoxToWorld:function(){return cc.rect(0,0,cc._canvas.width,cc._canvas.height)},initWithDictionary:function(a,b){var c=!1,d=null,e=this._valueForKey,f=parseInt(e("maxParticles",a));if(this.initWithTotalParticles(f)){this.angle=parseFloat(e("angle",a)),this.angleVar=parseFloat(e("angleVariance",a)),this.duration=parseFloat(e("duration",a)),this._blendFunc.src=parseInt(e("blendFuncSource",a)),this._blendFunc.dst=parseInt(e("blendFuncDestination",a));var g=this._startColor;g.r=255*parseFloat(e("startColorRed",a)),g.g=255*parseFloat(e("startColorGreen",a)),g.b=255*parseFloat(e("startColorBlue",a)),g.a=255*parseFloat(e("startColorAlpha",a));var h=this._startColorVar;h.r=255*parseFloat(e("startColorVarianceRed",a)),h.g=255*parseFloat(e("startColorVarianceGreen",a)),h.b=255*parseFloat(e("startColorVarianceBlue",a)),h.a=255*parseFloat(e("startColorVarianceAlpha",a));var i=this._endColor;i.r=255*parseFloat(e("finishColorRed",a)),i.g=255*parseFloat(e("finishColorGreen",a)),i.b=255*parseFloat(e("finishColorBlue",a)),i.a=255*parseFloat(e("finishColorAlpha",a));var j=this._endColorVar;if(j.r=255*parseFloat(e("finishColorVarianceRed",a)),j.g=255*parseFloat(e("finishColorVarianceGreen",a)),j.b=255*parseFloat(e("finishColorVarianceBlue",a)),j.a=255*parseFloat(e("finishColorVarianceAlpha",a)),this.startSize=parseFloat(e("startParticleSize",a)),this.startSizeVar=parseFloat(e("startParticleSizeVariance",a)),this.endSize=parseFloat(e("finishParticleSize",a)),this.endSizeVar=parseFloat(e("finishParticleSizeVariance",a)),this.setPosition(parseFloat(e("sourcePositionx",a)),parseFloat(e("sourcePositiony",a))),this._posVar.x=parseFloat(e("sourcePositionVariancex",a)),this._posVar.y=parseFloat(e("sourcePositionVariancey",a)),this.startSpin=parseFloat(e("rotationStart",a)),this.startSpinVar=parseFloat(e("rotationStartVariance",a)),this.endSpin=parseFloat(e("rotationEnd",a)),this.endSpinVar=parseFloat(e("rotationEndVariance",a)),this.emitterMode=parseInt(e("emitterType",a)),this.emitterMode===cc.ParticleSystem.MODE_GRAVITY){var k=this.modeA;k.gravity.x=parseFloat(e("gravityx",a)),k.gravity.y=parseFloat(e("gravityy",a)),k.speed=parseFloat(e("speed",a)),k.speedVar=parseFloat(e("speedVariance",a));var l=e("radialAcceleration",a);k.radialAccel=l?parseFloat(l):0,l=e("radialAccelVariance",a),k.radialAccelVar=l?parseFloat(l):0,l=e("tangentialAcceleration",a),k.tangentialAccel=l?parseFloat(l):0,l=e("tangentialAccelVariance",a),k.tangentialAccelVar=l?parseFloat(l):0;var m=e("rotationIsDir",a).toLowerCase();k.rotationIsDir=null!=m&&("true"===m||"1"===m)}else{if(this.emitterMode!==cc.ParticleSystem.MODE_RADIUS)return cc.log("cc.ParticleSystem.initWithDictionary(): Invalid emitterType in config file"),!1;var n=this.modeB;n.startRadius=parseFloat(e("maxRadius",a)),n.startRadiusVar=parseFloat(e("maxRadiusVariance",a)),n.endRadius=parseFloat(e("minRadius",a)),n.endRadiusVar=0,n.rotatePerSecond=parseFloat(e("rotatePerSecond",a)),n.rotatePerSecondVar=parseFloat(e("rotatePerSecondVariance",a))}if(this.life=parseFloat(e("particleLifespan",a)),this.lifeVar=parseFloat(e("particleLifespanVariance",a)),this.emissionRate=this._totalParticles/this.life,!this._batchNode){this._opacityModifyRGB=!1;var o=e("textureFileName",a),p=cc.path.changeBasename(this._plistFile,o),q=cc.textureCache.getTextureForKey(p);if(q)this.setTexture(q);else{var r=e("textureImageData",a);if(r&&0!==r.length){if(d=cc.unzipBase64AsArray(r,1),!d)return cc.log("cc.ParticleSystem: error decoding or ungzipping textureImageData"),!1;var s=cc.getImageFormatByData(d);if(s!==cc.FMT_TIFF&&s!==cc.FMT_PNG)return cc.log("cc.ParticleSystem: unknown image format with Data"),!1;var t=document.createElement("canvas");if(s===cc.FMT_PNG){var u=new cc.PNGReader(d);u.render(t)}else{var v=cc.tiffReader;v.parseTIFF(d,t)}cc.textureCache.cacheImage(p,t);var w=cc.textureCache.getTextureForKey(p);w||cc.log("cc.ParticleSystem.initWithDictionary() : error loading the texture"),this.setTexture(w)}else{if(q=cc.textureCache.addImage(p),!q)return!1;this.setTexture(q)}}}c=!0}return c},initWithTotalParticles:function(a){this._totalParticles=a;var b,c=this._particles;for(c.length=0,b=0;a>b;b++)c[b]=new cc.Particle;if(!c)return cc.log("Particle system: not enough memory"),!1;if(this._allocatedParticles=a,this._batchNode)for(b=0;b=this._totalParticles},updateQuadWithParticle:function(a,b){this._renderCmd.updateQuadWithParticle(a,b)},postStep:function(){this._renderCmd.postStep()},update:function(a){if(this._isActive&&this.emissionRate){var b=1/this.emissionRate;for(this.particleCountb;)this.addParticle(),this._emitCounter-=b;this._elapsed+=a,-1!==this.duration&&this.duration0){if(this.emitterMode===cc.ParticleSystem.MODE_GRAVITY){var i=f,j=d,k=e;h.pos.x||h.pos.y?(cc.pIn(j,h.pos),cc.pNormalizeIn(j)):cc.pZeroIn(j),cc.pIn(k,j),cc.pMultIn(j,h.modeA.radialAccel);var l=k.x;k.x=-k.y,k.y=l,cc.pMultIn(k,h.modeA.tangentialAccel),cc.pIn(i,j),cc.pAddIn(i,k),cc.pAddIn(i,this.modeA.gravity),cc.pMultIn(i,a),cc.pAddIn(h.modeA.dir,i),cc.pIn(i,h.modeA.dir),cc.pMultIn(i,a),cc.pAddIn(h.pos,i)}else{var m=h.modeB;m.angle+=m.degreesPerSecond*a,m.radius+=m.deltaRadius*a,h.pos.x=-Math.cos(m.angle)*m.radius,h.pos.y=-Math.sin(m.angle)*m.radius}this._renderCmd._updateDeltaColor(h,a),h.size+=h.deltaSize*a,h.size=Math.max(0,h.size),h.rotation+=h.deltaRotation*a;var n=d;if(this.positionType===cc.ParticleSystem.TYPE_FREE||this.positionType===cc.ParticleSystem.TYPE_RELATIVE){var o=e;cc.pIn(o,c),cc.pSubIn(o,h.startPos),cc.pIn(n,h.pos),cc.pSubIn(n,o)}else cc.pIn(n,h.pos);this._batchNode&&(n.x+=this._position.x,n.y+=this._position.y),this._renderCmd.updateParticlePosition(h,n),++this._particleIdx}else{var p=h.atlasIndex;if(this._particleIdx!==this.particleCount-1){var q=g[this._particleIdx];g[this._particleIdx]=g[this.particleCount-1],g[this.particleCount-1]=q}if(this._batchNode&&(this._batchNode.disableParticle(this.atlasIndex+p),g[this.particleCount-1].atlasIndex=p),--this.particleCount,0===this.particleCount&&this.autoRemoveOnFinish)return this.unscheduleUpdate(),void this._parent.removeChild(this,!0)}}this._transformSystemDirty=!1}this._batchNode||this.postStep()},updateWithNoTime:function(){this.update(0)},_valueForKey:function(a,b){if(b){var c=b[a];return null!=c?c:""}return""},_updateBlendFunc:function(){if(this._batchNode)return void cc.log("Can't change blending functions when the particle is being batched");var a=this._texture;if(a&&a instanceof cc.Texture2D){this._opacityModifyRGB=!1;var b=this._blendFunc;b.src===cc.BLEND_SRC&&b.dst===cc.BLEND_DST&&(a.hasPremultipliedAlpha()?this._opacityModifyRGB=!0:(b.src=cc.SRC_ALPHA,b.dst=cc.ONE_MINUS_SRC_ALPHA))}},clone:function(){var a=new cc.ParticleSystem;if(a.initWithTotalParticles(this.getTotalParticles())){a.setAngle(this.getAngle()),a.setAngleVar(this.getAngleVar()),a.setDuration(this.getDuration());var b=this.getBlendFunc();if(a.setBlendFunc(b.src,b.dst),a.setStartColor(this.getStartColor()),a.setStartColorVar(this.getStartColorVar()),a.setEndColor(this.getEndColor()),a.setEndColorVar(this.getEndColorVar()),a.setStartSize(this.getStartSize()),a.setStartSizeVar(this.getStartSizeVar()),a.setEndSize(this.getEndSize()),a.setEndSizeVar(this.getEndSizeVar()),a.setPosition(cc.p(this.x,this.y)),a.setPosVar(cc.p(this.getPosVar().x,this.getPosVar().y)),a.setPositionType(this.getPositionType()),a.setStartSpin(this.getStartSpin()||0),a.setStartSpinVar(this.getStartSpinVar()||0),a.setEndSpin(this.getEndSpin()||0),a.setEndSpinVar(this.getEndSpinVar()||0),a.setEmitterMode(this.getEmitterMode()),this.getEmitterMode()===cc.ParticleSystem.MODE_GRAVITY){var c=this.getGravity();a.setGravity(cc.p(c.x,c.y)),a.setSpeed(this.getSpeed()),a.setSpeedVar(this.getSpeedVar()),a.setRadialAccel(this.getRadialAccel()),a.setRadialAccelVar(this.getRadialAccelVar()),a.setTangentialAccel(this.getTangentialAccel()),a.setTangentialAccelVar(this.getTangentialAccelVar())}else this.getEmitterMode()===cc.ParticleSystem.MODE_RADIUS&&(a.setStartRadius(this.getStartRadius()),a.setStartRadiusVar(this.getStartRadiusVar()),a.setEndRadius(this.getEndRadius()),a.setEndRadiusVar(this.getEndRadiusVar()),a.setRotatePerSecond(this.getRotatePerSecond()),a.setRotatePerSecondVar(this.getRotatePerSecondVar()));if(a.setLife(this.getLife()),a.setLifeVar(this.getLifeVar()),a.setEmissionRate(this.getEmissionRate()),!this.getBatchNode()){a.setOpacityModifyRGB(this.isOpacityModifyRGB());var d=this.getTexture();if(d){var e=d.getContentSize();a.setTextureWithRect(d,cc.rect(0,0,e.width,e.height))}}}return a},setDisplayFrame:function(a){if(a){var b=a.getOffsetInPixels();(0!==b.x||0!==b.y)&&cc.log("cc.ParticleSystem.setDisplayFrame(): QuadParticle only supports SpriteFrames with no offsets");var c=a.getTexture(),d=this._texture;d!==c&&this.setTexture(c)}},setTextureWithRect:function(a,b){var c=this._texture;c!==a&&(this._texture=a,this._updateBlendFunc()),this.initTexCoordsWithRect(b)},listenBackToForeground:function(a){}});var _p=cc.ParticleSystem.prototype;_p.opacityModifyRGB,cc.defineGetterSetter(_p,"opacityModifyRGB",_p.isOpacityModifyRGB,_p.setOpacityModifyRGB),_p.batchNode,cc.defineGetterSetter(_p,"batchNode",_p.getBatchNode,_p.setBatchNode),_p.drawMode,cc.defineGetterSetter(_p,"drawMode",_p.getDrawMode,_p.setDrawMode),_p.shapeType,cc.defineGetterSetter(_p,"shapeType",_p.getShapeType,_p.setShapeType),_p.active,cc.defineGetterSetter(_p,"active",_p.isActive),_p.sourcePos,cc.defineGetterSetter(_p,"sourcePos",_p.getSourcePosition,_p.setSourcePosition),_p.posVar,cc.defineGetterSetter(_p,"posVar",_p.getPosVar,_p.setPosVar),_p.gravity,cc.defineGetterSetter(_p,"gravity",_p.getGravity,_p.setGravity),_p.speed,cc.defineGetterSetter(_p,"speed",_p.getSpeed,_p.setSpeed),_p.speedVar,cc.defineGetterSetter(_p,"speedVar",_p.getSpeedVar,_p.setSpeedVar),_p.tangentialAccel,cc.defineGetterSetter(_p,"tangentialAccel",_p.getTangentialAccel,_p.setTangentialAccel),_p.tangentialAccelVar,cc.defineGetterSetter(_p,"tangentialAccelVar",_p.getTangentialAccelVar,_p.setTangentialAccelVar),_p.radialAccel,cc.defineGetterSetter(_p,"radialAccel",_p.getRadialAccel,_p.setRadialAccel),_p.radialAccelVar,cc.defineGetterSetter(_p,"radialAccelVar",_p.getRadialAccelVar,_p.setRadialAccelVar),_p.rotationIsDir,cc.defineGetterSetter(_p,"rotationIsDir",_p.getRotationIsDir,_p.setRotationIsDir),_p.startRadius,cc.defineGetterSetter(_p,"startRadius",_p.getStartRadius,_p.setStartRadius),_p.startRadiusVar,cc.defineGetterSetter(_p,"startRadiusVar",_p.getStartRadiusVar,_p.setStartRadiusVar),_p.endRadius,cc.defineGetterSetter(_p,"endRadius",_p.getEndRadius,_p.setEndRadius),_p.endRadiusVar,cc.defineGetterSetter(_p,"endRadiusVar",_p.getEndRadiusVar,_p.setEndRadiusVar),_p.rotatePerS,cc.defineGetterSetter(_p,"rotatePerS",_p.getRotatePerSecond,_p.setRotatePerSecond),_p.rotatePerSVar,cc.defineGetterSetter(_p,"rotatePerSVar",_p.getRotatePerSecondVar,_p.setRotatePerSecondVar),_p.startColor,cc.defineGetterSetter(_p,"startColor",_p.getStartColor,_p.setStartColor),_p.startColorVar,cc.defineGetterSetter(_p,"startColorVar",_p.getStartColorVar,_p.setStartColorVar),_p.endColor,cc.defineGetterSetter(_p,"endColor",_p.getEndColor,_p.setEndColor),_p.endColorVar,cc.defineGetterSetter(_p,"endColorVar",_p.getEndColorVar,_p.setEndColorVar),_p.totalParticles,cc.defineGetterSetter(_p,"totalParticles",_p.getTotalParticles,_p.setTotalParticles),_p.texture,cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture),cc.ParticleSystem.create=function(a){return new cc.ParticleSystem(a)},cc.ParticleSystem.createWithTotalParticles=cc.ParticleSystem.create,cc.ParticleSystem.ModeA=function(a,b,c,d,e,f,g,h){this.gravity=a?a:cc.p(0,0),this.speed=b||0,this.speedVar=c||0,this.tangentialAccel=d||0,this.tangentialAccelVar=e||0,this.radialAccel=f||0,this.radialAccelVar=g||0,this.rotationIsDir=h||!1},cc.ParticleSystem.ModeB=function(a,b,c,d,e,f){this.startRadius=a||0,this.startRadiusVar=b||0,this.endRadius=c||0,this.endRadiusVar=d||0,this.rotatePerSecond=e||0,this.rotatePerSecondVar=f||0},cc.ParticleSystem.SHAPE_MODE=0,cc.ParticleSystem.TEXTURE_MODE=1,cc.ParticleSystem.STAR_SHAPE=0,cc.ParticleSystem.BALL_SHAPE=1,cc.ParticleSystem.DURATION_INFINITY=-1,cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE=-1,cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS=-1,cc.ParticleSystem.MODE_GRAVITY=0,cc.ParticleSystem.MODE_RADIUS=1,cc.ParticleSystem.TYPE_FREE=0,cc.ParticleSystem.TYPE_RELATIVE=1,cc.ParticleSystem.TYPE_GROUPED=2,function(){cc.ParticleSystem.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._drawMode=cc.ParticleSystem.TEXTURE_MODE,this._shapeType=cc.ParticleSystem.BALL_SHAPE,this._pointRect=cc.rect(0,0,0,0),this._tintCache=document.createElement("canvas")};var a=cc.ParticleSystem.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ParticleSystem.CanvasRenderCmd,a.getDrawMode=function(){return this._drawMode},a.setDrawMode=function(a){this._drawMode=a},a.getShapeType=function(){return this._shapeType},a.setShapeType=function(a){this._shapeType=a},a.setBatchNode=function(a){this._batchNode!==a&&(this._node._batchNode=a)},a.updateQuadWithParticle=function(a,b){},a.updateParticlePosition=function(a,b){cc.pIn(a.drawPos,b)},a.rendering=function(a,b,c){var d=a||cc._renderContext,e=d.getContext(),f=this._node,g=this._pointRect;d.setTransform(this._worldTransform,b,c),d.save(),f.isBlendAdditive()?e.globalCompositeOperation="lighter":e.globalCompositeOperation="source-over";var h,i,j,k,l=this._node.particleCount,m=this._node._particles;if(f.drawMode!==cc.ParticleSystem.SHAPE_MODE&&f._texture){if(!f._texture._textureLoaded)return void d.restore();var n=f._texture.getHtmlElementObj();if(!n.width||!n.height)return void d.restore();var o=n;for(h=0;l>h;h++)if(i=m[h],j=0|.5*i.size,k=i.color.a/255,0!==k){e.globalAlpha=k,e.save(),e.translate(0|i.drawPos.x,-(0|i.drawPos.y));var p=4*Math.floor(i.size/4),q=g.width,r=g.height;e.scale(Math.max(1/q*p,1e-6),Math.max(1/r*p,1e-6)),i.rotation&&e.rotate(cc.degreesToRadians(i.rotation)),o=i.isChangeColor?this._changeTextureColor(f._texture,i.color,this._pointRect):n,e.drawImage(o,-(0|q/2),-(0|r/2)),e.restore()}}else{var s=cc._drawingUtil;for(h=0;l>h;h++)i=m[h],j=0|.5*i.size,k=i.color.a/255,0!==k&&(e.globalAlpha=k,e.save(),e.translate(0|i.drawPos.x,-(0|i.drawPos.y)),f.shapeType===cc.ParticleSystem.STAR_SHAPE?(i.rotation&&e.rotate(cc.degreesToRadians(i.rotation)),s.drawStar(d,j,i.color)):s.drawColorBall(d,j,i.color),e.restore())}d.restore(),cc.g_NumberOfDraws++},a._changeTextureColor=function(a,b,c){var d=this._tintCache,e=a.getContentSize();return d.width=e.width,d.height=e.height,a._generateColorTexture(b.r,b.g,b.b,c,d)},a.initTexCoordsWithRect=function(a){this._pointRect=a},a.setTotalParticles=function(a){this._node._totalParticles=200>a?a:200},a.addParticle=function(){var a,b=this._node,c=b._particles;return b.particleCountd.getCapacity()&&(this._increaseAtlasCapacityTo(e+c),d.fillWithEmptyQuadsFromIndex(d.getCapacity()-c,c)),a.getAtlasIndex()+c!==e&&d.moveQuadsFromIndex(b,b+c),d.increaseTotalQuadsWith(c),this._updateAllAtlasIndexes()},removeChild:function(a,b){if(null!=a){if(!(a instanceof cc.ParticleSystem))throw new Error("cc.ParticleBatchNode.removeChild(): only supports cc.ParticleSystem as children");if(-1===this._children.indexOf(a))return void cc.log("cc.ParticleBatchNode.removeChild(): doesn't contain the sprite. Can't remove it");cc.Node.prototype.removeChild.call(this,a,b);var c=this.textureAtlas;c.removeQuadsAtIndex(a.getAtlasIndex(),a.getTotalParticles()),c.fillWithEmptyQuadsFromIndex(c.totalQuads,a.getTotalParticles()),a.setBatchNode(null),this._updateAllAtlasIndexes()}},reorderChild:function(a,b){if(!a)throw new Error("cc.ParticleBatchNode.reorderChild(): child should be non-null");if(!(a instanceof cc.ParticleSystem))throw new Error("cc.ParticleBatchNode.reorderChild(): only supports cc.QuadParticleSystems as children");if(-1===this._children.indexOf(a))return void cc.log("cc.ParticleBatchNode.reorderChild(): Child doesn't belong to batch");if(b!==a.zIndex){if(this._children.length>1){var c=this._getCurrentIndex(a,b);if(c.oldIndex!==c.newIndex){this._children.splice(c.oldIndex,1),this._children.splice(c.newIndex,0,a);var d=a.getAtlasIndex();this._updateAllAtlasIndexes();for(var e=0,f=this._children,g=0;gd;d++)if(b[d].zIndex>a)return d;return c},_getCurrentIndex:function(a,b){for(var c=!1,d=!1,e=0,f=0,g=0,h=this._children,i=h.length,j=0;i>j;j++){var k=h[j];if(k.zIndex>b&&!d&&(e=j,d=!0,c&&d))break;if(a===k&&(f=j,c=!0,d||(g=-1),c&&d))break}return d||(e=i),e+=g,{newIndex:e,oldIndex:f}},_addChildHelper:function(a,b,c){if(!a)throw new Error("cc.ParticleBatchNode._addChildHelper(): child should be non-null");if(a.parent)return cc.log("cc.ParticleBatchNode._addChildHelper(): child already added. It can't be added again"),null;this._children||(this._children=[]);var d=this._searchNewPositionInChildrenForZ(b);return this._children.splice(d,0,a),a.tag=c,a._setLocalZOrder(b),a.parent=this,this._running&&(a.onEnter(),a.onEnterTransitionDidFinish()),d},_updateBlendFunc:function(){this.textureAtlas.texture.hasPremultipliedAlpha()||(this._blendFunc.src=cc.SRC_ALPHA,this._blendFunc.dst=cc.ONE_MINUS_SRC_ALPHA)},getTextureAtlas:function(){return this.textureAtlas},setTextureAtlas:function(a){this.textureAtlas=a}});var _p=cc.ParticleBatchNode.prototype;_p.texture,cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture),cc.ParticleBatchNode.create=function(a,b){return new cc.ParticleBatchNode(a,b)},function(){cc.ParticleBatchNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!1};var a=cc.ParticleBatchNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ParticleBatchNode.CanvasRenderCmd,a._initWithTexture=function(){}}();!function(){cc.ParticleBatchNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0};var a=cc.ParticleBatchNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParticleBatchNode.WebGLRenderCmd,a.rendering=function(a){var b=this._node;0!==b.textureAtlas.totalQuads&&(this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBlendFuncForParticle(b._blendFunc.src,b._blendFunc.dst),b.textureAtlas.drawQuads())},a._initWithTexture=function(){this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR)},a.visit=function(a){var b=this._node;if(b._visible){var c=cc.current_stack;c.stack.push(c.top),this._syncStatus(a),c.top=this._stackMatrix,cc.renderer.pushRenderCommand(this),this._dirtyFlag=0,cc.kmGLPopMatrix()}}}(),function(){cc.ParticleSystem.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0,this._buffersVBO=[0,0],this._quads=[],this._indices=[],this._quadsArrayBuffer=null};var a=cc.ParticleSystem.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParticleSystem.WebGLRenderCmd,a.getDrawMode=function(){},a.setDrawMode=function(a){},a.getShapeType=function(){},a.setShapeType=function(a){},a.setBatchNode=function(a){var b=this._node;if(b._batchNode!==a){var c=b._batchNode;if(b._batchNode=a,a)for(var d=b._particles,e=0;ec;++c){var e=6*c,f=4*c;b[e+0]=f+0,b[e+1]=f+1,b[e+2]=f+2,b[e+5]=f+1,b[e+4]=f+2,b[e+3]=f+3}},a.isDifferentTexture=function(a,b){return a===b},a.updateParticlePosition=function(a,b){this.updateQuadWithParticle(a,b)},a.updateQuadWithParticle=function(a,b){var c=null,d=this._node;if(d._batchNode){var e=d._batchNode.textureAtlas.quads;c=e[d.atlasIndex+a.atlasIndex],d._batchNode.textureAtlas.dirty=!0}else c=this._quads[d._particleIdx];var f,g,h,i;d._opacityModifyRGB?(f=0|a.color.r*a.color.a/255,g=0|a.color.g*a.color.a/255,h=0|a.color.b*a.color.a/255):(f=0|a.color.r,g=0|a.color.g,h=0|a.color.b),i=0|a.color.a;var j=c.bl.colors,k=c.br.colors,l=c.tl.colors,m=c.tr.colors;j.r=k.r=l.r=m.r=f,j.g=k.g=l.g=m.g=g,j.b=k.b=l.b=m.b=h,j.a=k.a=l.a=m.a=i;var n=a.size/2;if(a.rotation){var o=-n,p=-n,q=n,r=n,s=b.x,t=b.y,u=-cc.degreesToRadians(a.rotation),v=Math.cos(u),w=Math.sin(u),x=o*v-p*w+s,y=o*w+p*v+t,z=q*v-p*w+s,A=q*w+p*v+t,B=q*v-r*w+s,C=q*w+r*v+t,D=o*v-r*w+s,E=o*w+r*v+t;c.bl.vertices.x=x,c.bl.vertices.y=y,c.br.vertices.x=z,c.br.vertices.y=A,c.tl.vertices.x=D,c.tl.vertices.y=E,c.tr.vertices.x=B,c.tr.vertices.y=C}else c.bl.vertices.x=b.x-n,c.bl.vertices.y=b.y-n,c.br.vertices.x=b.x+n,c.br.vertices.y=b.y-n,c.tl.vertices.x=b.x-n,c.tl.vertices.y=b.y+n,c.tr.vertices.x=b.x+n,c.tr.vertices.y=b.y+n},a.rendering=function(a){var b=this._node;if(b._texture){var c=a||cc._renderContext;this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),cc.glBindTexture2D(b._texture),cc.glBlendFuncForParticle(b._blendFunc.src,b._blendFunc.dst),cc.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX),c.bindBuffer(c.ARRAY_BUFFER,this._buffersVBO[0]),c.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,3,c.FLOAT,!1,24,0),c.vertexAttribPointer(cc.VERTEX_ATTRIB_COLOR,4,c.UNSIGNED_BYTE,!0,24,12),c.vertexAttribPointer(cc.VERTEX_ATTRIB_TEX_COORDS,2,c.FLOAT,!1,24,16),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]),c.drawElements(c.TRIANGLES,6*b._particleIdx,c.UNSIGNED_SHORT,0)}},a.initTexCoordsWithRect=function(a){var b=this._node,c=b.texture,d=cc.contentScaleFactor(),e=cc.rect(a.x*d,a.y*d,a.width*d,a.height*d),f=a.width,g=a.height;c&&(f=c.pixelsWidth,g=c.pixelsHeight);var h,i,j,k;cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL?(h=(2*e.x+1)/(2*f),i=(2*e.y+1)/(2*g),j=h+(2*e.width-2)/(2*f),k=i+(2*e.height-2)/(2*g)):(h=e.x/f,i=e.y/g,j=h+e.width/f,k=i+e.height/g);var l=k;k=i,i=l;var m,n=0,o=0;b._batchNode?(m=b._batchNode.textureAtlas.quads,n=b.atlasIndex,o=b.atlasIndex+b._totalParticles):(m=this._quads,n=0,o=b._totalParticles);for(var p=n;o>p;p++){m[p]||(m[p]=cc.V3F_C4B_T2F_QuadZero());var q=m[p];q.bl.texCoords.u=h,q.bl.texCoords.v=i,q.br.texCoords.u=j,q.br.texCoords.v=i,q.tl.texCoords.u=h,q.tl.texCoords.v=k,q.tr.texCoords.u=j,q.tr.texCoords.v=k}},a.setTotalParticles=function(a){var b=this._node;if(a>b._allocatedParticles){var c=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT;this._indices=new Uint16Array(6*a);var d=new ArrayBuffer(a*c),e=b._particles;e.length=0;var f=this._quads;f.length=0;for(var g=0;a>g;g++)e[g]=new cc.Particle,f[g]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,d,g*c);if(b._allocatedParticles=a,b._totalParticles=a,b._batchNode)for(var h=0;a>h;h++)e[h].atlasIndex=h;this._quadsArrayBuffer=d,this.initIndices(a),this._setupVBO(),b._texture&&this.initTexCoordsWithRect(cc.rect(0,0,b._texture.width,b._texture.height))}else b._totalParticles=a;b.resetSystem()},a.addParticle=function(){var a=this._node,b=a._particles;return b[a.particleCount]},a._setupVBO=function(){var a=cc._renderContext;this._buffersVBO[0]=a.createBuffer(),a.bindBuffer(a.ARRAY_BUFFER,this._buffersVBO[0]),a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW),this._buffersVBO[1]=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._buffersVBO[1]),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this._indices,a.STATIC_DRAW)},a._allocMemory=function(){var a=this._node;if(a._batchNode)return cc.log("cc.ParticleSystem._allocMemory(): Memory should not be allocated when not using batchNode"),!1;var b=cc.V3F_C4B_T2F_Quad.BYTES_PER_ELEMENT,c=a._totalParticles,d=this._quads;d.length=0,this._indices=new Uint16Array(6*c);for(var e=new ArrayBuffer(b*c),f=0;c>f;f++)d[f]=new cc.V3F_C4B_T2F_Quad(null,null,null,null,e,f*b);return d&&this._indices?(this._quadsArrayBuffer=e,!0):(cc.log("cocos2d: Particle system: not enough memory"),!1)},a.postStep=function(){var a=cc._renderContext;a.bindBuffer(a.ARRAY_BUFFER,this._buffersVBO[0]),a.bufferData(a.ARRAY_BUFFER,this._quadsArrayBuffer,a.DYNAMIC_DRAW)},a._setBlendAdditive=function(){var a=this._node._blendFunc;this._texture&&!this._texture.hasPremultipliedAlpha()?(a.src=cc.SRC_ALPHA,a.dst=cc.ONE_MINUS_SRC_ALPHA):(a.src=cc.BLEND_SRC,a.dst=cc.BLEND_DST)},a._initWithTotalParticles=function(a){return this._allocMemory()?(this.initIndices(a),this._setupVBO(),void(this._shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR))):!1},a._updateDeltaColor=function(a,b){a.color.r+=a.deltaColor.r*b,a.color.g+=a.deltaColor.g*b,a.color.b+=a.deltaColor.b*b,a.color.a+=a.deltaColor.a*b,a.isChangeColor=!0}}();cc.IMEKeyboardNotificationInfo=function(a,b,c){this.begin=a||cc.rect(0,0,0,0),this.end=b||cc.rect(0,0,0,0),this.duration=c||0},cc.IMEDelegate=cc.Class.extend({ctor:function(){cc.imeDispatcher.addDelegate(this)},removeDelegate:function(){cc.imeDispatcher.removeDelegate(this)},attachWithIME:function(){return cc.imeDispatcher.attachDelegateWithIME(this)},detachWithIME:function(){return cc.imeDispatcher.detachDelegateWithIME(this)},canAttachWithIME:function(){return!1},didAttachWithIME:function(){},canDetachWithIME:function(){return!1},didDetachWithIME:function(){},insertText:function(a,b){},deleteBackward:function(){},getContentText:function(){return""},keyboardWillShow:function(a){},keyboardDidShow:function(a){},keyboardWillHide:function(a){},keyboardDidHide:function(a){}}),cc.IMEDispatcher=cc.Class.extend({_domInputControl:null,impl:null,_currentInputString:"",_lastClickPosition:null,ctor:function(){this.impl=new cc.IMEDispatcher.Impl,this._lastClickPosition=cc.p(0,0)},init:function(){if(!cc.sys.isMobile){this._domInputControl=cc.$("#imeDispatcherInput"),this._domInputControl||(this._domInputControl=cc.$new("input"),this._domInputControl.setAttribute("type","text"),this._domInputControl.setAttribute("id","imeDispatcherInput"),this._domInputControl.resize(0,0),this._domInputControl.translates(0,0),this._domInputControl.style.opacity="0",this._domInputControl.style.fontSize="1px",this._domInputControl.setAttribute("tabindex",2),this._domInputControl.style.position="absolute",this._domInputControl.style.top=0,this._domInputControl.style.left=0,document.body.appendChild(this._domInputControl));var a=this;this._domInputControl.addEventListener("input",function(){a._processDomInputString(a._domInputControl.value)},!1),this._domInputControl.addEventListener("keydown",function(b){b.keyCode===cc.KEY.tab?(b.stopPropagation(),b.preventDefault()):b.keyCode===cc.KEY.enter&&(a.dispatchInsertText("\n",1),b.stopPropagation(),b.preventDefault())},!1),/msie/i.test(navigator.userAgent)&&this._domInputControl.addEventListener("keyup",function(b){b.keyCode===cc.KEY.backspace&&a._processDomInputString(a._domInputControl.value)},!1),window.addEventListener("mousedown",function(b){var c=b.pageX||0,d=b.pageY||0;a._lastClickPosition.x=c,a._lastClickPosition.y=d},!1)}},_processDomInputString:function(a){var b,c,d=this._currentInputString.lengthc&&a[c]===this._currentInputString[c];c++);var e=this._currentInputString.length-c,f=a.length-c;for(b=0;e>b;b++)this.dispatchDeleteBackward();for(b=0;f>b;b++)this.dispatchInsertText(a[c+b],1);this._currentInputString=a},dispatchInsertText:function(a,b){!this.impl||!a||0>=b||this.impl._delegateWithIme&&this.impl._delegateWithIme.insertText(a,b)},dispatchDeleteBackward:function(){this.impl&&this.impl._delegateWithIme&&this.impl._delegateWithIme.deleteBackward()},getContentText:function(){if(this.impl&&this.impl._delegateWithIme){var a=this.impl._delegateWithIme.getContentText();return a?a:""}return""},dispatchKeyboardWillShow:function(a){if(this.impl)for(var b=0;b-1||this.impl._delegateList.splice(0,0,a))},attachDelegateWithIME:function(a){if(!this.impl||!a)return!1;if(-1===this.impl._delegateList.indexOf(a))return!1;if(this.impl._delegateWithIme){if(!this.impl._delegateWithIme.canDetachWithIME()||!a.canAttachWithIME())return!1;var b=this.impl._delegateWithIme;return this.impl._delegateWithIme=null,b.didDetachWithIME(),this._focusDomInput(a),!0}return a.canAttachWithIME()?(this._focusDomInput(a),!0):!1},_focusDomInput:function(a){if(cc.sys.isMobile){this.impl._delegateWithIme=a,a.didAttachWithIME(),this._currentInputString=a.string||"";var b,c=a.getTipMessage?a.getTipMessage():"please enter your word:";b=window.Window&&Window.prototype.prompt!=prompt?Window.prototype.prompt.call(window,c,this._currentInputString):prompt(c,this._currentInputString),null!=b&&this._processDomInputString(b),this.dispatchInsertText("\n",1)}else this.impl._delegateWithIme=a,this._currentInputString=a.string||"",a.didAttachWithIME(),this._domInputControl.focus(),this._domInputControl.value=this._currentInputString,this._domInputControlTranslate()},_domInputControlTranslate:function(){/msie/i.test(navigator.userAgent)?(this._domInputControl.style.left=this._lastClickPosition.x+"px",this._domInputControl.style.top=this._lastClickPosition.y+"px"):this._domInputControl.translates(this._lastClickPosition.x,this._lastClickPosition.y)},detachDelegateWithIME:function(a){return this.impl&&a?this.impl._delegateWithIme!==a?!1:a.canDetachWithIME()?(this.impl._delegateWithIme=null,a.didDetachWithIME(),cc._canvas.focus(),!0):!1:!1},removeDelegate:function(a){this.impl&&a&&-1!==this.impl._delegateList.indexOf(a)&&(this.impl._delegateWithIme&&a===this.impl._delegateWithIme&&(this.impl._delegateWithIme=null),cc.arrayRemoveObject(this.impl._delegateList,a))},processKeycode:function(a){32>a?a===cc.KEY.backspace?this.dispatchDeleteBackward():a===cc.KEY.enter?this.dispatchInsertText("\n",1):a===cc.KEY.tab||a===cc.KEY.escape:255>a&&this.dispatchInsertText(String.fromCharCode(a),1)}}),cc.IMEDispatcher.Impl=cc.Class.extend({_delegateWithIme:null,_delegateList:null,ctor:function(){this._delegateList=[]},findDelegate:function(a){for(var b=0;b=a?(this._inputText="",this._charCount=0,cc.LabelTTF.prototype.setString.call(this,this._placeHolder),void this.setColor(this.colorSpaceHolder)):void(this.string=this._inputText.substring(0,a-b))}},removeDelegate:function(){cc.imeDispatcher.removeDelegate(this)},_tipMessage:"please enter your word:",setTipMessage:function(a){null!=a&&(this._tipMessage=a)},getTipMessage:function(){return this._tipMessage},insertText:function(a,b){var c=a,d=c.indexOf("\n");if(d>-1&&(c=c.substring(0,d)),c.length>0){if(this.delegate&&this.delegate.onTextFieldInsertText(this,c,c.length))return;var e=this._inputText+c;this._charCount=e.length,this.string=e}-1!==d&&(this.delegate&&this.delegate.onTextFieldInsertText(this,"\n",1)||this.detachWithIME())},getContentText:function(){return this._inputText},keyboardWillShow:function(a){},keyboardDidShow:function(a){},keyboardWillHide:function(a){},keyboardDidHide:function(a){}});var _p=cc.TextFieldTTF.prototype;_p.charCount,cc.defineGetterSetter(_p,"charCount",_p.getCharCount),_p.placeHolder,cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder),cc.TextFieldTTF.create=function(a,b,c,d,e){return new cc.TextFieldTTF(a,b,c,d,e)};cc.TGA_OK=0,cc.TGA_ERROR_FILE_OPEN=1,cc.TGA_ERROR_READING_FILE=2,cc.TGA_ERROR_INDEXED_COLOR=3,cc.TGA_ERROR_MEMORY=4,cc.TGA_ERROR_COMPRESSED_FILE=5,cc.ImageTGA=function(a,b,c,d,e,f,g){this.status=a||0,this.type=b||0,this.pixelDepth=c||0,this.width=d||0,this.height=e||0,this.imageData=f||[],this.flipped=g||0},cc.tgaLoadHeader=function(a,b,c){var d=2;if(d+1>b)return!1;var e=new cc.BinaryStreamReader(a);if(e.setOffset(d),c.type=e.readByte(),d+=10,d+4+1>b)return!1;if(e.setOffset(d),c.width=e.readUnsignedShort(),c.height=e.readUnsignedInteger(),c.pixelDepth=e.readByte(),d+=5,d+1>b)return!1;var f=e.readByte();return c.flipped=0,32&f&&(c.flipped=1),!0},cc.tgaLoadImageData=function(a,b,c){var d,e,f,g,h=18;if(d=0|c.pixelDepth/2,e=c.height*c.width*d,h+e>b)return!1;if(c.imageData=cc.__getSubArray(a,h,h+e),d>=3)for(f=0;e>f;f+=d)g=c.imageData[f],c.imageData[f]=c.imageData[f+2],c.imageData[f+2]=g;return!0},cc.tgaRGBtogreyscale=function(a){var b,c;if(8!==a.pixelDepth){var d=a.pixelDepth/8,e=new Uint8Array(a.height*a.width);if(null!==e){for(b=0,c=0;cf;f++){if(0!==k)k--,h=0!==i;else{if(l+1>b)break;k=a[l],l+=1,i=128&k,i&&(k-=128),h=0}if(!h){if(l+d>b)break;if(j=cc.__getSubArray(a,l,l+d),l+=d,d>=3){var m=j[0];j[0]=j[2],j[2]=m}}for(var n=0;d>n;n++)c.imageData[g+n]=j[n];g+=d}return!0},cc.tgaFlipImage=function(a){for(var b=a.pixelDepth/8,c=a.width*b,d=0;d>3;this._checkSize(c);var e=Math.pow(2,b-1)-1,f=this._readBits(a+b,1,d),g=this._readBits(a,b,d),h=0,i=2,j=0;do for(var k=this._readByte(++j,d),l=a%8||8,m=1<>=1;)k&m&&(h+=1/i),i*=2;while(a-=l);return this._offset+=d,g===(e<<1)+1?h?NaN:f?-(1/0):+(1/0):(1+-2*f)*(g||h?g?Math.pow(2,g-e)*(1+h):Math.pow(2,-e+1)*h:0)},_readByte:function(a,b){return this._data[this._offset+b-a-1]},_decodeInt:function(a,b){var c=this._readBits(0,a,a/8),d=Math.pow(2,a),e=b&&c>=d/2?c-d:c;return this._offset+=a/8,e},_shl:function(a,b){for(++b;--b;a=1073741824===(1073741824&(a%=2147483648))?2*a:2*(a-1073741824)+2147483647+1);return a},_readBits:function(a,b,c){var d=(a+b)%8,e=a%8,f=c-(a>>3)-1,g=c+(-(a+b)>>3),h=f-g,i=this._readByte(f,c)>>e&(1<<(h?8-e:b))-1;for(h&&d&&(i+=(this._readByte(g++,c)&(1<e;e++)if(d=c[e],d&&d.visible){var g=this._parseLayer(d,a);this.addChild(g,b,b),this.width=Math.max(this.width,g.width),this.height=Math.max(this.height,g.height),b++}},allLayers:function(){for(var a=[],b=this._children,c=0,d=b.length;d>c;c++){var e=b[c];e&&e instanceof cc.TMXLayer&&a.push(e)}return a},getLayer:function(a){if(!a||0===a.length)throw new Error("cc.TMXTiledMap.getLayer(): layerName should be non-null or non-empty string.");for(var b=this._children,c=0;c=0;e--){var f=d[e];if(f)for(var g=0;g>>0>=f.firstGid)return f}}return cc.log("cocos2d: Warning: TMX Layer "+a.name+" has no tiles"),null}});var _p=cc.TMXTiledMap.prototype;_p.mapWidth,cc.defineGetterSetter(_p,"mapWidth",_p._getMapWidth,_p._setMapWidth),_p.mapHeight,cc.defineGetterSetter(_p,"mapHeight",_p._getMapHeight,_p._setMapHeight),_p.tileWidth,cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth),_p.tileHeight,cc.defineGetterSetter(_p,"tileHeight",_p._getTileHeight,_p._setTileHeight),cc.TMXTiledMap.create=function(a,b){return new cc.TMXTiledMap(a,b)},cc.TMX_PROPERTY_NONE=0,cc.TMX_PROPERTY_MAP=1,cc.TMX_PROPERTY_LAYER=2,cc.TMX_PROPERTY_OBJECTGROUP=3,cc.TMX_PROPERTY_OBJECT=4,cc.TMX_PROPERTY_TILE=5,cc.TMX_TILE_HORIZONTAL_FLAG=2147483648,cc.TMX_TILE_VERTICAL_FLAG=1073741824,cc.TMX_TILE_DIAGONAL_FLAG=536870912,cc.TMX_TILE_FLIPPED_ALL=(cc.TMX_TILE_HORIZONTAL_FLAG|cc.TMX_TILE_VERTICAL_FLAG|cc.TMX_TILE_DIAGONAL_FLAG)>>>0,cc.TMX_TILE_FLIPPED_MASK=~cc.TMX_TILE_FLIPPED_ALL>>>0,cc.TMXLayerInfo=cc.Class.extend({properties:null,name:"",_layerSize:null,_tiles:null,visible:null,_opacity:null,ownTiles:!0,_minGID:1e5,_maxGID:0,offset:null,ctor:function(){this.properties=[],this.name="",this._layerSize=null,this._tiles=[],this.visible=!0,this._opacity=0,this.ownTiles=!0,this._minGID=1e5,this._maxGID=0,this.offset=cc.p(0,0)},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a}}),cc.TMXTilesetInfo=cc.Class.extend({name:"",firstGid:0,_tileSize:null,spacing:0,margin:0,sourceImage:"",imageSize:null,ctor:function(){this._tileSize=cc.size(0,0),this.imageSize=cc.size(0,0)},rectForGID:function(a){var b=cc.rect(0,0,0,0);b.width=this._tileSize.width,b.height=this._tileSize.height,a&=cc.TMX_TILE_FLIPPED_MASK,a-=parseInt(this.firstGid,10);var c=parseInt((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing),10);return b.x=parseInt(a%c*(this._tileSize.width+this.spacing)+this.margin,10),b.y=parseInt(parseInt(a/c,10)*(this._tileSize.height+this.spacing)+this.margin,10),b}}),cc.TMXMapInfo=cc.SAXParser.extend({properties:null,orientation:null,parentElement:null,parentGID:null,layerAttrs:0,storingCharacters:!1,tmxFileName:null,currentString:null,_objectGroups:null,_mapSize:null,_tileSize:null,_layers:null,_tilesets:null,_tileProperties:null,_resources:"",_currentFirstGID:0,ctor:function(a,b){cc.SAXParser.prototype.ctor.apply(this),this._mapSize=cc.size(0,0),this._tileSize=cc.size(0,0),this._layers=[],this._tilesets=[],this._objectGroups=[],this.properties=[],this._tileProperties={},this._currentFirstGID=0,void 0!==b?this.initWithXML(a,b):void 0!==a&&this.initWithTMXFile(a)},getOrientation:function(){return this.orientation},setOrientation:function(a){this.orientation=a},getMapSize:function(){return cc.size(this._mapSize.width,this._mapSize.height)},setMapSize:function(a){this._mapSize.width=a.width,this._mapSize.height=a.height},_getMapWidth:function(){return this._mapSize.width},_setMapWidth:function(a){this._mapSize.width=a},_getMapHeight:function(){return this._mapSize.height},_setMapHeight:function(a){this._mapSize.height=a},getTileSize:function(){return cc.size(this._tileSize.width,this._tileSize.height)},setTileSize:function(a){this._tileSize.width=a.width,this._tileSize.height=a.height},_getTileWidth:function(){return this._tileSize.width},_setTileWidth:function(a){this._tileSize.width=a},_getTileHeight:function(){return this._tileSize.height},_setTileHeight:function(a){this._tileSize.height=a},getLayers:function(){return this._layers},setLayers:function(a){this._layers.push(a)},getTilesets:function(){return this._tilesets},setTilesets:function(a){this._tilesets.push(a)},getObjectGroups:function(){return this._objectGroups},setObjectGroups:function(a){this._objectGroups.push(a)},getParentElement:function(){return this.parentElement},setParentElement:function(a){this.parentElement=a},getParentGID:function(){return this.parentGID},setParentGID:function(a){this.parentGID=a},getLayerAttribs:function(){return this.layerAttrs},setLayerAttribs:function(a){this.layerAttrs=a},getStoringCharacters:function(){return this.storingCharacters},setStoringCharacters:function(a){this.storingCharacters=a},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a},initWithTMXFile:function(a){return this._internalInit(a,null),this.parseXMLFile(a)},initWithXML:function(a,b){return this._internalInit(null,b),this.parseXMLString(a)},parseXMLFile:function(a,b){b=b||!1;var c=b?a:cc.loader.getRes(a);if(!c)throw new Error("Please load the resource first : "+a);var d,e,f=this._parseXML(c),g=f.documentElement,h=g.getAttribute("version"),i=g.getAttribute("orientation");if("map"===g.nodeName){"1.0"!==h&&null!==h&&cc.log("cocos2d: TMXFormat: Unsupported TMX version:"+h),"orthogonal"===i?this.orientation=cc.TMX_ORIENTATION_ORTHO:"isometric"===i?this.orientation=cc.TMX_ORIENTATION_ISO:"hexagonal"===i?this.orientation=cc.TMX_ORIENTATION_HEX:null!==i&&cc.log("cocos2d: TMXFomat: Unsupported orientation:"+i);var j=cc.size(0,0);j.width=parseFloat(g.getAttribute("width")),j.height=parseFloat(g.getAttribute("height")),this.setMapSize(j),j=cc.size(0,0),j.width=parseFloat(g.getAttribute("tilewidth")),j.height=parseFloat(g.getAttribute("tileheight")),this.setTileSize(j);var k=g.querySelectorAll("map > properties > property");if(k){var l={};for(d=0;d property");if(z){var A={};for(e=0;e property");if(R){var S={};for(e=0;e properties > property");if(W)for(e=0;e property");if(ba)for(var ca=0;ca0){var ea=da[0].getAttribute("points");ea&&(_.points=this._parsePointsString(ea))}var fa=$.querySelectorAll("polyline");if(fa&&fa.length>0){var ga=fa[0].getAttribute("points");ga&&(_.polylinePoints=this._parsePointsString(ga))}V.setObjects(_)}this.setObjectGroups(V)}return g},_parsePointsString:function(a){if(!a)return null;for(var b=[],c=a.split(" "),d=0;d0)for(var b=this._objects,c=0,d=b.length;d>c;c++){var e=b[c].name;if(e&&e===a)return b[c]}return null},getObjects:function(){return this._objects},setObjects:function(a){this._objects.push(a)}}),cc.TMXLayer=cc.SpriteBatchNode.extend({tiles:null,tileset:null,layerOrientation:null,properties:null,layerName:"",_layerSize:null,_mapTileSize:null,_opacity:255,_minGID:null,_maxGID:null,_vertexZvalue:null,_useAutomaticVertexZ:null,_reusedTile:null,_atlasIndexArray:null,_contentScaleFactor:null,_className:"TMXLayer",ctor:function(a,b,c){cc.SpriteBatchNode.prototype.ctor.call(this),this._descendants=[],this._layerSize=cc.size(0,0),this._mapTileSize=cc.size(0,0),void 0!==c&&this.initWithTilesetInfo(a,b,c)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.TMXLayer.CanvasRenderCmd(this):new cc.TMXLayer.WebGLRenderCmd(this)},setContentSize:function(a,b){cc.Node.prototype.setContentSize.call(this,a,b),this._renderCmd._updateCacheContext(a,b)},getTexture:function(){return this._renderCmd.getTexture()},getLayerSize:function(){return cc.size(this._layerSize.width,this._layerSize.height)},setLayerSize:function(a){this._layerSize.width=a.width,this._layerSize.height=a.height},_getLayerWidth:function(){return this._layerSize.width},_setLayerWidth:function(a){this._layerSize.width=a},_getLayerHeight:function(){return this._layerSize.height},_setLayerHeight:function(a){this._layerSize.height=a},getMapTileSize:function(){return cc.size(this._mapTileSize.width,this._mapTileSize.height)},setMapTileSize:function(a){this._mapTileSize.width=a.width,this._mapTileSize.height=a.height},_getTileWidth:function(){return this._mapTileSize.width},_setTileWidth:function(a){this._mapTileSize.width=a},_getTileHeight:function(){return this._mapTileSize.height},_setTileHeight:function(a){this._mapTileSize.height=a},getTiles:function(){return this.tiles},setTiles:function(a){this.tiles=a},getTileset:function(){return this.tileset},setTileset:function(a){this.tileset=a},getLayerOrientation:function(){return this.layerOrientation},setLayerOrientation:function(a){this.layerOrientation=a},getProperties:function(){return this.properties},setProperties:function(a){this.properties=a},initWithTilesetInfo:function(a,b,c){var d,e=b._layerSize,f=parseInt(e.width*e.height),g=.35*f+1;if(a&&(d=cc.textureCache.addImage(a.sourceImage)),this.initWithTexture(d,g)){this.layerName=b.name,this._layerSize=e,this.tiles=b._tiles,this._minGID=b._minGID,this._maxGID=b._maxGID,this._opacity=b._opacity,this.properties=b.properties,this._contentScaleFactor=cc.director.getContentScaleFactor(),this.tileset=a,this._mapTileSize=c.getTileSize(),this.layerOrientation=c.orientation;var h=this._calculateLayerOffset(b.offset);return this.setPosition(cc.pointPixelsToPoints(h)),this._atlasIndexArray=[],this.setContentSize(cc.sizePixelsToPoints(cc.size(this._layerSize.width*this._mapTileSize.width,this._layerSize.height*this._mapTileSize.height))),this._useAutomaticVertexZ=!1,this._vertexZvalue=0,!0}return!1},releaseMap:function(){this.tiles&&(this.tiles=null),this._atlasIndexArray&&(this._atlasIndexArray=null)},getTileAt:function(a,b){if(!a)throw new Error("cc.TMXLayer.getTileAt(): pos should be non-null");if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||a.x<0||a.y<0)throw new Error("cc.TMXLayer.getTileAt(): invalid position");if(!this.tiles||!this._atlasIndexArray)return cc.log("cc.TMXLayer.getTileAt(): TMXLayer: the tiles map has been released"),null;var c=null,d=this.getTileGIDAt(a);if(0===d)return c;var e=0|a.x+a.y*this._layerSize.width;if(c=this.getChildByTag(e),!c){var f=this.tileset.rectForGID(d);f=cc.rectPixelsToPoints(f),c=new cc.Sprite,c.initWithTexture(this.texture,f),c.batchNode=this,c.setPosition(this.getPositionAt(a)),c.vertexZ=this._vertexZForPos(a),c.anchorX=0,c.anchorY=0,c.opacity=this._opacity;var g=this._atlasIndexForExistantZ(e);this.addSpriteWithoutQuad(c,g,e)}return c},getTileGIDAt:function(a,b){if(null==a)throw new Error("cc.TMXLayer.getTileGIDAt(): pos should be non-null");if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||a.x<0||a.y<0)throw new Error("cc.TMXLayer.getTileGIDAt(): invalid position");if(!this.tiles||!this._atlasIndexArray)return cc.log("cc.TMXLayer.getTileGIDAt(): TMXLayer: the tiles map has been released"),null;var c=0|a.x+a.y*this._layerSize.width,d=this.tiles[c];return(d&cc.TMX_TILE_FLIPPED_MASK)>>>0},getTileFlagsAt:function(a,b){if(!a)throw new Error("cc.TMXLayer.getTileFlagsAt(): pos should be non-null");if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||a.x<0||a.y<0)throw new Error("cc.TMXLayer.getTileFlagsAt(): invalid position");if(!this.tiles||!this._atlasIndexArray)return cc.log("cc.TMXLayer.getTileFlagsAt(): TMXLayer: the tiles map has been released"),null;var c=0|a.x+a.y*this._layerSize.width,d=this.tiles[c];return(d&cc.TMX_TILE_FLIPPED_ALL)>>>0},setTileGID:function(a,b,c,d){if(!b)throw new Error("cc.TMXLayer.setTileGID(): pos should be non-null");var e;if(void 0!==d?e=cc.p(b,c):(e=b,d=c),e.x>=this._layerSize.width||e.y>=this._layerSize.height||e.x<0||e.y<0)throw new Error("cc.TMXLayer.setTileGID(): invalid position");if(!this.tiles||!this._atlasIndexArray)return void cc.log("cc.TMXLayer.setTileGID(): TMXLayer: the tiles map has been released");if(0!==a&&a>>0;if(0===a)this.removeTileAt(e);else if(0===g)this._insertTileForGID(h,e);else{var i=e.x+e.y*this._layerSize.width,j=this.getChildByTag(i);if(j){var k=this.tileset.rectForGID(a);k=cc.rectPixelsToPoints(k),j.setTextureRect(k,!1),null!=d&&this._setupTileSprite(j,e,h),this.tiles[i]=h}else this._updateTileForGID(h,e)}}},removeTileAt:function(a,b){if(!a)throw new Error("cc.TMXLayer.removeTileAt(): pos should be non-null");if(void 0!==b&&(a=cc.p(a,b)),a.x>=this._layerSize.width||a.y>=this._layerSize.height||a.x<0||a.y<0)throw new Error("cc.TMXLayer.removeTileAt(): invalid position");if(!this.tiles||!this._atlasIndexArray)return void cc.log("cc.TMXLayer.removeTileAt(): TMXLayer: the tiles map has been released");var c=this.getTileGIDAt(a);if(0!==c){cc._renderType===cc.game.RENDER_TYPE_CANVAS&&this._setNodeDirtyForCache();var d=0|a.x+a.y*this._layerSize.width,e=this._atlasIndexForExistantZ(d);this.tiles[d]=0,this._atlasIndexArray.splice(e,1);var f=this.getChildByTag(d);if(f)cc.SpriteBatchNode.prototype.removeChild.call(this,f,!0);else if(cc._renderType===cc.game.RENDER_TYPE_WEBGL&&this.textureAtlas.removeQuadAtIndex(e),this._children)for(var g=this._children,h=0,i=g.length;i>h;h++){var j=g[h];if(j){var k=j.atlasIndex;k>=e&&(j.atlasIndex=k-1)}}}},getPositionAt:function(a,b){void 0!==b&&(a=cc.p(a,b));var c=cc.p(0,0);switch(this.layerOrientation){case cc.TMX_ORIENTATION_ORTHO:c=this._positionForOrthoAt(a);break;case cc.TMX_ORIENTATION_ISO:c=this._positionForIsoAt(a);break;case cc.TMX_ORIENTATION_HEX:c=this._positionForHexAt(a)}return cc.pointPixelsToPoints(c)},getProperty:function(a){return this.properties[a]},setupTiles:function(){this._renderCmd.initImageSize(),this._parseInternalProperties(),cc._renderType===cc.game.RENDER_TYPE_CANVAS&&this._setNodeDirtyForCache();for(var a=this._layerSize.height,b=this._layerSize.width,c=0;a>c;c++)for(var d=0;b>d;d++){var e=d+b*c,f=this.tiles[e];0!==f&&(this._appendTileForGID(f,cc.p(d,c)),this._minGID=Math.min(f,this._minGID),this._maxGID=Math.max(f,this._maxGID))}this._maxGID>=this.tileset.firstGid&&this._minGID>=this.tileset.firstGid||cc.log("cocos2d:TMX: Only 1 tileset per layer is supported")},addChild:function(a,b,c){cc.log("addChild: is not supported on cc.TMXLayer. Instead use setTileGID or tileAt.")},removeChild:function(a,b){if(a){if(-1===this._children.indexOf(a))return void cc.log("cc.TMXLayer.removeChild(): Tile does not belong to TMXLayer");cc._renderType===cc.game.RENDER_TYPE_CANVAS&&this._setNodeDirtyForCache();var c=a.atlasIndex,d=this._atlasIndexArray[c];this.tiles[d]=0,this._atlasIndexArray.splice(c,1),cc.SpriteBatchNode.prototype.removeChild.call(this,a,b),cc.renderer.childrenOrderDirty=!0}},getLayerName:function(){return this.layerName},setLayerName:function(a){this.layerName=a},_positionForIsoAt:function(a){return cc.p(this._mapTileSize.width/2*(this._layerSize.width+a.x-a.y-1),this._mapTileSize.height/2*(2*this._layerSize.height-a.x-a.y-2))},_positionForOrthoAt:function(a){return cc.p(a.x*this._mapTileSize.width,(this._layerSize.height-a.y-1)*this._mapTileSize.height)},_positionForHexAt:function(a){var b=a.x%2===1?-this._mapTileSize.height/2:0;return cc.p(a.x*this._mapTileSize.width*3/4,(this._layerSize.height-a.y-1)*this._mapTileSize.height+b)},_calculateLayerOffset:function(a){var b=cc.p(0,0);switch(this.layerOrientation){case cc.TMX_ORIENTATION_ORTHO:b=cc.p(a.x*this._mapTileSize.width,-a.y*this._mapTileSize.height);break;case cc.TMX_ORIENTATION_ISO:b=cc.p(this._mapTileSize.width/2*(a.x-a.y),this._mapTileSize.height/2*(-a.x-a.y));break;case cc.TMX_ORIENTATION_HEX:(0!==a.x||0!==a.y)&&cc.log("offset for hexagonal map not implemented yet")}return b},_appendTileForGID:function(a,b){var c=this.tileset.rectForGID(a);c=cc.rectPixelsToPoints(c);var d=0|b.x+b.y*this._layerSize.width,e=this._renderCmd._reusedTileWithRect(c);this._setupTileSprite(e,b,a);var f=this._atlasIndexArray.length;return this.insertQuadFromSprite(e,f),this._atlasIndexArray.splice(f,0,d),e},_insertTileForGID:function(a,b){var c=this.tileset.rectForGID(a);c=cc.rectPixelsToPoints(c);var d=0|b.x+b.y*this._layerSize.width,e=this._renderCmd._reusedTileWithRect(c);this._setupTileSprite(e,b,a);var f=this._atlasIndexForNewZ(d);if(this.insertQuadFromSprite(e,f),this._atlasIndexArray.splice(f,0,d),this._children)for(var g=this._children,h=0,i=g.length;i>h;h++){var j=g[h];if(j){var k=j.atlasIndex;k>=f&&(j.atlasIndex=k+1)}}return this.tiles[d]=a,e},_updateTileForGID:function(a,b){var c=this.tileset.rectForGID(a),d=this._contentScaleFactor;c=cc.rect(c.x/d,c.y/d,c.width/d,c.height/d);var e=b.x+b.y*this._layerSize.width,f=this._renderCmd._reusedTileWithRect(c);return this._setupTileSprite(f,b,a),f.atlasIndex=this._atlasIndexForExistantZ(e),f.dirty=!0,f.updateTransform(),this.tiles[e]=a,f},_parseInternalProperties:function(){var a=this.getProperty("cc_vertexz");if(a)if("automatic"===a){this._useAutomaticVertexZ=!0;var b=this.getProperty("cc_alpha_func"),c=0;if(b&&(c=parseFloat(b)),cc._renderType===cc.game.RENDER_TYPE_WEBGL){this.shaderProgram=cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLORALPHATEST);var d=cc._renderContext.getUniformLocation(this.shaderProgram.getProgram(),cc.UNIFORM_ALPHA_TEST_VALUE_S);this.shaderProgram.use(),this.shaderProgram.setUniformLocationWith1f(d,c)}}else this._vertexZvalue=parseInt(a,10)},_setupTileSprite:function(a,b,c){var d=b.x+b.y*this._layerSize.width;if(a.setPosition(this.getPositionAt(b)),cc._renderType===cc.game.RENDER_TYPE_WEBGL?a.vertexZ=this._vertexZForPos(b):a.tag=d,a.anchorX=0,a.anchorY=0,a.opacity=this._opacity,cc._renderType===cc.game.RENDER_TYPE_WEBGL&&(a.rotation=0),a.setFlippedX(!1),a.setFlippedY(!1),(c&cc.TMX_TILE_DIAGONAL_FLAG)>>>0){a.anchorX=.5,a.anchorY=.5,a.x=this.getPositionAt(b).x+a.width/2,a.y=this.getPositionAt(b).y+a.height/2;var e=(c&(cc.TMX_TILE_HORIZONTAL_FLAG|cc.TMX_TILE_VERTICAL_FLAG)>>>0)>>>0;e===cc.TMX_TILE_HORIZONTAL_FLAG?a.rotation=90:e===cc.TMX_TILE_VERTICAL_FLAG?a.rotation=270:e===(cc.TMX_TILE_VERTICAL_FLAG|cc.TMX_TILE_HORIZONTAL_FLAG)>>>0?(a.rotation=90,a.setFlippedX(!0)):(a.rotation=270,a.setFlippedX(!0))}else(c&cc.TMX_TILE_HORIZONTAL_FLAG)>>>0&&a.setFlippedX(!0),(c&cc.TMX_TILE_VERTICAL_FLAG)>>>0&&a.setFlippedY(!0)},_vertexZForPos:function(a){var b=0,c=0;if(this._useAutomaticVertexZ)switch(this.layerOrientation){case cc.TMX_ORIENTATION_ISO:c=this._layerSize.width+this._layerSize.height,b=-(c-(a.x+a.y));break;case cc.TMX_ORIENTATION_ORTHO:b=-(this._layerSize.height-a.y);break;case cc.TMX_ORIENTATION_HEX:cc.log("TMX Hexa zOrder not supported");break;default:cc.log("TMX invalid value")}else b=this._vertexZvalue;return b},_atlasIndexForExistantZ:function(a){var b;if(this._atlasIndexArray)for(var c=this._atlasIndexArray,d=0,e=c.length;e>d&&(b=c[d],b!==a);d++); +return cc.isNumber(b)||cc.log("cc.TMXLayer._atlasIndexForExistantZ(): TMX atlas index not found. Shall not happen"),d},_atlasIndexForNewZ:function(a){for(var b=this._atlasIndexArray,c=0,d=b.length;d>c;c++){var e=b[c];if(e>a)break}return c}});var _p=cc.TMXLayer.prototype;cc.defineGetterSetter(_p,"texture",_p.getTexture,_p.setTexture),_p.layerWidth,cc.defineGetterSetter(_p,"layerWidth",_p._getLayerWidth,_p._setLayerWidth),_p.layerHeight,cc.defineGetterSetter(_p,"layerHeight",_p._getLayerHeight,_p._setLayerHeight),_p.tileWidth,cc.defineGetterSetter(_p,"tileWidth",_p._getTileWidth,_p._setTileWidth),_p.tileHeight,cc.defineGetterSetter(_p,"tileHeight",_p._getTileHeight,_p._setTileHeight),cc.TMXLayer.create=function(a,b,c){return new cc.TMXLayer(a,b,c)},function(){cc.TMXLayer.CanvasRenderCmd=function(a){cc.SpriteBatchNode.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._realWorldTransform={a:1,b:0,c:0,d:1,tx:0,ty:0};var b=cc._canvas,c=document.createElement("canvas");c.width=b.width,c.height=b.height,this._cacheCanvas=c,this._cacheContext=new cc.CanvasContextWrapper(this._cacheCanvas.getContext("2d"));var d=new cc.Texture2D;d.initWithElement(c),d.handleLoadedTexture(),this._cacheTexture=d,this._cacheDirty=!1};var a=cc.TMXLayer.CanvasRenderCmd.prototype=Object.create(cc.SpriteBatchNode.CanvasRenderCmd.prototype);a.constructor=cc.TMXLayer.CanvasRenderCmd,a._setNodeDirtyForCache=function(){this._cacheDirty=!0},a._renderingChildToCache=function(){if(this._cacheDirty){var a=this._cacheContext,b=a.getContext(),c=this._cacheCanvas;b.setTransform(1,0,0,1,0,0),b.clearRect(0,0,c.width,c.height);for(var d=this._node._children,e=0,f=d.length;f>e;e++)if(d[e]){var g=d[e]._renderCmd;g&&(g.rendering(a,1,1),g._cacheDirty=!1)}this._cacheDirty=!1}},a.rendering=function(a,b,c){var d=this._displayedOpacity/255;if(!(0>=d)){var e=this._node;this._renderingChildToCache();var f=a||cc._renderContext,g=f.getContext();f.setGlobalAlpha(d);var h=this._cacheCanvas;if(h&&0!==h.width&&0!==h.height){f.setTransform(this._realWorldTransform,b,c);var i=h.height*c;if(e.layerOrientation===cc.TMX_ORIENTATION_HEX){var j=.5*e._mapTileSize.height*c;g.drawImage(h,0,0,h.width,h.height,0,-i+j,h.width*b,i)}else g.drawImage(h,0,0,h.width,h.height,0,-i,h.width*b,i)}cc.g_NumberOfDraws++}},a._updateCacheContext=function(a,b){var c=this._node,d=c._contentSize,e=this._cacheCanvas,f=cc.contentScaleFactor();e.width=0|1.5*d.width*f,e.height=0|1.5*d.height*f,c.layerOrientation===cc.TMX_ORIENTATION_HEX?this._cacheContext.setOffset(0,.5*-c._mapTileSize.height):this._cacheContext.setOffset(0,0);var g=this._cacheTexture._contentSize;g.width=e.width,g.height=e.height},a.getTexture=function(){return this._cacheTexture},a.visit=function(a){var b,c,d=this._node,e=d._children;if(d._visible&&e&&0!==e.length){if(a=a||this.getParentRenderCmd(),a&&(this._curLevel=a._curLevel+1),this._syncStatus(a),this._cacheDirty){var f=this._cacheContext,g=this._cacheCanvas,h=f.getContext(),i=d.__instanceId,j=cc.renderer;for(j._turnToCacheMode(i),d.sortAllChildren(),b=0,c=e.length;c>b;b++)if(e[b]){var k=e[b]._renderCmd;k&&(k.visit(this),k._cacheDirty=!1)}h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,g.width,g.height),j._renderingToCacheCanvas(f,i),this._cacheDirty=!1}cc.renderer.pushRenderCommand(this),this._dirtyFlag=0}},a.transform=function(a,b){var c=this.getNodeToParentTransform(),d=this._realWorldTransform;if(a){var e=a._worldTransform;d.a=c.a*e.a+c.b*e.c,d.b=c.a*e.b+c.b*e.d,d.c=c.c*e.a+c.d*e.c,d.d=c.c*e.b+c.d*e.d,d.tx=e.a*c.tx+e.c*c.ty+e.tx,d.ty=e.d*c.ty+e.ty+e.b*c.tx}else d.a=c.a,d.b=c.b,d.c=c.c,d.d=c.d,d.tx=c.tx,d.ty=c.ty;if(b){var f=this._node._children;if(!f||0===f.length)return;var g,h;for(g=0,h=f.length;h>g;g++)f[g]._renderCmd.transform(this,b)}},a.initImageSize=function(){var a=this._node;a.tileset.imageSize=this._texture.getContentSizeInPixels()},a._reusedTileWithRect=function(a){var b=this._node;return b._reusedTile=new cc.Sprite,b._reusedTile.initWithTexture(this._texture,a,!1),b._reusedTile.batchNode=b,b._reusedTile.parent=b,b._reusedTile._renderCmd._cachedParent=b._renderCmd,b._reusedTile}}();!function(){cc.TMXLayer.WebGLRenderCmd=function(a){cc.SpriteBatchNode.WebGLRenderCmd.call(this,a),this._needDraw=!0};var a=cc.TMXLayer.WebGLRenderCmd.prototype=Object.create(cc.SpriteBatchNode.WebGLRenderCmd.prototype);a.constructor=cc.TMXLayer.WebGLRenderCmd,a._updateCacheContext=function(){},a.initImageSize=function(){var a=this._node;a.tileset.imageSize=this._textureAtlas.texture.getContentSizeInPixels(),this._textureAtlas.texture.setAliasTexParameters()},a._reusedTileWithRect=function(a){var b=this._node;return b._reusedTile?(b._reusedTile.batchNode=null,b._reusedTile.setTextureRect(a,!1),b._reusedTile.batchNode=b):(b._reusedTile=new cc.Sprite,b._reusedTile.initWithTexture(b.texture,a,!1),b._reusedTile.batchNode=b),b._reusedTile}}();cc.PointObject=cc.Class.extend({_ratio:null,_offset:null,_child:null,ctor:function(a,b){this.initWithCCPoint(a,b)},getRatio:function(){return this._ratio},setRatio:function(a){this._ratio=a},getOffset:function(){return this._offset},setOffset:function(a){this._offset=a},getChild:function(){return this._child},setChild:function(a){this._child=a},initWithCCPoint:function(a,b){return this._ratio=a,this._offset=b,this._child=null,!0}}),cc.PointObject.create=function(a,b){return new cc.PointObject(a,b)},cc.ParallaxNode=cc.Node.extend({parallaxArray:null,_lastPosition:null,_className:"ParallaxNode",getParallaxArray:function(){return this.parallaxArray},setParallaxArray:function(a){this.parallaxArray=a},ctor:function(){cc.Node.prototype.ctor.call(this),this.parallaxArray=[],this._lastPosition=cc.p(-100,-100)},addChild:function(a,b,c,d){if(3===arguments.length)return void cc.log("ParallaxNode: use addChild(child, z, ratio, offset) instead");if(!a)throw new Error("cc.ParallaxNode.addChild(): child should be non-null");var e=new cc.PointObject(c,d);e.setChild(a),this.parallaxArray.push(e),a.setPosition(this._position.x*c.x+d.x,this._position.y*c.y+d.y),cc.Node.prototype.addChild.call(this,a,b,a.tag)},removeChild:function(a,b){for(var c=this.parallaxArray,d=0;dc;c++){var e=b[c],f=e.getChild();f.setPosition(-a.x+a.x*e.getRatio().x+e.getOffset().x,-a.y+a.y*e.getRatio().y+e.getOffset().y)}this._lastPosition=a}},_absolutePosition:function(){for(var a=this._position,b=this;null!==b.parent;)b=b.parent,a=cc.pAdd(a,b.getPosition());return a},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ParallaxNode.CanvasRenderCmd(this):new cc.ParallaxNode.WebGLRenderCmd(this)}}),cc.ParallaxNode.create=function(){return new cc.ParallaxNode},function(){cc.ParallaxNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._needDraw=!1};var a=cc.ParallaxNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.ParallaxNode.CanvasRenderCmd,a.updateStatus=function(){this._node._updateParallaxPosition(),cc.Node.CanvasRenderCmd.prototype.updateStatus.call(this)},a._syncStatus=function(a){this._node._updateParallaxPosition(),cc.Node.CanvasRenderCmd.prototype._syncStatus.call(this,a)}}(),cc.game.addEventListener(cc.game.EVENT_RENDERER_INITED,function(){if(cc._renderType===cc.game.RENDER_TYPE_WEBGL){cc.ParallaxNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!1};var a=cc.ParallaxNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=cc.ParallaxNode.WebGLRenderCmd,a.updateStatus=function(){this._node._updateParallaxPosition(),cc.Node.WebGLRenderCmd.prototype.updateStatus.call(this)},a._syncStatus=function(a){this._node._updateParallaxPosition(),cc.Node.WebGLRenderCmd.prototype._syncStatus.call(this,a)}}});cc.CONTROL_EVENT_TOTAL_NUMBER=9,cc.CONTROL_EVENT_TOUCH_DOWN=1,cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE=2,cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE=4,cc.CONTROL_EVENT_TOUCH_DRAG_ENTER=8,cc.CONTROL_EVENT_TOUCH_DRAG_EXIT=16,cc.CONTROL_EVENT_TOUCH_UP_INSIDE=32,cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE=64,cc.CONTROL_EVENT_TOUCH_CANCEL=128,cc.CONTROL_EVENT_VALUECHANGED=256,cc.CONTROL_STATE_NORMAL=1,cc.CONTROL_STATE_HIGHLIGHTED=2,cc.CONTROL_STATE_DISABLED=4,cc.CONTROL_STATE_SELECTED=8,cc.CONTROL_STATE_INITIAL=8,cc.Control=cc.Layer.extend({_isOpacityModifyRGB:!1,_hasVisibleParents:!1,_touchListener:null,_className:"Control",isOpacityModifyRGB:function(){return this._isOpacityModifyRGB},setOpacityModifyRGB:function(a){this._isOpacityModifyRGB=a;for(var b=this.getChildren(),c=0,d=b.length;d>c;c++){var e=b[c];e&&e.setOpacityModifyRGB(a)}},_state:cc.CONTROL_STATE_NORMAL,getState:function(){return this._state},_enabled:!1,_selected:!1,_highlighted:!1,_dispatchTable:null,setEnabled:function(a){this._enabled=a,this._state=a?cc.CONTROL_STATE_NORMAL:cc.CONTROL_STATE_DISABLED,this.needsLayout()},isEnabled:function(){return this._enabled},setSelected:function(a){this._selected=a,this.needsLayout()},isSelected:function(){return this._selected},setHighlighted:function(a){this._highlighted=a,this.needsLayout()},isHighlighted:function(){return this._highlighted},hasVisibleParents:function(){for(var a=this.getParent(),b=a;null!=b;b=b.getParent())if(!b.isVisible())return!1;return!0},ctor:function(){cc.Layer.prototype.ctor.call(this),this._dispatchTable={},this._color=cc.color.WHITE},init:function(){if(cc.Layer.prototype.init.call(this)){this._state=cc.CONTROL_STATE_NORMAL,this._enabled=!0,this._selected=!1,this._highlighted=!1;var a=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0});return this.onTouchBegan&&(a.onTouchBegan=this.onTouchBegan.bind(this)),this.onTouchMoved&&(a.onTouchMoved=this.onTouchMoved.bind(this)),this.onTouchEnded&&(a.onTouchEnded=this.onTouchEnded.bind(this)),this.onTouchCancelled&&(a.onTouchCancelled=this.onTouchCancelled.bind(this)),this._touchListener=a,!0}return!1},onEnter:function(){var a=this._touchListener;a._isRegistered()||cc.eventManager.addListener(a,this),cc.Node.prototype.onEnter.call(this)},sendActionsForControlEvents:function(a){for(var b=0,c=cc.CONTROL_EVENT_TOTAL_NUMBER;c>b;b++)if(a&1<e;e++)d[e].invoke(this)},addTargetWithActionForControlEvents:function(a,b,c){for(var d=0,e=cc.CONTROL_EVENT_TOTAL_NUMBER;e>d;d++)c&1<d;d++)c&1<a.g?a.r:a.g,c=c>a.b?c:a.b,e.v=c,d=c-b,c>0?(e.s=d/c,a.r>=c?e.h=(a.g-a.b)/d:a.g>=c?e.h=2+(a.b-a.r)/d:e.h=4+(a.r-a.g)/d,e.h*=60,e.h<0&&(e.h+=360),e):(e.s=0,e.h=-1,e)},cc.ControlUtils.RGBfromHSV=function(a){var b,c,d,e,f,g,h=new cc.RGBA;if(h.a=1,a.s<=0)return a.h?(h.r=0,h.g=0,h.b=0,h):(h.r=a.v,h.g=a.v,h.b=a.v,h);switch(b=a.h,b>=360&&(b=0),b/=60,g=0|b,f=b-g,c=a.v*(1-a.s),d=a.v*(1-a.s*f),e=a.v*(1-a.s*(1-f)),g){case 0:h.r=a.v,h.g=e,h.b=c;break;case 1:h.r=d,h.g=a.v,h.b=c;break;case 2:h.r=c,h.g=a.v,h.b=e;break;case 3:h.r=c,h.g=d,h.b=a.v;break;case 4:h.r=e,h.g=c,h.b=a.v;break;default:h.r=a.v,h.g=c,h.b=d}return h},cc.ControlUtils.CCRectUnion=function(a,b){return cc.rectUnion(a,b)},cc.Invocation=cc.Class.extend({_action:null,_target:null,_controlEvent:null,ctor:function(a,b,c){this._target=a,this._action=b,this._controlEvent=c},getAction:function(){return this._action},getTarget:function(){return this._target},getControlEvent:function(){return this._controlEvent},invoke:function(a){this._target&&this._action&&(cc.isString(this._action)?this._target[this._action](a,this._controlEvent):this._action.call(this._target,a,this._controlEvent))}}),cc.Spacer=cc.Layer.extend({}),cc.Spacer.verticalSpacer=function(a){var b=new cc.Spacer;return b.init(),b.setContentSize(0,a),b},cc.Spacer.horizontalSpacer=function(a){var b=new cc.Spacer;return b.init(),b.setContentSize(a,0),b},cc.MenuPassive=cc.Layer.extend({_color:null,_opacity:0,_className:"MenuPassive",ctor:function(){},getColor:function(){var a=this._color;return cc.color(a.r,a.g,a.b,a.a)},setColor:function(a){var b=this._color;if(b.r=a.r,b.g=a.g,b.b=a.b,this._children&&this._children.length>0)for(var c=0;c0)for(var b=0;b0)for(b=0;b0)for(b=0;b0)for(b=0;b0)for(b=0;b0)for(b=0;b=c.length){cc.log("cc.MenuPassive.alignItemsInColumns(): invalid row index");continue}if(d=c[g],!d){cc.log("cc.MenuPassive.alignItemsInColumns(): can not have zero columns on a row");continue}e=this._children[b].getContentSize().height,h=0|(h>=e||null==e?h:e),++i,i>=d&&(f+=h+5,i=0,h=0,++g)}var j=cc.director.getWinSize();g=0,h=0,d=0;var k=0,l=0,m=f/2;if(this._children&&this._children.length>0)for(b=0;b=e||null==e?h:e),this._children[b].setPosition(l-j.width/2,m-this._children[b].getContentSize().height/2),l+=k,++i,i>=d&&(m-=h+5,i=0,d=0,h=0,++g))},alignItemsInRows:function(a){var b,c=[];for(b=1;b0)for(b=0;b=c.length){cc.log("cc.MenuPassive.alignItemsInRows(): invalid row index");continue}if(d=c[j],!d){cc.log("cc.MenuPassive.alignItemsInColumns(): can't have zero rows on a column");continue}e=this._children[b].getContentSize().width,k=0|(k>=e||null==e?k:e),i+=0|this._children[b].getContentSize().height+5,++l,l>=d&&(f.push(k),g.push(i),h+=k+10,l=0,k=0,i=-5,++j)}var m=cc.director.getWinSize();j=0,k=0,d=null;var n=-h/2,o=0;if(this._children&&this._children.length>0)for(b=0;b=e||null==e?k:e),this._children[b].setPosition(n+f[j]/2,o-m.height/2),o-=this._children[b].getContentSize().height+10,++l,l>=d&&(n+=k+5,l=0,d=0,k=0,++j))},setOpacityModifyRGB:function(a){},isOpacityModifyRGB:function(){return!1}}),cc.MenuPassive.create=function(a){a||(a=null);for(var b=[],c=1;ch&&(a.x=b+h*Math.cos(g),a.y=c+h*Math.sin(g)),this._slider.setPosition(a),a.xthis._startPos.x+this._boxPos+this._boxSize-1&&(a.x=this._startPos.x+this._boxPos+this._boxSize-1),a.ythis._startPos.y+this._boxPos+this._boxSize&&(a.y=this._startPos.y+this._boxPos+this._boxSize),this._saturation=1-Math.abs((this._startPos.x+this._boxPos-a.x)/this._boxSize),this._brightness=Math.abs((this._startPos.y+this._boxPos-a.y)/this._boxSize)},_checkSliderPosition:function(a){var b=this._startPos.x+.5*this._background.getBoundingBox().width,c=this._startPos.y+.5*this._background.getBoundingBox().height,d=a.x-b,e=a.y-c,f=Math.sqrt(d*d+e*e);return f<=.5*this._background.getBoundingBox().width?(this._updateSliderPosition(a),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED),!0):!1},onTouchBegan:function(a,b){if(!this.isEnabled()||!this.isVisible())return!1;var c=this.getTouchLocation(a);return this._checkSliderPosition(c)},onTouchMoved:function(a,b){var c=this.getTouchLocation(a);this._checkSliderPosition(c)}});var _p=cc.ControlSaturationBrightnessPicker.prototype;_p.saturation,cc.defineGetterSetter(_p,"saturation",_p.getSaturation),_p.brightness,cc.defineGetterSetter(_p,"brightness",_p.getBrightness),_p.background,cc.defineGetterSetter(_p,"background",_p.getBackground),_p.overlay,cc.defineGetterSetter(_p,"overlay",_p.getOverlay),_p.shadow,cc.defineGetterSetter(_p,"shadow",_p.getShadow),_p.slider,cc.defineGetterSetter(_p,"slider",_p.getSlider),_p.startPos,cc.defineGetterSetter(_p,"startPos",_p.getStartPos),_p=null,cc.ControlSaturationBrightnessPicker.create=function(a,b){return new cc.ControlSaturationBrightnessPicker(a,b)},cc.ControlHuePicker=cc.Control.extend({_hue:0,_huePercentage:0,_background:null,_slider:null,_startPos:null,_className:"ControlHuePicker",ctor:function(a,b){cc.Control.prototype.ctor.call(this),b&&this.initWithTargetAndPos(a,b)},getHue:function(){return this._hue},setHue:function(a){this._hue=a,this.setHuePercentage(this._hue/360)},getHuePercentage:function(){return this._huePercentage},setHuePercentage:function(a){this._huePercentage=a,this._hue=360*this._huePercentage;var b=this._background.getBoundingBox(),c=this._startPos.x+.5*b.width,d=this._startPos.y+.5*b.height,e=.5*b.width-15,f=360*this._huePercentage-180,g=cc.degreesToRadians(f),h=c+e*Math.cos(g),i=d+e*Math.sin(g);this._slider.setPosition(h,i)},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a),this._slider&&this._slider.setOpacity(a?255:128)},getBackground:function(){return this._background},getSlider:function(){return this._slider},getStartPos:function(){return this._startPos},initWithTargetAndPos:function(a,b){return cc.Control.prototype.init.call(this)?(this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("huePickerBackground.png",a,b,cc.p(0,0)),this._slider=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png",a,b,cc.p(.5,.5)),this._slider.setPosition(b.x,b.y+.5*this._background.getBoundingBox().height),this._startPos=b,this._hue=0,this._huePercentage=0,!0):!1},_updateSliderPosition:function(a){var b=this._background.getBoundingBox(),c=this._startPos.x+.5*b.width,d=this._startPos.y+.5*b.height,e=a.x-c,f=a.y-d,g=Math.atan2(f,e),h=cc.radiansToDegrees(g)+180;this.setHue(h),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},_checkSliderPosition:function(a){var b=Math.sqrt(Math.pow(a.x+10,2)+Math.pow(a.y,2));return 80>b&&b>59?(this._updateSliderPosition(a),!0):!1},onTouchBegan:function(a,b){if(!this.isEnabled()||!this.isVisible())return!1;var c=this.getTouchLocation(a);return this._checkSliderPosition(c)},onTouchMoved:function(a,b){var c=this.getTouchLocation(a);this._checkSliderPosition(c)}});var _p=cc.ControlHuePicker.prototype;_p.hue,cc.defineGetterSetter(_p,"hue",_p.getHue,_p.setHue),_p.huePercent,cc.defineGetterSetter(_p,"huePercent",_p.getHuePercentage,_p.setHuePercentage),_p.background,cc.defineGetterSetter(_p,"background",_p.getBackground),_p.slider,cc.defineGetterSetter(_p,"slider",_p.getSlider),_p.startPos,cc.defineGetterSetter(_p,"startPos",_p.getStartPos),_p=null,cc.ControlHuePicker.create=function(a,b){return new cc.ControlHuePicker(a,b)},cc.ControlColourPicker=cc.Control.extend({_hsv:null,_colourPicker:null,_huePicker:null,_background:null,_className:"ControlColourPicker",ctor:function(){cc.Control.prototype.ctor.call(this),this.init()},hueSliderValueChanged:function(a,b){this._hsv.h=a.getHue();var c=cc.ControlUtils.RGBfromHSV(this._hsv);cc.Control.prototype.setColor.call(this,cc.color(0|255*c.r,0|255*c.g,0|255*c.b)),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED),this._updateControlPicker()},colourSliderValueChanged:function(a,b){this._hsv.s=a.getSaturation(),this._hsv.v=a.getBrightness();var c=cc.ControlUtils.RGBfromHSV(this._hsv);cc.Control.prototype.setColor.call(this,cc.color(0|255*c.r,0|255*c.g,0|255*c.b)),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},setColor:function(a){cc.Control.prototype.setColor.call(this,a);var b=new cc.RGBA;b.r=a.r/255,b.g=a.g/255,b.b=a.b/255,b.a=1,this._hsv=cc.ControlUtils.HSVfromRGB(b),this._updateHueAndControlPicker()},getBackground:function(){return this._background},init:function(){if(cc.Control.prototype.init.call(this)){cc.spriteFrameCache.addSpriteFrames(res.CCControlColourPickerSpriteSheet_plist);var a=new cc.SpriteBatchNode(res.CCControlColourPickerSpriteSheet_png);this.addChild(a),this._hsv=new cc.HSV(0,0,0),this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png",a,cc.p(0,0),cc.p(.5,.5));var b=cc.pSub(this._background.getPosition(),cc.p(this._background.getContentSize().width/2,this._background.getContentSize().height/2)),c=8,d=28;return this._huePicker=new cc.ControlHuePicker(a,cc.p(b.x+c,b.y+c)),this._colourPicker=new cc.ControlSaturationBrightnessPicker(a,cc.p(b.x+d,b.y+d)),this._huePicker.addTargetWithActionForControlEvents(this,this.hueSliderValueChanged,cc.CONTROL_EVENT_VALUECHANGED),this._colourPicker.addTargetWithActionForControlEvents(this,this.colourSliderValueChanged,cc.CONTROL_EVENT_VALUECHANGED),this._updateHueAndControlPicker(),this.addChild(this._huePicker),this.addChild(this._colourPicker),this.setContentSize(this._background.getContentSize()),!0}return!1},_updateControlPicker:function(){this._huePicker.setHue(this._hsv.h),this._colourPicker.updateWithHSV(this._hsv)},_updateHueAndControlPicker:function(){this._huePicker.setHue(this._hsv.h),this._colourPicker.updateWithHSV(this._hsv),this._colourPicker.updateDraggerWithHSV(this._hsv)},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a),null!==this._huePicker&&this._huePicker.setEnabled(a),this._colourPicker&&this._colourPicker.setEnabled(a)},onTouchBegan:function(){return!1}});var _p=cc.ControlColourPicker.prototype;_p.background,cc.defineGetterSetter(_p,"background",_p.getBackground),_p=null,cc.ControlColourPicker.create=function(){return new cc.ControlColourPicker};var res=res||{};res.CCControlColourPickerSpriteSheet_plist=res.CCControlColourPickerSpriteSheet_plist||"res/extensions/CCControlColourPickerSpriteSheet.plist",res.CCControlColourPickerSpriteSheet_png=res.CCControlColourPickerSpriteSheet_png||"res/extensions/CCControlColourPickerSpriteSheet.png",cc.SLIDER_MARGIN_H=24,cc.SLIDER_MARGIN_V=8,cc.ControlSlider=cc.Control.extend({_value:0,_minimumValue:0,_maximumValue:0,_minimumAllowedValue:0,_maximumAllowedValue:0,_thumbSprite:null,_progressSprite:null,_backgroundSprite:null,_className:"ControlSlider",ctor:function(a,b,c){if(cc.Control.prototype.ctor.call(this),void 0!=c){var d=new cc.Sprite(a),e=new cc.Sprite(b),f=new cc.Sprite(c);this.initWithSprites(d,e,f)}},getValue:function(){return this._value},setValue:function(a){a=Math.max(a,this._minimumValue),a=Math.min(a,this._maximumValue),this._value=a,this.needsLayout(),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},getMinimumValue:function(){return this._minimumValue},setMinimumValue:function(a){this._minimumValue=a,this._minimumAllowedValue=a,this._minimumValue>=this._maximumValue&&(this._maximumValue=this._minimumValue+1),this.setValue(this._value)},getMaximumValue:function(){return this._maximumValue},setMaximumValue:function(a){this._maximumValue=a,this._maximumAllowedValue=a,this._maximumValue<=this._minimumValue&&(this._minimumValue=this._maximumValue-1),this.setValue(this._value)},isTouchInside:function(a){var b=a.getLocation();b=this.getParent().convertToNodeSpace(b);var c=this.getBoundingBox();return c.width+=this._thumbSprite.getContentSize().width,c.x-=this._thumbSprite.getContentSize().width/2,cc.rectContainsPoint(c,b)},locationFromTouch:function(a){var b=a.getLocation();return b=this.convertToNodeSpace(b),b.x<0?b.x=0:b.x>this._backgroundSprite.getContentSize().width&&(b.x=this._backgroundSprite.getContentSize().width),b},getMinimumAllowedValue:function(){return this._minimumAllowedValue},setMinimumAllowedValue:function(a){this._minimumAllowedValue=a},getMaximumAllowedValue:function(){return this._maximumAllowedValue},setMaximumAllowedValue:function(a){this._maximumAllowedValue=a},getThumbSprite:function(){return this._thumbSprite},getProgressSprite:function(){return this._progressSprite},getBackgroundSprite:function(){return this._backgroundSprite},initWithSprites:function(a,b,c){if(cc.Control.prototype.init.call(this)){this.ignoreAnchorPointForPosition(!1),this._backgroundSprite=a,this._progressSprite=b,this._thumbSprite=c;var d=cc.ControlUtils.CCRectUnion(a.getBoundingBox(),c.getBoundingBox());return this.setContentSize(d.width,d.height),this._backgroundSprite.setAnchorPoint(.5,.5),this._backgroundSprite.setPosition(d.width/2,d.height/2),this.addChild(this._backgroundSprite),this._progressSprite.setAnchorPoint(0,.5),this._progressSprite.setPosition(0,d.height/2), +this.addChild(this._progressSprite),this._thumbSprite.setPosition(0,d.height/2),this.addChild(this._thumbSprite),this._minimumValue=0,this._maximumValue=1,this.setValue(this._minimumValue),!0}return!1},setEnabled:function(a){cc.Control.prototype.setEnabled.call(this,a),this._thumbSprite&&this._thumbSprite.setOpacity(a?255:128)},sliderBegan:function(a){this.setSelected(!0),this._thumbSprite.setColor(cc.color.GRAY),this.setValue(this.valueForLocation(a))},sliderMoved:function(a){this.setValue(this.valueForLocation(a))},sliderEnded:function(a){this.isSelected()&&this.setValue(this.valueForLocation(this._thumbSprite.getPosition())),this._thumbSprite.setColor(cc.color.WHITE),this.setSelected(!1)},getTouchLocationInControl:function(a){var b=a.getLocation();return b=this.convertToNodeSpace(b),b.x<0?b.x=0:b.x>this._backgroundSprite.getContentSize().width+cc.SLIDER_MARGIN_H&&(b.x=this._backgroundSprite.getContentSize().width+cc.SLIDER_MARGIN_H),b},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;var c=this.locationFromTouch(a);return this.sliderBegan(c),!0},onTouchMoved:function(a,b){var c=this.locationFromTouch(a);this.sliderMoved(c)},onTouchEnded:function(a,b){this.sliderEnded(cc.p(0,0))},needsLayout:function(){var a=(this._value-this._minimumValue)/(this._maximumValue-this._minimumValue);this._thumbSprite.setPositionX(a*this._backgroundSprite.getContentSize().width);var b=this._progressSprite.getTextureRect();b=cc.rect(b.x,b.y,this._thumbSprite.getPositionX(),b.height),this._progressSprite.setTextureRect(b,this._progressSprite.isTextureRectRotated()),this._thumbSprite._renderCmd.transform(this._renderCmd)},valueForLocation:function(a){var b=a.x/this._backgroundSprite.getContentSize().width;return Math.max(Math.min(this._minimumValue+b*(this._maximumValue-this._minimumValue),this._maximumAllowedValue),this._minimumAllowedValue)}});var _p=cc.ControlSlider.prototype;_p.value,cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue),_p.minValue,cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue),_p.maxValue,cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue),_p.minAllowedValue,cc.defineGetterSetter(_p,"minAllowedValue",_p.getMinimumAllowedValue,_p.setMinimumAllowedValue),_p.maxAllowedValue,cc.defineGetterSetter(_p,"maxAllowedValue",_p.getMaximumAllowedValue,_p.setMaximumAllowedValue),_p.thumbSprite,cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite),_p.progressSprite,cc.defineGetterSetter(_p,"progressSprite",_p.getProgressSprite),_p.backgroundSprite,cc.defineGetterSetter(_p,"backgroundSprite",_p.getBackgroundSprite),_p=null,cc.ControlSlider.create=function(a,b,c){return new cc.ControlSlider(a,b,c)},cc.ControlSwitch=cc.Control.extend({_switchSprite:null,_initialTouchXPosition:0,_moved:!1,_on:!1,_className:"ControlSwitch",ctor:function(a,b,c,d,e,f){cc.Control.prototype.ctor.call(this),f&&this.initWithMaskSprite(a,b,c,d,e,f)},initWithMaskSprite:function(a,b,c,d,e,f){if(!a)throw new Error("cc.ControlSwitch.initWithMaskSprite(): maskSprite should be non-null.");if(!b)throw new Error("cc.ControlSwitch.initWithMaskSprite(): onSprite should be non-null.");if(!c)throw new Error("cc.ControlSwitch.initWithMaskSprite(): offSprite should be non-null.");if(!d)throw new Error("cc.ControlSwitch.initWithMaskSprite(): thumbSprite should be non-null.");return this.init()?(this._on=!0,this._switchSprite=new cc.ControlSwitchSprite,this._switchSprite.initWithMaskSprite(a,b,c,d,e,f),this._switchSprite.setPosition(this._switchSprite.getContentSize().width/2,this._switchSprite.getContentSize().height/2),this.addChild(this._switchSprite),this.ignoreAnchorPointForPosition(!1),this.setAnchorPoint(.5,.5),this.setContentSize(this._switchSprite.getContentSize()),!0):!1},setOn:function(a,b){b=b||!1,this._on=a;var c=this._on?this._switchSprite.getOnPosition():this._switchSprite.getOffPosition();b?this._switchSprite.runAction(new cc.ActionTween(.2,"sliderXPosition",this._switchSprite.getSliderXPosition(),c)):this._switchSprite.setSliderXPosition(c),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},isOn:function(){return this._on},hasMoved:function(){return this._moved},setEnabled:function(a){this._enabled=a,this._switchSprite.setOpacity(a?255:128)},locationFromTouch:function(a){var b=a.getLocation();return b=this.convertToNodeSpace(b)},onTouchBegan:function(a,b){if(!this.isTouchInside(a)||!this.isEnabled()||!this.isVisible())return!1;this._moved=!1;var c=this.locationFromTouch(a);return this._initialTouchXPosition=c.x-this._switchSprite.getSliderXPosition(),this._switchSprite.getThumbSprite().setColor(cc.color.GRAY),this._switchSprite.needsLayout(),!0},onTouchMoved:function(a,b){var c=this.locationFromTouch(a);c=cc.p(c.x-this._initialTouchXPosition,0),this._moved=!0,this._switchSprite.setSliderXPosition(c.x)},onTouchEnded:function(a,b){var c=this.locationFromTouch(a);this._switchSprite.getThumbSprite().setColor(cc.color.WHITE),this.hasMoved()?this.setOn(!(c.x=this._onPosition&&(a=this._onPosition),this._sliderXPosition=a,this.needsLayout()},getSliderXPosition:function(){return this._sliderXPosition},_getOnSideWidth:function(){return this._onSprite.getContentSize().width},_getOffSideWidth:function(){return this._offSprite.getContentSize().height},updateTweenAction:function(a,b){"sliderXPosition"===b&&this.setSliderXPosition(a)},setOnPosition:function(a){this._onPosition=a},getOnPosition:function(){return this._onPosition},setOffPosition:function(a){this._offPosition=a},getOffPosition:function(){return this._offPosition},setMaskTexture:function(a){this._stencil.setTexture(a)},getMaskTexture:function(){return this._stencil.getTexture()},setTextureLocation:function(a){this._textureLocation=a},getTextureLocation:function(){return this._textureLocation},setMaskLocation:function(a){this._maskLocation=a},getMaskLocation:function(){return this._maskLocation},setOnSprite:function(a){this._onSprite=a},getOnSprite:function(){return this._onSprite},setOffSprite:function(a){this._offSprite=a},getOffSprite:function(){return this._offSprite},setThumbSprite:function(a){this._thumbSprite=a},getThumbSprite:function(){return this._thumbSprite},setOnLabel:function(a){this._onLabel=a},getOnLabel:function(){return this._onLabel},setOffLabel:function(a){this._offLabel=a},getOffLabel:function(){return this._offLabel}});var _p=cc.ControlSwitchSprite.prototype;_p.sliderX,cc.defineGetterSetter(_p,"sliderX",_p.getSliderXPosition,_p.setSliderXPosition),_p.onPos,cc.defineGetterSetter(_p,"onPos",_p.getOnPosition,_p.setOnPosition),_p.offPos,cc.defineGetterSetter(_p,"offPos",_p.getOffPosition,_p.setOffPosition),_p.maskTexture,cc.defineGetterSetter(_p,"maskTexture",_p.getMaskTexture,_p.setMaskTexture),_p.maskPos,cc.defineGetterSetter(_p,"maskPos",_p.getMaskLocation,_p.setMaskLocation),_p.onSprite,cc.defineGetterSetter(_p,"onSprite",_p.getOnSprite,_p.setOnSprite),_p.offSprite,cc.defineGetterSetter(_p,"offSprite",_p.getOffSprite,_p.setOffSprite),_p.thumbSprite,cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite,_p.setThumbSprite),_p.onLabel,cc.defineGetterSetter(_p,"onLabel",_p.getOnLabel,_p.setOnLabel),_p.offLabel,cc.defineGetterSetter(_p,"offLabel",_p.getOffLabel,_p.setOffLabel),_p.onSideWidth,cc.defineGetterSetter(_p,"onSideWidth",_p._getOnSideWidth),_p.offSideWidth,cc.defineGetterSetter(_p,"offSideWidth",_p._getOffSideWidth),_p=null,cc.CONTROL_STEPPER_PARTMINUS=0,cc.CONTROL_STEPPER_PARTPLUS=1,cc.CONTROL_STEPPER_PARTNONE=2,cc.CONTROL_STEPPER_LABELCOLOR_ENABLED=cc.color(55,55,55),cc.CONTROL_STEPPER_LABELCOLOR_DISABLED=cc.color(147,147,147),cc.CONTROL_STEPPER_LABELFONT="CourierNewPSMT",cc.AUTOREPEAT_DELTATIME=.15,cc.AUTOREPEAT_INCREASETIME_INCREMENT=12,cc.ControlStepper=cc.Control.extend({_minusSprite:null,_plusSprite:null,_minusLabel:null,_plusLabel:null,_value:0,_continuous:!1,_autorepeat:!1,_wraps:!1,_minimumValue:0,_maximumValue:0,_stepValue:0,_touchInsideFlag:!1,_touchedPart:cc.CONTROL_STEPPER_PARTNONE,_autorepeatCount:0,_className:"ControlStepper",ctor:function(a,b){cc.Control.prototype.ctor.call(this),this._minusSprite=null,this._plusSprite=null,this._minusLabel=null,this._plusLabel=null,this._value=0,this._continuous=!1,this._autorepeat=!1,this._wraps=!1,this._minimumValue=0,this._maximumValue=0,this._stepValue=0,this._touchInsideFlag=!1,this._touchedPart=cc.CONTROL_STEPPER_PARTNONE,this._autorepeatCount=0,b&&this.initWithMinusSpriteAndPlusSprite(a,b)},initWithMinusSpriteAndPlusSprite:function(a,b){if(!a)throw new Error("cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Minus sprite should be non-null.");if(!b)throw new Error("cc.ControlStepper.initWithMinusSpriteAndPlusSprite(): Plus sprite should be non-null.");if(this.init()){this._autorepeat=!0,this._continuous=!0,this._minimumValue=0,this._maximumValue=100,this._value=0,this._stepValue=1,this._wraps=!1,this.ignoreAnchorPointForPosition(!1),this.setMinusSprite(a),this._minusSprite.setPosition(a.getContentSize().width/2,a.getContentSize().height/2),this.addChild(this._minusSprite),this.setMinusLabel(new cc.LabelTTF("-",cc.CONTROL_STEPPER_LABELFONT,40,cc.size(40,40),cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER)),this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_DISABLED),this._minusLabel.setPosition(this._minusSprite.getContentSize().width/2,this._minusSprite.getContentSize().height/2),this._minusSprite.addChild(this._minusLabel),this.setPlusSprite(b),this._plusSprite.setPosition(a.getContentSize().width+b.getContentSize().width/2,a.getContentSize().height/2),this.addChild(this._plusSprite),this.setPlusLabel(new cc.LabelTTF("+",cc.CONTROL_STEPPER_LABELFONT,40,cc.size(40,40),cc.TEXT_ALIGNMENT_CENTER,cc.VERTICAL_TEXT_ALIGNMENT_CENTER)),this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED),this._plusLabel.setPosition(this._plusSprite.getContentSize().width/2,this._plusSprite.getContentSize().height/2),this._plusSprite.addChild(this._plusLabel);var c=cc.ControlUtils.CCRectUnion(this._minusSprite.getBoundingBox(),this._plusSprite.getBoundingBox());return this.setContentSize(this._minusSprite.getContentSize().width+this._plusSprite.getContentSize().height,c.height),!0}return!1},setWraps:function(a){this._wraps=a,this._wraps&&(this._minusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED),this._plusLabel.setColor(cc.CONTROL_STEPPER_LABELCOLOR_ENABLED)),this.setValue(this._value)},getWraps:function(){return this._wraps},setMinimumValue:function(a){if(a>=this._maximumValue)throw new Error("cc.ControlStepper.setMinimumValue(): minimumValue should be numerically less than maximumValue.");this._minimumValue=a,this.setValue(this._value)},getMinimumValue:function(){return this._minimumValue},setMaximumValue:function(a){if(a<=this._minimumValue)throw new Error("cc.ControlStepper.setMaximumValue(): maximumValue should be numerically less than maximumValue.");this._maximumValue=a,this.setValue(this._value)},getMaximumValue:function(){return this._maximumValue},setValue:function(a){this.setValueWithSendingEvent(a,!0)},getValue:function(){return this._value},setStepValue:function(a){if(0>=a)throw new Error("cc.ControlStepper.setMaximumValue(): stepValue should be numerically greater than 0.");this._stepValue=a},getStepValue:function(){return this._stepValue},isContinuous:function(){return this._continuous},setValueWithSendingEvent:function(a,b){athis._maximumValue&&(a=this._wraps?this._minimumValue:this._maximumValue),this._value=a,this._wraps||(this._minusLabel.setColor(a===this._minimumValue?cc.CONTROL_STEPPER_LABELCOLOR_DISABLED:cc.CONTROL_STEPPER_LABELCOLOR_ENABLED),this._plusLabel.setColor(a===this._maximumValue?cc.CONTROL_STEPPER_LABELCOLOR_DISABLED:cc.CONTROL_STEPPER_LABELCOLOR_ENABLED)),b&&this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},startAutorepeat:function(){this._autorepeatCount=-1,this.schedule(this.update,cc.AUTOREPEAT_DELTATIME,cc.REPEAT_FOREVER,3*cc.AUTOREPEAT_DELTATIME)},stopAutorepeat:function(){this.unschedule(this.update)},update:function(a){this._autorepeatCount++,this._autorepeatCountthis._minimumValue?(this._touchedPart=cc.CONTROL_STEPPER_PARTMINUS,this._minusSprite.setColor(cc.color.GRAY),this._plusSprite.setColor(cc.color.WHITE)):a.x>=this._minusSprite.getContentSize().width&&this._valuethis._maximumValue&&(a=this._maximumValue),this._value=a;var b=(a-this._minimumValue)/(this._maximumValue-this._minimumValue);this._progressTimer.setPercentage(100*b),this._thumbSprite.setRotation(360*b),this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},getValue:function(){return this._value},setMinimumValue:function(a){this._minimumValue=a,this._minimumValue>=this._maximumValue&&(this._maximumValue=this._minimumValue+1),this.setValue(this._maximumValue)},getMinimumValue:function(){return this._minimumValue},setMaximumValue:function(a){this._maximumValue=a,this._maximumValue<=this._minimumValue&&(this._minimumValue=this._maximumValue-1),this.setValue(this._minimumValue)},getMaximumValue:function(){return this._maximumValue},isTouchInside:function(a){var b=this.getTouchLocation(a),c=this.distanceBetweenPointAndPoint(this._progressTimer.getPosition(),b);return c180?b-=360:-180>b&&(b+=360),this.setValue(this._value+b/360*(this._maximumValue-this._minimumValue)),this._previousLocation=a},potentiometerEnded:function(a){this.getThumbSprite().setColor(cc.color.WHITE),this.setSelected(!1)},setThumbSprite:function(a){this._thumbSprite=a},getThumbSprite:function(){return this._thumbSprite},setProgressTimer:function(a){this._progressTimer=a},getProgressTimer:function(){return this._progressTimer},setPreviousLocation:function(a){this._previousLocation=a},getPreviousLocation:function(){return this._previousLocation}});var _p=cc.ControlPotentiometer.prototype;_p.value,cc.defineGetterSetter(_p,"value",_p.getValue,_p.setValue),_p.minValue,cc.defineGetterSetter(_p,"minValue",_p.getMinimumValue,_p.setMinimumValue),_p.maxValue,cc.defineGetterSetter(_p,"maxValue",_p.getMaximumValue,_p.setMaximumValue),_p.progressTimer,cc.defineGetterSetter(_p,"progressTimer",_p.getProgressTimer,_p.setProgressTimer),_p.thumbSprite,cc.defineGetterSetter(_p,"thumbSprite",_p.getThumbSprite,_p.setThumbSprite),_p.prevLocation,cc.defineGetterSetter(_p,"prevLocation",_p.getPreviousLocation,_p.setPreviousLocation),_p=null,cc.ControlPotentiometer.create=function(a,b,c){return new cc.ControlPotentiometer(a,b,c)},cc.SCROLLVIEW_DIRECTION_NONE=-1,cc.SCROLLVIEW_DIRECTION_HORIZONTAL=0,cc.SCROLLVIEW_DIRECTION_VERTICAL=1,cc.SCROLLVIEW_DIRECTION_BOTH=2;var SCROLL_DEACCEL_RATE=.95,SCROLL_DEACCEL_DIST=1,BOUNCE_DURATION=.15,INSET_RATIO=.2,MOVE_INCH=7/160,BOUNCE_BACK_FACTOR=.35;cc.convertDistanceFromPointToInch=function(a){var b=cc.view,c=(b.getScaleX()+b.getScaleY())/2;return a*c/160},cc.ScrollViewDelegate=cc.Class.extend({scrollViewDidScroll:function(a){},scrollViewDidZoom:function(a){}}),cc.ScrollView=cc.Layer.extend({_zoomScale:0,_minZoomScale:0,_maxZoomScale:0,_delegate:null,_direction:cc.SCROLLVIEW_DIRECTION_BOTH,_dragging:!1,_contentOffset:null,_container:null,_touchMoved:!1,_maxInset:null,_minInset:null,_bounceable:!1,_clippingToBounds:!1,_scrollDistance:null,_touchPoint:null,_touchLength:0,_touches:null,_viewSize:null,_minScale:0,_maxScale:0,_parentScissorRect:null,_scissorRestored:!1,_tmpViewRect:null,_touchListener:null,_className:"ScrollView",ctor:function(a,b){cc.Layer.prototype.ctor.call(this),this._contentOffset=cc.p(0,0),this._maxInset=cc.p(0,0),this._minInset=cc.p(0,0),this._scrollDistance=cc.p(0,0),this._touchPoint=cc.p(0,0),this._touches=[],this._viewSize=cc.size(0,0),this._parentScissorRect=new cc.Rect(0,0,0,0),this._tmpViewRect=new cc.Rect(0,0,0,0),void 0!=b?this.initWithViewSize(a,b):this.initWithViewSize(cc.size(200,200),null)},init:function(){return this.initWithViewSize(cc.size(200,200),null)},initWithViewSize:function(a,b){var c=cc.p(0,0);return cc.Layer.prototype.init.call(this)?(b||this._container||(b=new cc.Layer),b&&this.setContainer(b),this.setViewSize(a),this.setTouchEnabled(!0),this._touches.length=0,this._delegate=null,this._bounceable=!0,this._clippingToBounds=!0,this._direction=cc.SCROLLVIEW_DIRECTION_BOTH,this._container.setPosition(c),this._touchLength=0,this._minScale=this._maxScale=1,!0):!1},setContentOffset:function(a,b){if(b)return void this.setContentOffsetInDuration(a,BOUNCE_DURATION);if(!this._bounceable){var c=this.minContainerOffset(),d=this.maxContainerOffset();a.x=Math.max(c.x,Math.min(d.x,a.x)),a.y=Math.max(c.y,Math.min(d.y,a.y))}this._container.setPosition(a);var e=this._delegate;null!=e&&e.scrollViewDidScroll&&e.scrollViewDidScroll(this)},getContentOffset:function(){var a=this._container.getPosition();return cc.p(a.x,a.y)},setContentOffsetInDuration:function(a,b){var c=cc.moveTo(b,a),d=cc.callFunc(this._stoppedAnimatedScroll,this);this._container.runAction(cc.sequence(c,d)),this.schedule(this._performedAnimatedScroll)},setZoomScale:function(a,b){if(b)return void this.setZoomScaleInDuration(a,BOUNCE_DURATION);var c=this._container;if(c.getScale()!==a){var d,e,f;if(0===this._touchLength){var g=this._viewSize;f=cc.p(.5*g.width,.5*g.height),f=this.convertToWorldSpace(f)}else f=this._touchPoint;d=c.convertToNodeSpace(f),c.setScale(Math.max(this._minScale,Math.min(this._maxScale,a))),e=c.convertToWorldSpace(d);var h=cc.pSub(f,e);this._delegate&&this._delegate.scrollViewDidZoom&&this._delegate.scrollViewDidZoom(this),this.setContentOffset(cc.pAdd(c.getPosition(),h))}},getZoomScale:function(){return this._container.getScale()},setZoomScaleInDuration:function(a,b){if(b>0){var c=this._container.getScale();if(c!==a){var d=cc.actionTween(b,"zoomScale",c,a);this.runAction(d)}}else this.setZoomScale(a)},minContainerOffset:function(){var a=this._container,b=a.getContentSize(),c=this._viewSize;return cc.p(c.width-b.width*a.getScaleX(),c.height-b.height*a.getScaleY())},maxContainerOffset:function(){return cc.p(0,0)},isNodeVisible:function(a){var b=this.getContentOffset(),c=this.getViewSize(),d=this.getZoomScale(),e=cc.rect(-b.x/d,-b.y/d,c.width/d,c.height/d);return cc.rectIntersectsRect(e,a.getBoundingBox())},pause:function(a){this._container.pause();for(var b=this._container.getChildren(),c=0;cc;c++)b[c].resume();this._container.resume(),this._super()},isDragging:function(){return this._dragging},isTouchMoved:function(){return this._touchMoved},isBounceable:function(){return this._bounceable},setBounceable:function(a){this._bounceable=a},getViewSize:function(){return this._viewSize},setViewSize:function(a){this._viewSize=a,cc.Node.prototype.setContentSize.call(this,a)},getContainer:function(){return this._container},setContainer:function(a){a&&(this.removeAllChildren(!0),this._container=a,a.ignoreAnchorPointForPosition(!1),a.setAnchorPoint(0,0),this.addChild(a),this.setViewSize(this._viewSize))},getDirection:function(){return this._direction},setDirection:function(a){this._direction=a},getDelegate:function(){return this._delegate},setDelegate:function(a){this._delegate=a},onTouchBegan:function(a,b){for(var c=this;null!=c;c=c.parent)if(!c.isVisible())return!1;var d=this._getViewRect(),e=this._container,f=e.convertToWorldSpace(e.convertTouchToNodeSpace(a)),g=this._touches;return g.length>2||this._touchMoved||!cc.rectContainsPoint(d,f)?!1:(g.push(a),1===g.length?(this._touchPoint=this.convertTouchToNodeSpace(a),this._touchMoved=!1,this._dragging=!0,this._scrollDistance.x=0,this._scrollDistance.y=0,this._touchLength=0):2===g.length&&(this._touchPoint=cc.pMidpoint(this.convertTouchToNodeSpace(g[0]),this.convertTouchToNodeSpace(g[1])),this._touchLength=cc.pDistance(e.convertTouchToNodeSpace(g[0]),e.convertTouchToNodeSpace(g[1])),this._dragging=!1),!0)},onTouchMoved:function(a,b){if(this.isVisible())if(this.setNodeDirty(),1===this._touches.length&&this._dragging){this._touchMoved=!0;var c,d=(this._getViewRect(),this.convertTouchToNodeSpace(a)),e=cc.pSub(d,this._touchPoint),f=0,g=this._direction;if(g===cc.SCROLLVIEW_DIRECTION_VERTICAL)f=e.y,c=this._container.getPositionY(),this.minContainerOffset().y<=c&&c<=this.maxContainerOffset().y||(e.y*=BOUNCE_BACK_FACTOR);else if(g===cc.SCROLLVIEW_DIRECTION_HORIZONTAL)f=e.x,c=this._container.getPositionX(),this.minContainerOffset().x<=c&&c<=this.maxContainerOffset().x||(e.x*=BOUNCE_BACK_FACTOR);else{f=Math.sqrt(e.x*e.x+e.y*e.y),c=this._container.getPositionY();var h=this.minContainerOffset(),i=this.maxContainerOffset();h.y<=c&&c<=i.y||(e.y*=BOUNCE_BACK_FACTOR),c=this._container.getPositionX(),h.x<=c&&c<=i.x||(e.x*=BOUNCE_BACK_FACTOR)}if(!this._touchMoved&&Math.abs(cc.convertDistanceFromPointToInch(f))b.y||gb.x||fc&&(a.x+=b.width*c,c=-c),0>d&&(a.y+=b.height*d,d=-d);var f=this._tmpViewRect;return f.x=a.x,f.y=a.y,f.width=b.width*c,f.height=b.height*d,f},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ScrollView.CanvasRenderCmd(this):new cc.ScrollView.WebGLRenderCmd(this)}});var _p=cc.ScrollView.prototype;_p.minOffset,cc.defineGetterSetter(_p,"minOffset",_p.minContainerOffset),_p.maxOffset,cc.defineGetterSetter(_p,"maxOffset",_p.maxContainerOffset),_p.bounceable,cc.defineGetterSetter(_p,"bounceable",_p.isBounceable,_p.setBounceable),_p.viewSize,cc.defineGetterSetter(_p,"viewSize",_p.getViewSize,_p.setViewSize),_p.container,cc.defineGetterSetter(_p,"container",_p.getContainer,_p.setContainer),_p.direction,cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection),_p.delegate,cc.defineGetterSetter(_p,"delegate",_p.getDelegate,_p.setDelegate),_p.clippingToBounds,cc.defineGetterSetter(_p,"clippingToBounds",_p.isClippingToBounds,_p.setClippingToBounds),_p=null,cc.ScrollView.create=function(a,b){return new cc.ScrollView(a,b)},function(){cc.ScrollView.CanvasRenderCmd=function(a){cc.Layer.CanvasRenderCmd.call(this,a),this._needDraw=!1,this.startCmd=new cc.CustomRenderCmd(this,this._startCmd),this.endCmd=new cc.CustomRenderCmd(this,this._endCmd)};var a=cc.ScrollView.CanvasRenderCmd.prototype=Object.create(cc.Layer.CanvasRenderCmd.prototype);a.constructor=cc.ScrollView.CanvasRenderCmd,a._startCmd=function(a,b,c){var d=this._node,e=a||cc._renderContext,f=e.getContext();if(e.save(),d._clippingToBounds){this._scissorRestored=!1,e.setTransform(this._worldTransform,b,c);var g=d.getScaleX(),h=d.getScaleY(),i=d._viewSize.width*g*b,j=d._viewSize.height*h*c;f.beginPath(),f.rect(0,0,i,-j),f.closePath(),f.clip()}},a._endCmd=function(a){a=a||cc._renderContext,a.restore()},a.visit=function(a){var b=this._node;if(b._visible){var c,d,e=b._children;if(this.transform(a),cc.renderer.pushRenderCommand(this.startCmd),e&&e.length>0)for(d=e.length,b.sortAllChildren(),c=0;d>c;c++)e[c]._renderCmd.visit(this);cc.renderer.pushRenderCommand(this.endCmd)}}}(),cc.SortableObject=cc.Class.extend({setObjectID:function(a){},getObjectID:function(){return 0}}),cc.SortedObject=cc.SortableObject.extend({_objectID:0,ctor:function(){this._objectID=0},setObjectID:function(a){this._objectID=a},getObjectID:function(){return this._objectID}});var _compareObject=function(a,b){return a.getObjectID()-b.getObjectID()};cc.ArrayForObjectSorting=cc.Class.extend({_saveObjectArr:null,ctor:function(){this._saveObjectArr=[]},insertSortedObject:function(a){if(!a)throw new Error("cc.ArrayForObjectSorting.insertSortedObject(): addObject should be non-null.");var b=this.indexOfSortedObject(a);this.insertObject(a,b)},removeSortedObject:function(a){if(0!==this.count()){var b=this.indexOfSortedObject(a);if(b=c&&h>d)break;c=h,b++}else b=cc.INVALID_INDEX;return b},count:function(){return this._saveObjectArr.length},lastObject:function(){var a=this._saveObjectArr;return 0===a.length?null:a[a.length-1]},objectAtIndex:function(a){return this._saveObjectArr[a]},addObject:function(a){this._saveObjectArr.push(a),this._saveObjectArr.sort(_compareObject)},removeObjectAtIndex:function(a){this._saveObjectArr.splice(a,1),this._saveObjectArr.sort(_compareObject)},insertObject:function(a,b){this._saveObjectArr.splice(b,0,a),this._saveObjectArr.sort(_compareObject)}}),cc.TABLEVIEW_FILL_TOPDOWN=0,cc.TABLEVIEW_FILL_BOTTOMUP=1,cc.TableViewCell=cc.Node.extend({_idx:0,_className:"TableViewCell",getIdx:function(){return this._idx},setIdx:function(a){this._idx=a},reset:function(){this._idx=cc.INVALID_INDEX},setObjectID:function(a){this._idx=a},getObjectID:function(){return this._idx}});var _p=cc.TableViewCell.prototype;_p.objectId,cc.defineGetterSetter(_p,"objectId",_p.getObjectID,_p.setObjectID),_p=null,cc.TableViewDelegate=cc.ScrollViewDelegate.extend({tableCellTouched:function(a,b){},tableCellHighlight:function(a,b){},tableCellUnhighlight:function(a,b){},tableCellWillRecycle:function(a,b){}}),cc.TableViewDataSource=cc.Class.extend({tableCellSizeForIndex:function(a,b){return this.cellSizeForTable(a)},cellSizeForTable:function(a){return cc.size(0,0)},tableCellAtIndex:function(a,b){return null},numberOfCellsInTableView:function(a){return 0}}),cc.TableView=cc.ScrollView.extend({_vOrdering:null,_indices:null,_cellsFreed:null,_dataSource:null,_tableViewDelegate:null,_oldDirection:null,_cellsPositions:null,_touchedCell:null,ctor:function(a,b,c){cc.ScrollView.prototype.ctor.call(this),this._oldDirection=cc.SCROLLVIEW_DIRECTION_NONE,this._cellsPositions=[],this.initWithViewSize(b,c),this.setDataSource(a),this._updateCellPositions(),this._updateContentSize()},__indexFromOffset:function(a){var b,c=0,d=this._dataSource.numberOfCellsInTableView(this)-1;switch(this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:b=a.x;break;default:b=a.y}for(var e=this._cellsPositions;d>=c;){var f=0|c+(d-c)/2,g=e[f],h=e[f+1];if(b>=g&&h>=b)return f;g>b?d=f-1:c=f+1}return 0>=c?0:-1},_indexFromOffset:function(a){var b={x:a.x,y:a.y},c=this._dataSource,d=c.numberOfCellsInTableView(this)-1;this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(b.y=this.getContainer().getContentSize().height-b.y);var e=this.__indexFromOffset(b);return-1!==e&&(e=Math.max(0,e),e>d&&(e=cc.INVALID_INDEX)),e},__offsetFromIndex:function(a){var b;switch(this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:b=cc.p(this._cellsPositions[a],0);break;default:b=cc.p(0,this._cellsPositions[a])}return b},_offsetFromIndex:function(a){var b=this.__offsetFromIndex(a),c=this._dataSource.tableCellSizeForIndex(this,a);return this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(b.y=this.getContainer().getContentSize().height-b.y-c.height),b},_updateCellPositions:function(){var a=this._dataSource.numberOfCellsInTableView(this),b=this._cellsPositions;if(a>0){for(var c,d=0,e=this._dataSource,f=0;a>f;f++)switch(b[f]=d,c=e.tableCellSizeForIndex(this,f),this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:d+=c.width;break;default:d+=c.height}this._cellsPositions[a]=d}},_updateContentSize:function(){var a=cc.size(0,0),b=this._dataSource.numberOfCellsInTableView(this);if(b>0){var c=this._cellsPositions[b];switch(this.getDirection()){case cc.SCROLLVIEW_DIRECTION_HORIZONTAL:a=cc.size(c,this._viewSize.height);break;default:a=cc.size(this._viewSize.width,c)}}this.setContentSize(a),this._oldDirection!==this._direction&&(this._direction===cc.SCROLLVIEW_DIRECTION_HORIZONTAL?this.setContentOffset(cc.p(0,0)):this.setContentOffset(cc.p(0,this.minContainerOffset().y)),this._oldDirection=this._direction)},_moveCellOutOfSight:function(a){this._tableViewDelegate&&this._tableViewDelegate.tableCellWillRecycle&&this._tableViewDelegate.tableCellWillRecycle(this,a),this._cellsFreed.addObject(a),this._cellsUsed.removeSortedObject(a),cc.arrayRemoveObject(this._indices,a.getIdx()),a.reset(),a.getParent()===this.getContainer()&&this.getContainer().removeChild(a,!0)},_setIndexForCell:function(a,b){b.setAnchorPoint(0,0),b.setPosition(this._offsetFromIndex(a)),b.setIdx(a)},_addCellIfNecessary:function(a){a.getParent()!==this.getContainer()&&this.getContainer().addChild(a),this._cellsUsed.insertSortedObject(a);var b=this._indices,c=a.getIdx();-1===b.indexOf(c)&&(b.push(c),b.sort(function(a,b){return a-b}))},getDataSource:function(){return this._dataSource},setDataSource:function(a){this._dataSource=a},getDelegate:function(){return this._tableViewDelegate},setDelegate:function(a){this._tableViewDelegate=a},setVerticalFillOrder:function(a){this._vOrdering!==a&&(this._vOrdering=a,this._cellsUsed.count()>0&&this.reloadData())},getVerticalFillOrder:function(){return this._vOrdering},initWithViewSize:function(a,b){return cc.ScrollView.prototype.initWithViewSize.call(this,a,b)?(this._cellsUsed=new cc.ArrayForObjectSorting,this._cellsFreed=new cc.ArrayForObjectSorting,this._indices=[],this._tableViewDelegate=null,this._vOrdering=cc.TABLEVIEW_FILL_BOTTOMUP,this.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL),cc.ScrollView.prototype.setDelegate.call(this,this),!0):!1},updateCellAtIndex:function(a){if(!(a===cc.INVALID_INDEX||a>this._dataSource.numberOfCellsInTableView(this)-1)){var b=this.cellAtIndex(a);b&&this._moveCellOutOfSight(b),b=this._dataSource.tableCellAtIndex(this,a),this._setIndexForCell(a,b),this._addCellIfNecessary(b)}},insertCellAtIndex:function(a){if(!(a===cc.INVALID_INDEX||a>this._dataSource.numberOfCellsInTableView(this)-1)){var b,c=this._cellsUsed,d=c.objectWithObjectID(a);if(d){b=c.indexOfSortedObject(d);for(var e=b;ethis._dataSource.numberOfCellsInTableView(this)-1)){var b=this.cellAtIndex(a);if(b){var c=this._cellsUsed,d=c.indexOfSortedObject(b);this._moveCellOutOfSight(b),cc.arrayRemoveObject(this._indices,a),this._updateCellPositions();for(var e=c.count()-1;e>d;e--)b=c.objectAtIndex(e),this._setIndexForCell(b.getIdx()-1,b)}}},reloadData:function(){this._oldDirection=cc.SCROLLVIEW_DIRECTION_NONE;for(var a=this._cellsUsed,b=this._cellsFreed,c=this.getContainer(),d=0,e=a.count();e>d;d++){var f=a.objectAtIndex(d);this._tableViewDelegate&&this._tableViewDelegate.tableCellWillRecycle&&this._tableViewDelegate.tableCellWillRecycle(this,f),b.addObject(f),f.reset(),f.getParent()===c&&c.removeChild(f,!0)}this._indices=[],this._cellsUsed=new cc.ArrayForObjectSorting,this._updateCellPositions(),this._updateContentSize(),this._dataSource.numberOfCellsInTableView(this)>0&&this.scrollViewDidScroll(this)},dequeueCell:function(){if(0===this._cellsFreed.count())return null;var a=this._cellsFreed.objectAtIndex(0);return this._cellsFreed.removeObjectAtIndex(0),a},cellAtIndex:function(a){var b=this._indices.indexOf(a);return-1===b?null:this._cellsUsed.objectWithObjectID(a)},scrollViewDidScroll:function(a){var b=this._dataSource,c=b.numberOfCellsInTableView(this);if(0!==c){null!==this._tableViewDelegate&&this._tableViewDelegate.scrollViewDidScroll&&this._tableViewDelegate.scrollViewDidScroll(this);var d=0,e=this._viewSize,f=this.getContainer(),g=this.getContentOffset();g.x*=-1,g.y*=-1;var h=Math.max(c-1,0);this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN&&(g.y=g.y+e.height/f.getScaleY());var i=this._indexFromOffset(g);i===cc.INVALID_INDEX&&(i=c-1),this._vOrdering===cc.TABLEVIEW_FILL_TOPDOWN?g.y-=e.height/f.getScaleY():g.y+=e.height/f.getScaleY(),g.x+=e.width/f.getScaleX();var j=this._indexFromOffset(g);j===cc.INVALID_INDEX&&(j=c-1);var k,l=this._cellsUsed;if(l.count()>0)for(k=l.objectAtIndex(0),d=k.getIdx();i>d&&(this._moveCellOutOfSight(k),l.count()>0);)k=l.objectAtIndex(0),d=k.getIdx();if(l.count()>0)for(k=l.lastObject(),d=k.getIdx();h>=d&&d>j&&(this._moveCellOutOfSight(k),l.count()>0);)k=l.lastObject(),d=k.getIdx();for(var m=this._indices,n=i;j>=n;n++)-1===m.indexOf(n)&&this.updateCellAtIndex(n)}},scrollViewDidZoom:function(a){},onTouchEnded:function(a,b){if(this.isVisible()){if(this._touchedCell){var c=this.getBoundingBox(),d=cc.p(c.x,c.y);d=this._parent.convertToWorldSpace(d),c.x=d.x,c.y=d.y;var e=this._tableViewDelegate;cc.rectContainsPoint(c,a.getLocation())&&null!==e&&(e.tableCellUnhighlight&&e.tableCellUnhighlight(this,this._touchedCell),e.tableCellTouched&&e.tableCellTouched(this,this._touchedCell)),this._touchedCell=null}cc.ScrollView.prototype.onTouchEnded.call(this,a,b)}},onTouchBegan:function(a,b){for(var c=this;null!=c;c=c.parent)if(!c.isVisible())return!1;var d=cc.ScrollView.prototype.onTouchBegan.call(this,a,b);if(1===this._touches.length){var e,f;f=this.getContainer().convertTouchToNodeSpace(a),e=this._indexFromOffset(f),e===cc.INVALID_INDEX?this._touchedCell=null:this._touchedCell=this.cellAtIndex(e),this._touchedCell&&null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellHighlight&&this._tableViewDelegate.tableCellHighlight(this,this._touchedCell)}else this._touchedCell&&(null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellUnhighlight&&this._tableViewDelegate.tableCellUnhighlight(this,this._touchedCell),this._touchedCell=null);return d},onTouchMoved:function(a,b){cc.ScrollView.prototype.onTouchMoved.call(this,a,b),this._touchedCell&&this.isTouchMoved()&&(null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellUnhighlight&&this._tableViewDelegate.tableCellUnhighlight(this,this._touchedCell),this._touchedCell=null)},onTouchCancelled:function(a,b){cc.ScrollView.prototype.onTouchCancelled.call(this,a,b),this._touchedCell&&(null!==this._tableViewDelegate&&this._tableViewDelegate.tableCellUnhighlight&&this._tableViewDelegate.tableCellUnhighlight(this,this._touchedCell),this._touchedCell=null)}});var _p=cc.TableView.prototype;_p.dataSource,cc.defineGetterSetter(_p,"dataSource",_p.getDataSource,_p.setDataSource),_p.delegate,cc.defineGetterSetter(_p,"delegate",_p.getDelegate,_p.setDelegate),_p.verticalFillOrder,cc.defineGetterSetter(_p,"verticalFillOrder",_p.getVerticalFillOrder,_p.setVerticalFillOrder),_p=null,cc.TableView.create=function(a,b,c){return new cc.TableView(a,b,c)};!function(){cc.ScrollView.WebGLRenderCmd=function(a){cc.Layer.WebGLRenderCmd.call(this,a),this._needDraw=!1,this.startCmd=new cc.CustomRenderCmd(this,this._startCmd),this.endCmd=new cc.CustomRenderCmd(this,this._endCmd)};var a=cc.ScrollView.WebGLRenderCmd.prototype=Object.create(cc.Layer.WebGLRenderCmd.prototype);a.constructor=cc.ScrollView.WebGLRenderCmd,a._startCmd=function(){var a=this._node,b=cc.view,c=a._getViewRect();if(b.isScissorEnabled()){if(a._scissorRestored=!0,a._parentScissorRect=b.getScissorRect(),cc.rectIntersection(c,a._parentScissorRect)){var d=a._parentScissorRect,e=Math.max(c.x,d.x),f=Math.max(c.y,d.y),g=Math.min(c.x+c.width,d.x+d.width),h=Math.min(c.y+c.height,d.y+d.height);b.setScissorInPoints(e,f,g-e,h-f)}}else{var i=cc._renderContext;i.enable(i.SCISSOR_TEST),b.setScissorInPoints(c.x,c.y,c.width,c.height)}},a._endCmd=function(){var a=this._node;if(a._scissorRestored){var b=a._parentScissorRect;cc.view.setScissorInPoints(b.x,b.y,b.width,b.height)}else{var c=cc._renderContext;c.disable(c.SCISSOR_TEST)}},a.visit=function(a){var b=this._node;if(b._visible){var c,d,e,f=b._children;if(cc.kmGLPushMatrix(),this.transform(a),b._clippingToBounds&&cc.renderer.pushRenderCommand(this.startCmd),f&&f.length>0){for(e=f.length,c=0;e>c&&(d=f[c],d&&d._localZOrder<0);c++)d._renderCmd.visit();for(;e>c;c++)f[c]._renderCmd.visit()}b._clippingToBounds&&cc.renderer.pushRenderCommand(this.endCmd),this._dirtyFlag=0,cc.kmGLPopMatrix()}}}();cc.DOM={},cc.DOM._addMethods=function(a){for(var b in cc.DOM.methods)a[b]=cc.DOM.methods[b];cc.defineGetterSetter(a,"x",a.getPositionX,a.setPositionX),cc.defineGetterSetter(a,"y",a.getPositionY,a.setPositionY),cc.defineGetterSetter(a,"width",a._getWidth,a._setWidth),cc.defineGetterSetter(a,"height",a._getHeight,a._setHeight),cc.defineGetterSetter(a,"anchorX",a._getAnchorX,a._setAnchorX),cc.defineGetterSetter(a,"anchorY",a._getAnchorY,a._setAnchorY),cc.defineGetterSetter(a,"scale",a.getScale,a.setScale),cc.defineGetterSetter(a,"scaleX",a.getScaleX,a.setScaleX),cc.defineGetterSetter(a,"scaleY",a.getScaleY,a.setScaleY),cc.defineGetterSetter(a,"rotation",a.getRotation,a.setRotation),cc.defineGetterSetter(a,"skewX",a.getSkewX,a.setSkewX),cc.defineGetterSetter(a,"skewY",a.getSkewY,a.setSkewY),cc.defineGetterSetter(a,"visible",a.isVisible,a.setVisible),cc.defineGetterSetter(a,"parent",a.getParent,a.setParent),cc.defineGetterSetter(a,"opacity",a.getOpacity,a.setOpacity)},cc.DOM.methods={setPosition:function(a,b){void 0===b?(this._position.x=a.x,this._position.y=a.y):(this._position.x=a,this._position.y=b),this.setNodeDirty(),this.dom.translates(this._position.x,-this._position.y)},setPositionY:function(a){this._position.y=a,this.setNodeDirty(),this.dom.translates(this._position.x,-this._position.y)},setPositionX:function(a){this._position.x=a,this.setNodeDirty(),this.dom.translates(this._position.x,-this._position.y)},setScale:function(a,b){this._scaleX=a,this._scaleY=b||a,this.setNodeDirty(),this.dom.resize(this._scaleX,this._scaleY)},setScaleX:function(a){this._scaleX=a,this.setNodeDirty(),this.dom.resize(this._scaleX,this._scaleY)},setScaleY:function(a){this._scaleY=a,this.setNodeDirty(),this.dom.resize(this._scaleX,this._scaleY)},setAnchorPoint:function(a,b){var c=this._renderCmd,d=this._anchorPoint;void 0===b?(d.x=a.x,d.y=a.y):(d.x=a,d.y=b);var e=c._anchorPointInPoints,f=this._contentSize;e.x=f.width*d.x,e.y=f.height*d.y,this.dom.style[cc.$.pfx+"TransformOrigin"]=""+e.x+"px "+-e.y+"px",this.ignoreAnchor?(this.dom.style.marginLeft=0,this.dom.style.marginBottom=0):(this.dom.style.marginLeft=this.isToggler?0:-e.x+"px",this.dom.style.marginBottom=-e.y+"px"),this.setNodeDirty()},_setAnchorX:function(a){var b=this._anchorPoint,c=this._renderCmd;if(a!==b.x){b.x=a;var d=c._anchorPointInPoints,e=this._contentSize;d.x=e.width*b.x,this.dom.style[cc.$.pfx+"TransformOrigin"]=""+d.x+"px "+-d.y+"px",this.ignoreAnchor?(this.dom.style.marginLeft=0,this.dom.style.marginBottom=0):this.dom.style.marginLeft=this.isToggler?0:-d.x+"px",this.setNodeDirty()}},_setAnchorY:function(a){var b=this._anchorPoint,c=this._renderCmd;if(a!==b.y){b.y=a;var d=c._anchorPointInPoints,e=this._contentSize;d.y=e.height*b.y,this.dom.style[cc.$.pfx+"TransformOrigin"]=""+d.x+"px "+-d.y+"px",this.ignoreAnchor?(this.dom.style.marginLeft=0,this.dom.style.marginBottom=0):this.dom.style.marginBottom=-d.y+"px",this.setNodeDirty()}},setContentSize:function(a,b){var c=this._renderCmd,d=this._contentSize;void 0===b?(d.width=a.width,d.height=a.height):(d.width=a,d.height=b);var e=c._anchorPointInPoints,f=this._anchorPoint;e.x=d.width*f.x,e.y=d.height*f.y,this.dom.width=d.width,this.dom.height=d.height,this.setAnchorPoint(this.getAnchorPoint()),this.canvas&&(this.canvas.width=d.width,this.canvas.height=d.height),this.setNodeDirty(),this.redraw()},_setWidth:function(a){var b=this._contentSize,c=this._renderCmd;if(a!==b.width){b.width=a;var d=c._anchorPointInPoints,e=this._anchorPoint;d.x=b.width*e.x,this.dom.width=b.width,this.anchorX=e.x,this.canvas&&(this.canvas.width=b.width),this.setNodeDirty(),this.redraw()}},_setHeight:function(a){var b=this._contentSize,c=this._renderCmd;if(a!==b.height){b.height=a;var d=c._anchorPointInPoints,e=this._anchorPoint;d.y=b.height*e.y,this.dom.height=b.height,this.anchorY=e.y,this.canvas&&(this.canvas.height=b.height),this.setNodeDirty(),this.redraw()}},setRotation:function(a){this._rotation!==a&&(this._rotationX=this._rotationY=a,this.setNodeDirty(),this.dom.rotate(a))},setSkewX:function(a){this._skewX=a,this.setNodeDirty(),this.dom.setSkew(this._skewX,this._skewY)},setSkewY:function(a){this._skewY=a,this.setNodeDirty(),this.dom.setSkew(this._skewX,this._skewY)},setVisible:function(a){this._visible=a,this.setNodeDirty(),this.dom&&(this.dom.style.display=a?"block":"none")},_setLocalZOrder:function(a){this._localZOrder=a,this.setNodeDirty(),this.dom&&(this.dom.zIndex=a)},setParent:function(a){this._parent=a,null!==a&&(a.setAnchorPoint(a.getAnchorPoint()),this.setNodeDirty(),cc.DOM.parentDOM(this))},resume:function(){this.getScheduler().resumeTarget(this),this.getActionManager().resumeTarget(this),cc.eventManager.resumeTarget(this),this.dom&&!this.dom.parentNode&&(this.getParent()?cc.DOM.parentDOM(this):""===this.dom.id?cc.DOM._createEGLViewDiv(this):this.dom.appendTo(cc.container)),this.dom&&(this.dom.style.visibility="visible")},pause:function(){this.getScheduler().pauseTarget(this),this.getActionManager().pauseTarget(this),cc.eventManager.pauseTarget(this),this.dom&&(this.dom.style.visibility="hidden")},cleanup:function(){this.stopAllActions(),this.unscheduleAllCallbacks(),cc.eventManager.removeListeners(this),this._arrayMakeObjectsPerformSelector(this._children,cc.Node._stateCallbackType.cleanup),this.dom&&this.dom.remove()},setOpacity:function(a){this._opacity=a,this.dom.style.opacity=a/255},redraw:function(){if(this.isSprite){var a=this._children;this._children=[],cc.Sprite.prototype.visit.call(this,this.ctx),this._children=a}else cc.Sprite.prototype.visit.call(this,this.ctx)}},cc.DOM._resetEGLViewDiv=function(){var a=cc.$("#EGLViewDiv");if(a){var b=cc.view,c=b.getDesignResolutionSize(),d=b.getViewPortRect(),e=b.getFrameSize(),f=b.getDevicePixelRatio(),g=c.width,h=c.height;0===c.width&&0===c.height&&(g=e.width,h=e.height);var i=d.width/f;0===d.width&&0===d.height&&(i=e.width),a.style.position="absolute",a.style.width=g+"px",a.style.maxHeight=h+"px",a.style.margin=0,a.resize(b.getScaleX()/f,b.getScaleY()/f),b.getResolutionPolicy()===b._rpNoBorder?(a.style.left=(b.getFrameSize().width-g)/2+"px",a.style.bottom=(b.getFrameSize().height-h*b.getScaleY()/f)/2+"px"):(a.style.left=(g*b.getScaleX()/f-g)/2+"px",a.style.bottom="0px")}},cc.DOM.parentDOM=function(a){var b=a.getParent();if(!b||!a.dom)return!1;if(b.dom||(cc.DOM.placeHolder(b),b.setParent=cc.DOM.methods.setParent),a.dom.appendTo(b.dom),b.setAnchorPoint(b.getAnchorPoint()),b.getParent())cc.DOM.parentDOM(b);else if(b.isRunning()){var c=cc.$("#EGLViewDiv");c?b.dom.appendTo(c):cc.DOM._createEGLViewDiv(b)}return!0},cc.DOM._createEGLViewDiv=function(a){var b=cc.$("#EGLViewDiv");b||(b=cc.$new("div"),b.id="EGLViewDiv");var c=cc.view,d=c.getDesignResolutionSize(),e=c.getViewPortRect(),f=c.getFrameSize(),g=c.getDevicePixelRatio(),h=d.width,i=d.height;0===d.width&&0===d.height&&(h=f.width,i=f.height);var j=e.width/g;0===e.width&&0===e.height&&(j=f.width),b.style.position="absolute",b.style.width=h+"px",b.style.maxHeight=i+"px",b.style.margin=0,b.resize(c.getScaleX()/g,c.getScaleY()/g),c.getResolutionPolicy()===c._rpNoBorder?(b.style.left=(f.width-h)/2+"px",b.style.bottom=(f.height-i*c.getScaleY()/g)/2+"px"):(b.style.left=(h*c.getScaleX()/g-h)/2+"px",b.style.bottom="0px"),a.dom.appendTo(b),b.appendTo(cc.container)},cc.DOM.setTransform=function(a){if(a.ctx)if(a.ctx.translate(a.getAnchorPointInPoints().x,a.getAnchorPointInPoints().y),a.isSprite){var b=a._children;a._children=[],cc.Sprite.prototype.visit.call(a),a._children=b}else cc.Sprite.prototype.visit.call(a);a.dom&&(a.dom.position.x=a.getPositionX(),a.dom.position.y=-a.getPositionY(),a.dom.rotation=a.getRotation(),a.dom.scale={x:a.getScaleX(),y:a.getScaleY()},a.dom.skew={x:a.getSkewX(),y:a.getSkewY()},a.setAnchorPoint&&a.setAnchorPoint(a.getAnchorPoint()),a.dom.transforms())},cc.DOM.forSprite=function(a){a.dom=cc.$new("div"),a.canvas=cc.$new("canvas");var b=a.getContentSize();a.canvas.width=b.width,a.canvas.height=b.height,a.dom.style.position="absolute",a.dom.style.bottom=0,a.ctx=a.canvas.getContext("2d"),a.dom.appendChild(a.canvas),a.getParent()&&cc.DOM.parentDOM(a),a.isSprite=!0},cc.DOM.placeHolder=function(a){a.dom=cc.$new("div"),a.placeholder=!0,a.dom.style.position="absolute",a.dom.style.bottom=0,a.dom.style.width=(a.getContentSize().width||cc.director.getWinSize().width)+"px",a.dom.style.maxHeight=(a.getContentSize().height||cc.director.getWinSize().height)+"px",a.dom.style.margin=0,cc.DOM.setTransform(a),a.dom.transforms(),cc.DOM._addMethods(a)},cc.DOM.convert=function(a){if(arguments.length>1)return void cc.DOM.convert(arguments);if(1===arguments.length&&!arguments[0].length)return void cc.DOM.convert([arguments[0]]);for(var b=arguments[0],c=0;c0&&(this._maxLength=a,this._edTxt.maxLength=a)},getMaxLength:function(){return this._maxLength},setPlaceHolder:function(a){if(null!=a){var b=this._placeholderText;this._placeholderText=a,this._edTxt.value===b&&(this._edTxt.value=a,this._edTxt.style.color=cc.colorToHex(this._placeholderColor),this._setPlaceholderFontToEditText())}},setPlaceholderFont:function(a,b){this._placeholderFontName=a,this._placeholderFontSize=b,this._setPlaceholderFontToEditText()},_setPlaceholderFont:function(a){var b=cc.LabelTTF._fontStyleRE.exec(a);b&&(this._placeholderFontName=b[2],this._placeholderFontSize=parseInt(b[1]),this._setPlaceholderFontToEditText())},setPlaceholderFontName:function(a){this._placeholderFontName=a,this._setPlaceholderFontToEditText()},setPlaceholderFontSize:function(a){this._placeholderFontSize=a,this._setPlaceholderFontToEditText()},_setPlaceholderFontToEditText:function(){this._edTxt.value===this._placeholderText&&(this._edTxt.style.fontFamily=this._placeholderFontName,this._edTxt.style.fontSize=this._placeholderFontSize+"px",this._edTxt.type="text")},setPlaceholderFontColor:function(a){this._placeholderColor=a,this._edTxt.value===this._placeholderText&&(this._edTxt.style.color=cc.colorToHex(a))},setInputFlag:function(a){this._editBoxInputFlag=a,this._edTxt.value!==this._placeholderText&&a===cc.EDITBOX_INPUT_FLAG_PASSWORD?this._edTxt.type="password":this._edTxt.type="text"},getText:function(){return cc.log("Please use the getString"),this._edTxt.value},getString:function(){return this._edTxt.value===this._placeholderText?"":this._edTxt.value},initWithSizeAndBackgroundSprite:function(a,b){return this.initWithBackgroundSprite(b)?(this._domInputSprite.x=3,this._domInputSprite.y=3,this.setZoomOnTouchDown(!1),this.setPreferredSize(a),this.x=0,this.y=0,this._addTargetWithActionForControlEvent(this,this.touchDownAction,cc.CONTROL_EVENT_TOUCH_UP_INSIDE),!0):!1},setDelegate:function(a){this._delegate=a},getPlaceHolder:function(){return this._placeholderText},setInputMode:function(a){this._editBoxInputMode=a},setReturnType:function(a){this._keyboardReturnType=a},keyboardWillShow:function(a){var b=cc.EditBox.getRect(this);return b.y-=4,b.intersectsRect(a.end)?void(this._adjustHeight=a.end.getMaxY()-b.getMinY()):void cc.log("needn't to adjust view layout.")},keyboardDidShow:function(a){},keyboardWillHide:function(a){},keyboardDidHide:function(a){},touchDownAction:function(a,b){},initWithBackgroundColor:function(a,b){this._edWidth=a.width,this.dom.style.width=this._edWidth.toString()+"px",this._edHeight=a.height,this.dom.style.height=this._edHeight.toString()+"px",this.dom.style.backgroundColor=cc.colorToHex(b)},cleanup:function(){this._edTxt.removeEventListener("input",this._inputEvent),this._edTxt.removeEventListener("keypress",this._keyPressEvent),this._edTxt.removeEventListener("focus",this._focusEvent),this._edTxt.removeEventListener("blur",this._blurEvent),cc._canvas.removeEventListener("click",this._onCanvasClick),this._super()}});var _p=cc.EditBox.prototype;_p.font,cc.defineGetterSetter(_p,"font",null,_p._setFont),_p.fontName,cc.defineGetterSetter(_p,"fontName",null,_p.setFontName),_p.fontSize,cc.defineGetterSetter(_p,"fontSize",null,_p.setFontSize),_p.fontColor,cc.defineGetterSetter(_p,"fontColor",null,_p.setFontColor),_p.string,cc.defineGetterSetter(_p,"string",_p.getString,_p.setString),_p.maxLength,cc.defineGetterSetter(_p,"maxLength",_p.getMaxLength,_p.setMaxLength),_p.placeHolder,cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder),_p.placeHolderFont,cc.defineGetterSetter(_p,"placeHolderFont",null,_p._setPlaceholderFont),_p.placeHolderFontName,cc.defineGetterSetter(_p,"placeHolderFontName",null,_p.setPlaceholderFontName),_p.placeHolderFontSize,cc.defineGetterSetter(_p,"placeHolderFontSize",null,_p.setPlaceholderFontSize),_p.placeHolderFontColor,cc.defineGetterSetter(_p,"placeHolderFontColor",null,_p.setPlaceholderFontColor),_p.inputFlag,cc.defineGetterSetter(_p,"inputFlag",null,_p.setInputFlag),_p.delegate,cc.defineGetterSetter(_p,"delegate",null,_p.setDelegate),_p.inputMode,cc.defineGetterSetter(_p,"inputMode",null,_p.setInputMode),_p.returnType,cc.defineGetterSetter(_p,"returnType",null,_p.setReturnType),_p=null,cc.EditBox.getRect=function(a){var b=a.getContentSize(),c=cc.rect(0,0,b.width,b.height);return cc.rectApplyAffineTransform(c,a.getNodeToWorldTransform())},cc.EditBox.create=function(a,b,c,d){return new cc.EditBox(a,b,c,d)};cc.ProtectedNode=cc.Node.extend({_protectedChildren:null,_reorderProtectedChildDirty:!1,_insertProtectedChild:function(a,b){this._reorderProtectedChildDirty=!0,this._protectedChildren.push(a),a._setLocalZOrder(b)},ctor:function(){cc.Node.prototype.ctor.call(this),this._protectedChildren=[]},addProtectedChild:function(a,b,c){cc.assert(null!=a,"child must be non-nil"),cc.assert(!a.parent,"child already added. It can't be added again"),b=b||a.getLocalZOrder(),c&&a.setTag(c),this._insertProtectedChild(a,b),a.setParent(this),a.setOrderOfArrival(cc.s_globalOrderOfArrival),this._running&&(a.onEnter(),this._isTransitionFinished&&a.onEnterTransitionDidFinish()),this._cascadeColorEnabled&&this._renderCmd.setCascadeColorEnabledDirty(),this._cascadeOpacityEnabled&&this._renderCmd.setCascadeOpacityEnabledDirty()},getProtectedChildByTag:function(a){cc.assert(a!==cc.NODE_TAG_INVALID,"Invalid tag");for(var b=this._protectedChildren,c=0,d=b.length;d>c;c++)if(b.getTag()===a)return b[c];return null},removeProtectedChild:function(a,b){null==b&&(b=!0);var c=this._protectedChildren;if(0!==c.length){var d=c.indexOf(a);d>-1&&(this._running&&(a.onExitTransitionDidStart(),a.onExit()),b&&a.cleanup(),a.setParent(null),c.splice(d,1))}},removeProtectedChildByTag:function(a,b){cc.assert(a!==cc.NODE_TAG_INVALID,"Invalid tag"),null==b&&(b=!0);var c=this.getProtectedChildByTag(a);null==c?cc.log("cocos2d: removeChildByTag(tag = %d): child not found!",a):this.removeProtectedChild(c,b)},removeAllProtectedChildren:function(){this.removeAllProtectedChildrenWithCleanup(!0)},removeAllProtectedChildrenWithCleanup:function(a){null==a&&(a=!0);for(var b=this._protectedChildren,c=0,d=b.length;d>c;c++){var e=b[c];this._running&&(e.onExitTransitionDidStart(),e.onExit()),a&&e.cleanup(),e.setParent(null)}b.length=0},reorderProtectedChild:function(a,b){cc.assert(null!=a,"Child must be non-nil"),this._reorderProtectedChildDirty=!0,a.setOrderOfArrival(cc.s_globalOrderOfArrival++),a._setLocalZOrder(b)},sortAllProtectedChildren:function(){if(this._reorderProtectedChildDirty){var a,b,c,d=this._protectedChildren,e=d.length;for(a=1;e>a;a++){for(c=d[a],b=a-1;b>=0;){if(c._localZOrderb;b++)a[b].cleanup()},onEnter:function(){cc.Node.prototype.onEnter.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onEnter()},onEnterTransitionDidFinish:function(){cc.Node.prototype.onEnterTransitionDidFinish.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onEnterTransitionDidFinish()},onExit:function(){cc.Node.prototype.onExit.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onExit()},onExitTransitionDidStart:function(){cc.Node.prototype.onExitTransitionDidStart.call(this);for(var a=this._protectedChildren,b=0,c=a.length;c>b;b++)a[b].onExitTransitionDidStart()},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.ProtectedNode.CanvasRenderCmd(this):new cc.ProtectedNode.WebGLRenderCmd(this)}}),cc.ProtectedNode.create=function(){return new cc.ProtectedNode},function(){cc.ProtectedNode.RenderCmd={_updateDisplayColor:function(a){var b,c,d,e,f=this._node,g=this._displayedColor,h=f._realColor;if(this._cascadeColorEnabledDirty&&!f._cascadeColorEnabled){g.r=h.r,g.g=h.g,g.b=h.b;var i=new cc.Color(255,255,255,255);for(d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&e._renderCmd._updateDisplayColor(i);this._cascadeColorEnabledDirty=!1}else{if(void 0===a){var j=f._parent;a=j&&j._cascadeColorEnabled?j.getDisplayedColor():cc.color.WHITE}if(g.r=0|h.r*a.r/255,g.g=0|h.g*a.g/255,g.b=0|h.b*a.b/255,f._cascadeColorEnabled)for(d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&(e._renderCmd._updateDisplayColor(g),e._renderCmd._updateColor());for(d=f._protectedChildren,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&(e._renderCmd._updateDisplayColor(g),e._renderCmd._updateColor())}this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.colorDirty^this._dirtyFlag},_updateDisplayOpacity:function(a){var b,c,d,e,f=this._node;if(this._cascadeOpacityEnabledDirty&&!f._cascadeOpacityEnabled){for(this._displayedOpacity=f._realOpacity,d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&e._renderCmd._updateDisplayOpacity(255);this._cascadeOpacityEnabledDirty=!1}else{if(void 0===a){var g=f._parent;a=255,g&&g._cascadeOpacityEnabled&&(a=g.getDisplayedOpacity())}if(this._displayedOpacity=f._realOpacity*a/255,f._cascadeOpacityEnabled)for(d=f._children,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&(e._renderCmd._updateDisplayOpacity(this._displayedOpacity),e._renderCmd._updateColor());for(d=f._protectedChildren,b=0,c=d.length;c>b;b++)e=d[b],e&&e._renderCmd&&(e._renderCmd._updateDisplayOpacity(this._displayedOpacity),e._renderCmd._updateColor())}this._dirtyFlag=this._dirtyFlag&cc.Node._dirtyFlags.opacityDirty^this._dirtyFlag},_changeProtectedChild:function(a){var b=a._renderCmd,c=b._dirtyFlag,d=cc.Node._dirtyFlags;this._dirtyFlag&d.colorDirty&&(c|=d.colorDirty),this._dirtyFlag&d.opacityDirty&&(c|=d.opacityDirty);var e=c&d.colorDirty,f=c&d.opacityDirty;e&&b._updateDisplayColor(this._displayedColor),f&&b._updateDisplayOpacity(this._displayedOpacity),(e||f)&&b._updateColor()}},cc.ProtectedNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._cachedParent=null,this._cacheDirty=!1};var a=cc.ProtectedNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);cc.inject(cc.ProtectedNode.RenderCmd,a),a.constructor=cc.ProtectedNode.CanvasRenderCmd,a.visit=function(a){var b=this._node;if(b._visible){var c,d,e,f=b._children,g=b._children,h=b._protectedChildren,i=g.length,j=h.length;this._syncStatus(a),b.sortAllChildren(),b.sortAllProtectedChildren();var k;for(c=0;i>c&&(e=f[c],e._localZOrder<0);c++)e.visit(this);for(d=0;j>d&&(k=h[d],k&&k._localZOrder<0);d++)this._changeProtectedChild(k),k.visit(this);for(cc.renderer.pushRenderCommand(this);i>c;c++)f[c]&&f[c].visit(this);for(;j>d;d++)k=h[d],k&&(this._changeProtectedChild(k),k.visit(this));this._dirtyFlag=0,this._cacheDirty=!1}},a.transform=function(a,b){var c=this._node;c._changePosition&&c._changePosition();var d=c.getNodeToParentTransform(),e=this._worldTransform;if(a){var f=a._worldTransform;e.a=d.a*f.a+d.b*f.c,e.b=d.a*f.b+d.b*f.d,e.c=d.c*f.a+d.d*f.c,e.d=d.c*f.b+d.d*f.d,e.tx=f.a*d.tx+f.c*d.ty+f.tx,e.ty=f.d*d.ty+f.ty+f.b*d.tx}else e.a=d.a,e.b=d.b,e.c=d.c,e.d=d.d,e.tx=d.tx,e.ty=d.ty;var g,h,i=c._children;if(b&&i&&0!==i.length)for(g=0,h=i.length;h>g;g++)i[g]._renderCmd.transform(this,b);if(i=c._protectedChildren,b&&i&&0!==i.length)for(g=0,h=i.length;h>g;g++)i[g]._renderCmd.transform(this,b)}}(),function(){if(cc.Node.WebGLRenderCmd){cc.ProtectedNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a)};var a=cc.ProtectedNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);cc.inject(cc.ProtectedNode.RenderCmd,a),a.constructor=cc.ProtectedNode.WebGLRenderCmd,a.visit=function(a){var b=this._node;if(b._visible){var c,d,e=cc.current_stack;e.stack.push(e.top),this._syncStatus(a),e.top=this._stackMatrix;var f=b.grid;f&&f._active&&f.beforeDraw();var g=b._children,h=b._protectedChildren,i=g.length,j=h.length;b.sortAllChildren(),b.sortAllProtectedChildren();var k;for(c=0;i>c&&(g[c]&&g[c]._localZOrder<0);c++)g[c].visit(this);for(d=0;j>d&&(k=h[d],k&&k._localZOrder<0);d++)this._changeProtectedChild(k),k.visit(this);for(cc.renderer.pushRenderCommand(this);i>c;c++)g[c]&&g[c].visit(this);for(;j>d;d++)k=h[d],k&&(this._changeProtectedChild(k),k.visit(this));f&&f._active&&f.afterDraw(b),this._dirtyFlag=0,e.top=e.stack.pop()}},a.transform=function(a,b){var c=this._node,d=this._transform4x4,e=this._stackMatrix,f=a?a._stackMatrix:cc.current_stack.top,g=c.getNodeToParentTransform();c._changePosition&&c._changePosition();var h=d.mat;if(h[0]=g.a,h[4]=g.c,h[12]=g.tx,h[1]=g.b,h[5]=g.d,h[13]=g.ty,h[14]=c._vertexZ,cc.kmMat4Multiply(e,f,d),null!==c._camera&&(null===c.grid||!c.grid.isActive())){var i=this._anchorPointInPoints.x,j=this._anchorPointInPoints.y,k=0!==i||0!==j;if(k){cc.SPRITEBATCHNODE_RENDER_SUBPIXEL||(i=0|i,j=0|j);var l=cc.math.Matrix4.createByTranslation(i,j,0,d);e.multiply(k),c._camera._locateForRenderer(e),l=cc.math.Matrix4.createByTranslation(-i,-j,0,l),e.multiply(l),d.identity()}else c._camera._locateForRenderer(e)}var m,n,o=c._children;if(b&&o&&0!==o.length)for(m=0,n=o.length;n>m;m++)o[m]._renderCmd.transform(this,b);if(o=c._protectedChildren,b&&o&&0!==o.length)for(m=0,n=o.length;n>m;m++)o[m]._renderCmd.transform(this,b)}}}();var ccui=ccui||{};ccui.Class=ccui.Class||cc.Class,ccui.Class.extend=ccui.Class.extend||cc.Class.extend,ccui.Node=ccui.Node||cc.Node,ccui.Node.extend=ccui.Node.extend||cc.Node.extend,ccui.ProtectedNode=ccui.ProtectedNode||cc.ProtectedNode,ccui.ProtectedNode.extend=ccui.ProtectedNode.extend||cc.ProtectedNode.extend,ccui.cocosGUIVersion="CocosGUI v1.0.0.0",ccui._FocusNavigationController=cc.Class.extend({_keyboardListener:null,_firstFocusedWidget:null,_enableFocusNavigation:!1,_keyboardEventPriority:1,enableFocusNavigation:function(a){this._enableFocusNavigation!==a&&(this._enableFocusNavigation=a,a?this._addKeyboardEventListener():this._removeKeyboardEventListener())},_setFirstFocsuedWidget:function(a){this._firstFocusedWidget=a},_onKeyPressed:function(a,b){this._enableFocusNavigation&&this._firstFocusedWidget&&(a===cc.KEY.dpadDown&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.DOWN,this._firstFocusedWidget)),a===cc.KEY.dpadUp&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.UP,this._firstFocusedWidget)),a===cc.KEY.dpadLeft&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.LEFT,this._firstFocusedWidget)),a===cc.KEY.dpadRight&&(this._firstFocusedWidget=this._firstFocusedWidget.findNextFocusedWidget(ccui.Widget.RIGHT,this._firstFocusedWidget)))},_addKeyboardEventListener:function(){this._keyboardListener||(this._keyboardListener=cc.EventListener.create({event:cc.EventListener.KEYBOARD,onKeyReleased:this._onKeyPressed.bind(this)}),cc.eventManager.addListener(this._keyboardListener,this._keyboardEventPriority))},_removeKeyboardEventListener:function(){this._keyboardListener&&(cc.eventManager.removeEventListener(this._keyboardListener),this._keyboardListener=null)}}),ccui.__LAYOUT_COMPONENT_NAME="__ui_layout",ccui.Widget=ccui.ProtectedNode.extend({_enabled:!0,_bright:!0,_touchEnabled:!1,_brightStyle:null,_touchBeganPosition:null,_touchMovePosition:null,_touchEndPosition:null,_touchEventListener:null,_touchEventSelector:null,_name:"default",_widgetType:null,_actionTag:0,_customSize:null,_layoutParameterDictionary:null,_layoutParameterType:0,_focused:!1,_focusEnabled:!0,_ignoreSize:!1,_affectByClipping:!1,_sizeType:null,_sizePercent:null,_positionType:null,_positionPercent:null,_hit:!1,_nodes:null,_touchListener:null,_className:"Widget",_flippedX:!1,_flippedY:!1,_opacity:255,_highlight:!1,_touchEventCallback:null,_clickEventListener:null,_propagateTouchEvents:!0,_unifySize:!1,_callbackName:null,_callbackType:null,_usingLayoutComponent:!1,_inViewRect:!0,ctor:function(){cc.ProtectedNode.prototype.ctor.call(this),this._brightStyle=ccui.Widget.BRIGHT_STYLE_NONE,this._touchBeganPosition=cc.p(0,0),this._touchMovePosition=cc.p(0,0),this._touchEndPosition=cc.p(0,0),this._widgetType=ccui.Widget.TYPE_WIDGET,this._customSize=cc.size(0,0),this._layoutParameterDictionary={},this._sizeType=ccui.Widget.SIZE_ABSOLUTE,this._sizePercent=cc.p(0,0),this._positionType=ccui.Widget.POSITION_ABSOLUTE,this._positionPercent=cc.p(0,0),this._nodes=[],this._layoutParameterType=ccui.LayoutParameter.NONE,this.init()},init:function(){return cc.ProtectedNode.prototype.init.call(this)?(this._layoutParameterDictionary={},this._initRenderer(),this.setBright(!0),this.onFocusChanged=this.onFocusChange.bind(this),this.onNextFocusedWidget=null,this.setAnchorPoint(cc.p(.5,.5)),this.ignoreContentAdaptWithSize(!0),!0):!1},onEnter:function(){var a=this._touchListener;a&&!a._isRegistered()&&this._touchEnabled&&cc.eventManager.addListener(a,this),this._usingLayoutComponent||this.updateSizeAndPosition(),cc.ProtectedNode.prototype.onEnter.call(this)},onExit:function(){this.unscheduleUpdate(),cc.ProtectedNode.prototype.onExit.call(this)},_getOrCreateLayoutComponent:function(){var a=this.getComponent(ccui.__LAYOUT_COMPONENT_NAME);return null==a&&(a=new ccui.LayoutComponent,this.addComponent(a)),a},getWidgetParent:function(){var a=this.getParent();return a instanceof ccui.Widget?a:null},_updateContentSizeWithTextureSize:function(a){return this._unifySize?void this.setContentSize(a):void this.setContentSize(this._ignoreSize?a:this._customSize)},_isAncestorsEnabled:function(){var a=this._getAncensterWidget(this);return null==a?!0:a&&!a.isEnabled()?!1:a._isAncestorsEnabled()},setPropagateTouchEvents:function(a){this._propagateTouchEvents=a},isPropagateTouchEvents:function(){return this._propagateTouchEvents},setSwallowTouches:function(a){this._touchListener&&this._touchListener.setSwallowTouches(a)},isSwallowTouches:function(){return this._touchListener?this._touchListener.isSwallowTouches():!1},_getAncensterWidget:function(a){if(null==a)return null;var b=a.getParent();return null==b?null:b instanceof ccui.Widget?b:this._getAncensterWidget(b.getParent())},_isAncestorsVisible:function(a){if(null==a)return!0;var b=a.getParent();return b&&!b.isVisible()?!1:this._isAncestorsVisible(b)},_cleanupWidget:function(){this._eventDispatcher.removeEventListener(this._touchListener),this._touchEnabled=!1,this._touchListener=null,ccui.Widget._focusedWidget===this&&(ccui.Widget._focusedWidget=null,ccui.Widget._focusNavigationController=null)},setEnabled:function(a){this._enabled=a},_initRenderer:function(){},setContentSize:function(a,b){var c=void 0===b?a.width:a,d=void 0===b?a.height:b;if(cc.Node.prototype.setContentSize.call(this,c,d),this._customSize.width=c,this._customSize.height=d,this._unifySize||this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize()),!this._usingLayoutComponent&&this._running){var e=this.getWidgetParent(),f=e?e.getContentSize():this._parent.getContentSize();this._sizePercent.x=f.width>0?c/f.width:0,this._sizePercent.y=f.height>0?d/f.height:0}this._onSizeChanged()},_setWidth:function(a){if(cc.Node.prototype._setWidth.call(this,a),this._customSize.width=a,this._unifySize||this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize()),!this._usingLayoutComponent&&this._running){var b=this.getWidgetParent(),c=b?b.width:this._parent.width;this._sizePercent.x=c>0?this._customSize.width/c:0}this._onSizeChanged()},_setHeight:function(a){if(cc.Node.prototype._setHeight.call(this,a),this._customSize.height=a,this._unifySize||this._ignoreSize&&(this._contentSize=this.getVirtualRendererSize()),!this._usingLayoutComponent&&this._running){var b=this.getWidgetParent(),c=b?b.height:this._parent.height;this._sizePercent.y=c>0?this._customSize.height/c:0}this._onSizeChanged()},setSizePercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setUsingPercentContentSize(!0),b.setPercentContentSize(a),void b.refreshLayout()}this._sizePercent.x=a.x,this._sizePercent.y=a.y;var c=this._customSize.width,d=this._customSize.height;if(this._running){var e=this.getWidgetParent();e?(c=e.width*a.x,d=e.height*a.y):(c=this._parent.width*a.x,d=this._parent.height*a.y)}this._ignoreSize?this.setContentSize(this.getVirtualRendererSize()):this.setContentSize(c,d),this._customSize.width=c,this._customSize.height=d},_setWidthPercent:function(a){this._sizePercent.x=a;var b=this._customSize.width;if(this._running){var c=this.getWidgetParent();b=(c?c.width:this._parent.width)*a}this._ignoreSize?this._setWidth(this.getVirtualRendererSize().width):this._setWidth(b),this._customSize.width=b},_setHeightPercent:function(a){this._sizePercent.y=a;var b=this._customSize.height;if(this._running){var c=this.getWidgetParent();b=(c?c.height:this._parent.height)*a}this._ignoreSize?this._setHeight(this.getVirtualRendererSize().height):this._setHeight(b),this._customSize.height=b},updateSizeAndPosition:function(a){if(!a){var b=this.getWidgetParent();a=b?b.getLayoutSize():this._parent.getContentSize()}switch(this._sizeType){case ccui.Widget.SIZE_ABSOLUTE:this._ignoreSize?this.setContentSize(this.getVirtualRendererSize()):this.setContentSize(this._customSize),this._sizePercent.x=a.width>0?this._customSize.width/a.width:0,this._sizePercent.y=a.height>0?this._customSize.height/a.height:0;break;case ccui.Widget.SIZE_PERCENT:var c=cc.size(a.width*this._sizePercent.x,a.height*this._sizePercent.y);this._ignoreSize?this.setContentSize(this.getVirtualRendererSize()):this.setContentSize(c),this._customSize.width=c.width,this._customSize.height=c.height}this._onSizeChanged();var d=this.getPosition();switch(this._positionType){case ccui.Widget.POSITION_ABSOLUTE:a.width<=0||a.height<=0?this._positionPercent.x=this._positionPercent.y=0:(this._positionPercent.x=d.x/a.width,this._positionPercent.y=d.y/a.height);break;case ccui.Widget.POSITION_PERCENT:d=cc.p(a.width*this._positionPercent.x,a.height*this._positionPercent.y)}if(this._parent instanceof ccui.ImageView){var e=this._parent._imageRenderer;if(e&&!e._textureLoaded)return}this.setPosition(d)},setSizeType:function(a){if(this._sizeType=a,this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();b.setUsingPercentContentSize(this._sizeType===ccui.SIZE_PERCENT)}},getSizeType:function(){return this._sizeType},ignoreContentAdaptWithSize:function(a){return this._unifySize?void this.setContentSize(this._customSize):void(this._ignoreSize!==a&&(this._ignoreSize=a,this.setContentSize(a?this.getVirtualRendererSize():this._customSize)))},isIgnoreContentAdaptWithSize:function(){return this._ignoreSize},getCustomSize:function(){return cc.size(this._customSize)},getLayoutSize:function(){return cc.size(this._contentSize)},getSizePercent:function(){if(this._usingLayoutComponent){var a=this._getOrCreateLayoutComponent();this._sizePercent=a.getPercentContentSize()}return this._sizePercent},_getWidthPercent:function(){return this._sizePercent.x},_getHeightPercent:function(){return this._sizePercent.y},getWorldPosition:function(){return this.convertToWorldSpace(cc.p(this._anchorPoint.x*this._contentSize.width,this._anchorPoint.y*this._contentSize.height))},getVirtualRenderer:function(){return this},getVirtualRendererSize:function(){return cc.size(this._contentSize)},_onSizeChanged:function(){if(!this._usingLayoutComponent)for(var a=this.getChildren(),b=0,c=a.length;c>b;b++){var d=a[b];d instanceof ccui.Widget&&d.updateSizeAndPosition()}},setTouchEnabled:function(a){this._touchEnabled!==a&&(this._touchEnabled=a,this._touchEnabled?(this._touchListener||(this._touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,onTouchBegan:this.onTouchBegan.bind(this),onTouchMoved:this.onTouchMoved.bind(this),onTouchEnded:this.onTouchEnded.bind(this)})),cc.eventManager.addListener(this._touchListener,this)):cc.eventManager.removeListener(this._touchListener))},isTouchEnabled:function(){return this._touchEnabled},isHighlighted:function(){return this._highlight},setHighlighted:function(a){a!==this._highlight&&(this._highlight=a,this._bright?this._highlight?this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT):this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL):this._onPressStateChangedToDisabled())},isFocused:function(){return this._focused},setFocused:function(a){this._focused=a,a&&(ccui.Widget._focusedWidget=this,ccui.Widget._focusNavigationController&&ccui.Widget._focusNavigationController._setFirstFocsuedWidget(this))},isFocusEnabled:function(){return this._focusEnabled},setFocusEnabled:function(a){this._focusEnabled=a},findNextFocusedWidget:function(a,b){if(null===this.onNextFocusedWidget||null==this.onNextFocusedWidget(a)){var c=b instanceof ccui.Layout;if(this.isFocused()||c){var d=this.getParent();return null!==d&&d instanceof ccui.Layout?d.findNextFocusedWidget(a,b):c?b.findNextFocusedWidget(a,b):b}return b}var e=this.onNextFocusedWidget(a);return this.dispatchFocusEvent(this,e),e},requestFocus:function(){this!==ccui.Widget._focusedWidget&&this.dispatchFocusEvent(ccui.Widget._focusedWidget,this)},getCurrentFocusedWidget:function(){return ccui.Widget._focusedWidget},onFocusChanged:null,onNextFocusedWidget:null,interceptTouchEvent:function(a,b,c){var d=this.getWidgetParent();d&&d.interceptTouchEvent(a,b,c)},onFocusChange:function(a,b){a&&a.setFocused(!1),b&&b.setFocused(!0)},dispatchFocusEvent:function(a,b){a&&!a.isFocused()&&(a=ccui.Widget._focusedWidget),b!==a&&(b&&b.onFocusChanged&&b.onFocusChanged(a,b),a&&b.onFocusChanged&&a.onFocusChanged(a,b),cc.eventManager.dispatchEvent(new cc.EventFocus(a,b)))},setBright:function(a){this._bright=a,this._bright?(this._brightStyle=ccui.Widget.BRIGHT_STYLE_NONE,this.setBrightStyle(ccui.Widget.BRIGHT_STYLE_NORMAL)):this._onPressStateChangedToDisabled()},setBrightStyle:function(a){if(this._brightStyle!==a)switch(a=a||ccui.Widget.BRIGHT_STYLE_NORMAL,this._brightStyle=a,this._brightStyle){case ccui.Widget.BRIGHT_STYLE_NORMAL:this._onPressStateChangedToNormal();break;case ccui.Widget.BRIGHT_STYLE_HIGH_LIGHT:this._onPressStateChangedToPressed()}},_onPressStateChangedToNormal:function(){},_onPressStateChangedToPressed:function(){},_onPressStateChangedToDisabled:function(){},_updateChildrenDisplayedRGBA:function(){this.setColor(this.getColor()),this.setOpacity(this.getOpacity())},didNotSelectSelf:function(){},onTouchBegan:function(a,b){if(this._hit=!1,this.isVisible()&&this.isEnabled()&&this._isAncestorsEnabled()&&this._isAncestorsVisible(this)){var c=a.getLocation();this._touchBeganPosition.x=c.x,this._touchBeganPosition.y=c.y,this.hitTest(this._touchBeganPosition)&&this.isClippingParentContainsPoint(this._touchBeganPosition)&&(this._hit=!0)}return this._hit?(this.setHighlighted(!0),this._propagateTouchEvents&&this.propagateTouchEvent(ccui.Widget.TOUCH_BEGAN,this,a),this._pushDownEvent(),!0):!1},propagateTouchEvent:function(a,b,c){var d=this.getWidgetParent();d&&d.interceptTouchEvent(a,b,c)},onTouchMoved:function(a,b){var c=a.getLocation();this._touchMovePosition.x=c.x,this._touchMovePosition.y=c.y,this.setHighlighted(this.hitTest(c)),this._propagateTouchEvents&&this.propagateTouchEvent(ccui.Widget.TOUCH_MOVED,this,a),this._moveEvent()},onTouchEnded:function(a,b){var c=a.getLocation();this._touchEndPosition.x=c.x,this._touchEndPosition.y=c.y,this._propagateTouchEvents&&this.propagateTouchEvent(ccui.Widget.TOUCH_ENDED,this,a);var d=this._highlight;this.setHighlighted(!1),d?this._releaseUpEvent():this._cancelUpEvent()},onTouchCancelled:function(a){this.setHighlighted(!1),this._cancelUpEvent()},onTouchLongClicked:function(a){this.longClickEvent()},_pushDownEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_BEGAN),this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_BEGAN)},_moveEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_MOVED),this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_MOVED)},_releaseUpEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_ENDED),this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_ENDED),this._clickEventListener&&this._clickEventListener(this)},_cancelUpEvent:function(){this._touchEventCallback&&this._touchEventCallback(this,ccui.Widget.TOUCH_CANCELED),this._touchEventListener&&this._touchEventSelector&&this._touchEventSelector.call(this._touchEventListener,this,ccui.Widget.TOUCH_CANCELED)},longClickEvent:function(){},addTouchEventListener:function(a,b){void 0===b?this._touchEventCallback=a:(this._touchEventSelector=a,this._touchEventListener=b)},addClickEventListener:function(a){this._clickEventListener=a},hitTest:function(a){var b=cc.rect(0,0,this._contentSize.width,this._contentSize.height);return cc.rectContainsPoint(b,this.convertToNodeSpace(a))},isClippingParentContainsPoint:function(a){this._affectByClipping=!1;for(var b=this.getParent(),c=null;b;){if(b instanceof ccui.Layout&&b.isClippingEnabled()){this._affectByClipping=!0,c=b;break}b=b.getParent()}return this._affectByClipping&&c?c.hitTest(a)?c.isClippingParentContainsPoint(a):!1:!0},checkChildInfo:function(a,b,c){var d=this.getWidgetParent();d&&d.checkChildInfo(a,b,c)},setPosition:function(a,b){if(!this._usingLayoutComponent&&this._running){var c=this.getWidgetParent();if(c){var d=c.getContentSize();d.width<=0||d.height<=0?(this._positionPercent.x=0,this._positionPercent.y=0):void 0===b?(this._positionPercent.x=a.x/d.width,this._positionPercent.y=a.y/d.height):(this._positionPercent.x=a/d.width,this._positionPercent.y=b/d.height)}}cc.Node.prototype.setPosition.call(this,a,b)},setPositionX:function(a){if(this._running){var b=this.getWidgetParent();if(b){var c=b.width;0>=c?this._positionPercent.x=0:this._positionPercent.x=a/c}}cc.Node.prototype.setPositionX.call(this,a)},setPositionY:function(a){if(this._running){var b=this.getWidgetParent();if(b){var c=b.height;0>=c?this._positionPercent.y=0:this._positionPercent.y=a/c}}cc.Node.prototype.setPositionY.call(this,a)},setPositionPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setPositionPercentX(a.x),b.setPositionPercentY(a.y),void b.refreshLayout()}this._setXPercent(a.x),this._setYPercent(a.y),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},_setXPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setPositionPercentX(a.x),void b.refreshLayout()}this._positionPercent.x=a},_setYPercent:function(a){if(this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();return b.setPositionPercentY(a.x),void b.refreshLayout()}this._positionPercent.y=a},getPositionPercent:function(){if(this._usingLayoutComponent){var a=this._getOrCreateLayoutComponent();this._positionPercent.x=a.getPositionPercentX(),this._positionPercent.y=a.getPositionPercentY()}return cc.p(this._positionPercent)},_getXPercent:function(){if(this._usingLayoutComponent){var a=this._getOrCreateLayoutComponent();this._positionPercent.x=a.getPositionPercentX(),this._positionPercent.y=a.getPositionPercentY()}return this._positionPercent.x},_getYPercent:function(){if(this._usingLayoutComponent){var a=this._getOrCreateLayoutComponent();this._positionPercent.x=a.getPositionPercentX(),this._positionPercent.y=a.getPositionPercentY()}return this._positionPercent.y},setPositionType:function(a){if(this._positionType=a,this._usingLayoutComponent){var b=this._getOrCreateLayoutComponent();a===ccui.POSITION_ABSOLUTE?(b.setPositionPercentXEnabled(!1),b.setPositionPercentYEnabled(!1)):(b.setPositionPercentXEnabled(!0),b.setPositionPercentYEnabled(!0))}this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.transformDirty)},getPositionType:function(){return this._positionType},setFlippedX:function(a){var b=this.getScaleX();this._flippedX=a,this.setScaleX(b)},isFlippedX:function(){return this._flippedX},setFlippedY:function(a){var b=this.getScaleY();this._flippedY=a,this.setScaleY(b)},isFlippedY:function(){return this._flippedY},_adaptRenderers:function(){},isBright:function(){return this._bright},isEnabled:function(){return this._enabled},getLeftBoundary:function(){return this.getPositionX()-this._getAnchorX()*this._contentSize.width},getBottomBoundary:function(){return this.getPositionY()-this._getAnchorY()*this._contentSize.height},getRightBoundary:function(){return this.getLeftBoundary()+this._contentSize.width},getTopBoundary:function(){return this.getBottomBoundary()+this._contentSize.height},getTouchBeganPosition:function(){return cc.p(this._touchBeganPosition)},getTouchMovePosition:function(){return cc.p(this._touchMovePosition)},getTouchEndPosition:function(){return cc.p(this._touchEndPosition)},getWidgetType:function(){return this._widgetType},setLayoutParameter:function(a){a&&(this._layoutParameterDictionary[a.getLayoutType()]=a,this._layoutParameterType=a.getLayoutType())},getLayoutParameter:function(a){return a=a||this._layoutParameterType,this._layoutParameterDictionary[a]},getDescription:function(){return"Widget"},clone:function(){var a=this._createCloneInstance();return a._copyProperties(this),a._copyClonedWidgetChildren(this),a},_createCloneInstance:function(){return new ccui.Widget},_copyClonedWidgetChildren:function(a){for(var b=a.getChildren(),c=0;cc;c++)b[c].setOpacityModifyRGB(a);this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.cacheDirty)}},isOpacityModifyRGB:function(){return this._opacityModifyRGB},createSlicedSprites:function(){var a=this._originalSize.width,b=this._originalSize.height,c=this._spriteRect,d=Math.floor(this._offset.x+(a-c.width)/2),e=Math.floor(this._offset.y+(b-c.height)/2),f=c.x,g=c.y,h=this._capInsetsInternal,i=this._scale9Image,j=i.getTexture(),k=this._spriteFrameRotated,l=cc.rect(c.x,c.y,c.width,c.height);cc._rectEqualToZero(h)&&(h=cc.rect(a/3,b/3,a/3,b/3)),this._spriteFrameRotated?(f-=e,g-=d):(f-=d,g-=e),c=cc.rect(f,g,a,b);var m=h.x,n=h.width,o=c.width-(m+n),p=h.y,q=h.height,r=c.height-(p+q),s=0,t=0,u=cc.rect(s+.5|0,t+.5|0,m+.5|0,p+.5|0),v=u;s+=m;var w=cc.rect(s+.5|0,t+.5|0,n+.5|0,p+.5|0),x=w;s+=n;var y=cc.rect(s+.5|0,t+.5|0,o+.5|0,p+.5|0),z=y;s=0,t=0,t+=p;var A=cc.rect(s+.5|0,t+.5|0,m+.5|0,q+.5|0);s+=m;var B=cc.rect(s+.5|0,t+.5|0,n+.5|0,q+.5|0),C=B;s+=n;var D=cc.rect(s+.5|0,t+.5|0,o+.5|0,q+.5|0);s=0,t=0,t+=p,t+=q;var E=cc.rect(s+.5|0,t+.5|0,m+.5|0,r+.5|0);s+=m;var F=cc.rect(s+.5|0,t+.5|0,n+.5|0,r+.5|0);s+=n;var G=cc.rect(s+.5|0,t+.5|0,o+.5|0,r+.5|0),H=G,I=u,J=B,K=G,L=C,M=H,N=E,O=z,P=v,Q=D,R=A,S=F,T=x,U=cc.affineTransformMakeIdentity();k?(U=cc.affineTransformTranslate(U,l.height+l.x,l.y),U=cc.affineTransformRotate(U,1.57079633),u=cc.rectApplyAffineTransform(u,U),B=cc.rectApplyAffineTransform(B,U),G=cc.rectApplyAffineTransform(G,U),C=cc.rectApplyAffineTransform(C,U),H=cc.rectApplyAffineTransform(H,U),E=cc.rectApplyAffineTransform(E,U),z=cc.rectApplyAffineTransform(z,U),v=cc.rectApplyAffineTransform(v,U),D=cc.rectApplyAffineTransform(D,U),A=cc.rectApplyAffineTransform(A,U),F=cc.rectApplyAffineTransform(F,U),x=cc.rectApplyAffineTransform(x,U),I.x=u.x,J.x=B.x,K.x=G.x,L.x=C.x,M.x=H.x,N.x=E.x,O.x=z.x,P.x=v.x,Q.x=D.x,R.x=A.x,S.x=F.x,T.x=x.x,I.y=u.y,J.y=B.y,K.y=G.y,L.y=C.y,M.y=H.y,N.y=E.y,O.y=z.y,P.y=v.y,Q.y=D.y,R.y=A.y,S.y=F.y,T.y=x.y):(U=cc.affineTransformTranslate(U,l.x,l.y),I=cc.rectApplyAffineTransform(I,U),J=cc.rectApplyAffineTransform(J,U),K=cc.rectApplyAffineTransform(K,U),L=cc.rectApplyAffineTransform(L,U),M=cc.rectApplyAffineTransform(M,U),N=cc.rectApplyAffineTransform(N,U),O=cc.rectApplyAffineTransform(O,U),P=cc.rectApplyAffineTransform(P,U),Q=cc.rectApplyAffineTransform(Q,U),R=cc.rectApplyAffineTransform(R,U),S=cc.rectApplyAffineTransform(S,U),T=cc.rectApplyAffineTransform(T,U)),this._centre||(this._centre=new cc.Sprite),this._centre.initWithTexture(j,L,k),L.width>0&&L.height>0&&this._renderers.push(this._centre),this._top||(this._top=new cc.Sprite),this._top.initWithTexture(j,T,k),T.width>0&&T.height>0&&this._renderers.push(this._top),this._bottom||(this._bottom=new cc.Sprite),this._bottom.initWithTexture(j,S,k),S.width>0&&S.height>0&&this._renderers.push(this._bottom),this._left||(this._left=new cc.Sprite),this._left.initWithTexture(j,R,k),R.width>0&&R.height>0&&this._renderers.push(this._left),this._right||(this._right=new cc.Sprite),this._right.initWithTexture(j,Q,k),Q.width>0&&Q.height>0&&this._renderers.push(this._right),this._topLeft||(this._topLeft=new cc.Sprite),this._topLeft.initWithTexture(j,P,k),P.width>0&&P.height>0&&this._renderers.push(this._topLeft),this._topRight||(this._topRight=new cc.Sprite),this._topRight.initWithTexture(j,O,k),O.width>0&&O.height>0&&this._renderers.push(this._topRight),this._bottomLeft||(this._bottomLeft=new cc.Sprite),this._bottomLeft.initWithTexture(j,N,k),N.width>0&&N.height>0&&this._renderers.push(this._bottomLeft),this._bottomRight||(this._bottomRight=new cc.Sprite),this._bottomRight.initWithTexture(j,M,k),M.width>0&&M.height>0&&this._renderers.push(this._bottomRight)},updateWithSprite:function(a,b,c,d,e,f){var g=this.getOpacity(),h=this.getColor();if(this._renderers.length=0,a){if(!a.getSpriteFrame())return!1;this._scale9Image||(this._scale9Image=a)}if(!this._scale9Image)return!1;var i=b,j=e,k=this._scale9Image.getTexture(),l=k&&k.isLoaded();if(this._textureLoaded=l,!l)return k.addEventListener("load",function(g){this._positionsAreDirty=!0,this.updateWithSprite(a,b,c,d,e,f),this.setVisible(!0),this.setNodeDirty(),this.dispatchEvent("load")},this),this.setVisible(!1),!0;if(cc._rectEqualToZero(i)){var m=k.getContentSize();i=cc.rect(0,0,m.width,m.height)}return 0===j.width&&0===j.height&&(j=cc.size(i.width,i.height)),this._capInsets=f,this._spriteRect=i,this._offset=d,this._spriteFrameRotated=c,this._originalSize=j,this._preferredSize=j,this._capInsetsInternal=f,this._scale9Enabled?this.createSlicedSprites():this._scale9Image.initWithTexture(k,this._spriteRect,this._spriteFrameRotated),this.setState(this._brightState),this.setContentSize(j),this._spritesGenerated===!0&&(this.setOpacity(g),this.setColor(h)),this._spritesGenerated=!0,!0},updateWithBatchNode:function(a,b,c,d){var e=new cc.Sprite(a.getTexture()),f=cc.p(0,0),g=cc.size(b.width,b.height),h=a.getTexture(),i=h.isLoaded();return this._textureLoaded=i,i?this.updateWithSprite(e,b,c,f,g,d):(h.addEventListener("load",function(e){this._positionsAreDirty=!0,this.updateWithBatchNode(a,b,c,d),this.setVisible(!0),this.setNodeDirty(),this.dispatchEvent("load")},this),this.setVisible(!1),!0)},setSpriteFrame:function(a,b){b||(b=cc.rect());var c=new cc.Sprite(a.getTexture()),d=a.textureLoaded();this._textureLoaded=d,d||a.addEventListener("load",function(a){var b=this._preferredSize,c=0!==b.width&&0!==b.height;c&&(b=cc.size(b.width,b.height)),this.updateWithBatchNode(this._scale9Image,a.getRect(),cc._renderType===cc.game.RENDER_TYPE_WEBGL&&a.isRotated(),this._capInsets),c&&this.setPreferredSize(b),this._positionsAreDirty=!0,this.setNodeDirty(),this.dispatchEvent("load")},this),this.updateWithSprite(c,a.getRect(),a.isRotated(),a.getOffset(),a.getOriginalSize(),b),this._insetLeft=b.x,this._insetTop=b.y,this._insetRight=this._originalSize.width-this._insetLeft-b.width,this._insetBottom=this._originalSize.height-this._insetTop-b.height},setState:function(a){this._renderCmd.setState(a)},setScale9Enabled:function(a){this._scale9Enabled!==a&&(this._scale9Enabled=a,this._renderers.length=0,cc.Node.transformDirty=!0,this._scale9Enabled&&this._scale9Image&&this.updateWithSprite(this._scale9Image,this._spriteRect,this._spriteFrameRotated,this._offset,this._originalSize,this._capInsets),this._positionsAreDirty=!0)},_setRenderersPosition:function(){this._positionsAreDirty&&(this._updatePositions(),this._adjustScale9ImagePosition(),this._positionsAreDirty=!1)},_adjustScale9ImagePosition:function(){var a=this._scale9Image,b=this._contentSize;a&&(a.x=b.width*a.getAnchorPoint().x,a.y=b.height*a.getAnchorPoint().y)},_adjustScale9ImageScale:function(){var a=this._scale9Image,b=this._contentSize;a&&a.setScale(b.width/a.width,b.height/a.height)},setFlippedX:function(a){var b=this.getScaleX();this._flippedX=a,this.setScaleX(b),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.cacheDirty)},isFlippedX:function(){return this._flippedX},setFlippedY:function(a){var b=this.getScaleY();this._flippedY=a,this.setScaleY(b),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.cacheDirty)},isFlippedY:function(){return this._flippedY},setScaleX:function(a){this._flippedX&&(a=-1*a),cc.Node.prototype.setScaleX.call(this,a),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.cacheDirty)},setScaleY:function(a){this._flippedY&&(a=-1*a),cc.Node.prototype.setScaleY.call(this,a),this._renderCmd.setDirtyFlag(cc.Node._dirtyFlags.cacheDirty)},setScale:function(a,b){void 0===b&&(b=a),this.setScaleX(a),this.setScaleY(b)},getScaleX:function(){var a=cc.Node.prototype.getScaleX.call(this);return this._flippedX&&(a=-1*a),a},getScaleY:function(){var a=cc.Node.prototype.getScaleY.call(this);return this._flippedY&&(a=-1*a),a},getScale:function(){return this.getScaleX()!==this.getScaleY()&&cc.log("Scale9Sprite#scale. ScaleX != ScaleY. Don't know which one to return"),this.getScaleX()},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new ccui.Scale9Sprite.CanvasRenderCmd(this):new ccui.Scale9Sprite.WebGLRenderCmd(this)}});var _p=ccui.Scale9Sprite.prototype;cc.EventHelper.prototype.apply(_p),_p.preferredSize,cc.defineGetterSetter(_p,"preferredSize",_p.getPreferredSize,_p.setPreferredSize),_p.capInsets,cc.defineGetterSetter(_p,"capInsets",_p.getCapInsets,_p.setCapInsets),_p.insetLeft,cc.defineGetterSetter(_p,"insetLeft",_p.getInsetLeft,_p.setInsetLeft),_p.insetTop,cc.defineGetterSetter(_p,"insetTop",_p.getInsetTop,_p.setInsetTop),_p.insetRight,cc.defineGetterSetter(_p,"insetRight",_p.getInsetRight,_p.setInsetRight),_p.insetBottom,cc.defineGetterSetter(_p,"insetBottom",_p.getInsetBottom,_p.setInsetBottom),_p=null,ccui.Scale9Sprite.create=function(a,b,c){return new ccui.Scale9Sprite(a,b,c)},ccui.Scale9Sprite.createWithSpriteFrame=function(a,b){return new ccui.Scale9Sprite(a,b)},ccui.Scale9Sprite.createWithSpriteFrameName=function(a,b){return new ccui.Scale9Sprite(a,b)},ccui.Scale9Sprite.POSITIONS_CENTRE=0,ccui.Scale9Sprite.POSITIONS_TOP=1,ccui.Scale9Sprite.POSITIONS_LEFT=2,ccui.Scale9Sprite.POSITIONS_RIGHT=3,ccui.Scale9Sprite.POSITIONS_BOTTOM=4,ccui.Scale9Sprite.POSITIONS_TOPRIGHT=5,ccui.Scale9Sprite.POSITIONS_TOPLEFT=6,ccui.Scale9Sprite.POSITIONS_BOTTOMRIGHT=7,ccui.Scale9Sprite.state={NORMAL:0,GRAY:1},function(){ccui.Scale9Sprite.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._cachedParent=null,this._cacheDirty=!1,this._state=ccui.Scale9Sprite.state.NORMAL;var b=this._node,c=this._cacheCanvas=document.createElement("canvas");c.width=1,c.height=1,this._cacheContext=new cc.CanvasContextWrapper(c.getContext("2d"));var d=this._cacheTexture=new cc.Texture2D;d.initWithElement(c),d.handleLoadedTexture(),this._cacheSprite=new cc.Sprite(d),this._cacheSprite.setAnchorPoint(0,0),b.addChild(this._cacheSprite)};var a=ccui.Scale9Sprite.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=ccui.Scale9Sprite.CanvasRenderCmd,a.visit=function(a){var b=this._node;b._visible&&(b._positionsAreDirty&&(b._updatePositions(),b._positionsAreDirty=!1),cc.Node.CanvasRenderCmd.prototype.visit.call(this,a))},a.transform=function(a){var b=this._node;cc.Node.CanvasRenderCmd.prototype.transform.call(this,a),b._positionsAreDirty&&(b._updatePositions(),b._positionsAreDirty=!1);for(var c=b._children,d=0;de;e++){var f=c[e];if(!f)break;f._renderCmd._updateDisplayColor(a),f._renderCmd._updateColor()}else b._scale9Image&&(b._scale9Image._renderCmd._updateDisplayColor(a),b._scale9Image._renderCmd._updateColor())}},a.updateStatus=function(){var a=cc.Node._dirtyFlags,b=this._dirtyFlag;cc.Node.RenderCmd.prototype.updateStatus.call(this),b&a.cacheDirty&&(this._cacheScale9Sprite(),this._dirtyFlag=this._dirtyFlag&a.cacheDirty^this._dirtyFlag)},a._syncStatus=function(a){var b=cc.Node._dirtyFlags,c=this._dirtyFlag;cc.Node.RenderCmd.prototype._syncStatus.call(this,a),c&b.cacheDirty&&(this._cacheScale9Sprite(),this._dirtyFlag=this._dirtyFlag&b.cacheDirty^this._dirtyFlag)},a._cacheScale9Sprite=function(){var a=this._node;if(a._scale9Image){var b=cc.contentScaleFactor(),c=a._contentSize,d=cc.size(c.width*b,c.height*b),e=this._cacheCanvas,f=this._cacheContext,g=f.getContext(),h=!1;if((e.width!==d.width||e.height!==d.height)&&(e.width=d.width,e.height=d.height,h=!0),cc.renderer._turnToCacheMode(a.__instanceId),a._scale9Enabled){var i=a._renderers;a._setRenderersPosition();for(var j=i.length,k=0;j>k;k++){var l=i[k];if(!l)break;var m=l._renderCmd;m.updateStatus(),cc.renderer.pushRenderCommand(m)}}else{var m=a._scale9Image._renderCmd;a._adjustScale9ImagePosition(),a._adjustScale9ImageScale(),m.updateStatus(),cc.renderer.pushRenderCommand(a._scale9Image._renderCmd)}var n=a._scale9Image.getTexture();n&&this._state===ccui.Scale9Sprite.state.GRAY&&n._switchToGray(!0),g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,d.width,d.height),cc.renderer._renderingToCacheCanvas(f,a.__instanceId,b,b),cc.renderer._turnToNormalMode(),n&&this._state===ccui.Scale9Sprite.state.GRAY&&n._switchToGray(!1),h&&this._cacheSprite.setTextureRect(cc.rect(0,0,c.width,c.height)),this._cacheSprite.getParent()||a.addChild(this._cacheSprite,-1)}},a.setState=function(a){var b=this._node._scale9Image;b&&(this._state=a,this.setDirtyFlag(cc.Node._dirtyFlags.cacheDirty))}}(),function(){if(cc.Node.WebGLRenderCmd){ccui.Scale9Sprite.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._cachedParent=null,this._cacheDirty=!1};var a=ccui.Scale9Sprite.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype);a.constructor=ccui.Scale9Sprite.WebGLRenderCmd,a.visit=function(a){var b=this._node;if(b._visible&&b._scale9Image){if(b._positionsAreDirty&&(b._updatePositions(),b._positionsAreDirty=!1),a=a||this.getParentRenderCmd(),b._parent&&b._parent._renderCmd&&(this._curLevel=b._parent._renderCmd._curLevel+1),this._syncStatus(a),b._scale9Enabled)for(var c=b._renderers,d=c.length,e=0;d>e;e++){var f=c[e];if(!f)break;var g=f._renderCmd;g.visit(this)}else b._adjustScale9ImageScale(),b._adjustScale9ImagePosition(),b._scale9Image._renderCmd.visit(this);this._dirtyFlag=0,cc.Node.WebGLRenderCmd.prototype.visit.call(this,a)}},a.transform=function(a,b){var c=this._node;if(cc.Node.WebGLRenderCmd.prototype.transform.call(this,a,b),c._positionsAreDirty&&(c._updatePositions(),c._positionsAreDirty=!1),c._scale9Enabled)for(var d=c._renderers,e=d.length,f=0;e>f;f++){var g=d[f];if(!g)break;var h=g._renderCmd;h.transform(this,!0)}else c._adjustScale9ImageScale(),c._adjustScale9ImagePosition(),c._scale9Image._renderCmd.transform(this,!0)},a.setDirtyFlag=function(a,b){a===cc.Node._dirtyFlags.cacheDirty&&(a=cc.Node._dirtyFlags.transformDirty),cc.Node.RenderCmd.prototype.setDirtyFlag.call(this,a,b)},a._syncStatus=function(a){cc.Node.WebGLRenderCmd.prototype._syncStatus.call(this,a),this._updateDisplayColor(this._displayedColor),this._updateDisplayOpacity(this._displayedOpacity)},a._updateDisplayColor=function(a){cc.Node.WebGLRenderCmd.prototype._updateDisplayColor.call(this,a);var b=this._node,c=b._scale9Image;if(a=this._displayedColor,b._scale9Enabled)for(var d=b._renderers,e=0;ek&&(g=a.x,i+=k);var l=b.x+d-(a.x+a.width);l>0&&(i-=l);var m=b.y+e-(a.y+a.height);m>0&&(j-=m);var n=b.y-a.y;0>n&&(h=a.x,j+=n),0>i&&(i=0),0>j&&(j=0),this._clippingRect.x=g,this._clippingRect.y=h,this._clippingRect.width=i,this._clippingRect.height=j}else this._clippingRect.x=b.x-d*this._anchorPoint.x,this._clippingRect.y=b.y-e*this._anchorPoint.y,this._clippingRect.width=d,this._clippingRect.height=e;this._clippingRectDirty=!1}return this._clippingRect},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this);var a=this._contentSize;this._setStencilClippingSize(a),this._doLayoutDirty=!0,this._clippingRectDirty=!0,this._backGroundImage&&(this._backGroundImage.setPosition(.5*a.width,.5*a.height),this._backGroundScale9Enabled&&this._backGroundImage instanceof ccui.Scale9Sprite&&this._backGroundImage.setPreferredSize(a)),this._colorRender&&this._colorRender.setContentSize(a),this._gradientRender&&this._gradientRender.setContentSize(a)},setBackGroundImageScale9Enabled:function(a){this._backGroundScale9Enabled!==a&&(this.removeProtectedChild(this._backGroundImage),this._backGroundImage=null,this._backGroundScale9Enabled=a,this._addBackGroundImage(),this.setBackGroundImage(this._backGroundImageFileName,this._bgImageTexType),this.setBackGroundImageCapInsets(this._backGroundImageCapInsets))},isBackGroundImageScale9Enabled:function(){return this._backGroundScale9Enabled},setBackGroundImage:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,null===this._backGroundImage&&(this._addBackGroundImage(),this.setBackGroundImageScale9Enabled(this._backGroundScale9Enabled)),this._backGroundImageFileName=a,this._bgImageTexType=b;var c=this._backGroundImage;switch(this._bgImageTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._backGroundScale9Enabled&&c.setPreferredSize(this._contentSize),this._backGroundImageTextureSize=c.getContentSize(),c.setPosition(.5*this._contentSize.width,.5*this._contentSize.height),this._updateBackGroundImageColor()}},setBackGroundImageCapInsets:function(a){if(a){var b=this._backGroundImageCapInsets;b.x=a.x,b.y=a.y,b.width=a.width,b.height=a.height,this._backGroundScale9Enabled&&this._backGroundImage.setCapInsets(a)}},getBackGroundImageCapInsets:function(){return cc.rect(this._backGroundImageCapInsets)},_supplyTheLayoutParameterLackToChild:function(a){if(a)switch(this._layoutType){case ccui.Layout.ABSOLUTE:break;case ccui.Layout.LINEAR_HORIZONTAL:case ccui.Layout.LINEAR_VERTICAL:var b=a.getLayoutParameter(ccui.LayoutParameter.LINEAR);b||a.setLayoutParameter(new ccui.LinearLayoutParameter);break;case ccui.Layout.RELATIVE:var b=a.getLayoutParameter(ccui.LayoutParameter.RELATIVE);b||a.setLayoutParameter(new ccui.RelativeLayoutParameter)}},_addBackGroundImage:function(){var a=this._contentSize;this._backGroundScale9Enabled?(this._backGroundImage=new ccui.Scale9Sprite,this._backGroundImage.setPreferredSize(a)):this._backGroundImage=new cc.Sprite,this.addProtectedChild(this._backGroundImage,ccui.Layout.BACKGROUND_IMAGE_ZORDER,-1),this._backGroundImage.setPosition(.5*a.width,.5*a.height)},removeBackGroundImage:function(){this._backGroundImage&&(this.removeProtectedChild(this._backGroundImage),this._backGroundImage=null,this._backGroundImageFileName="",this._backGroundImageTextureSize.width=0,this._backGroundImageTextureSize.height=0)},setBackGroundColorType:function(a){if(this._colorType!==a){switch(this._colorType){case ccui.Layout.BG_COLOR_NONE:this._colorRender&&(this.removeProtectedChild(this._colorRender),this._colorRender=null),this._gradientRender&&(this.removeProtectedChild(this._gradientRender),this._gradientRender=null);break;case ccui.Layout.BG_COLOR_SOLID:this._colorRender&&(this.removeProtectedChild(this._colorRender),this._colorRender=null);break;case ccui.Layout.BG_COLOR_GRADIENT:this._gradientRender&&(this.removeProtectedChild(this._gradientRender),this._gradientRender=null)}switch(this._colorType=a,this._colorType){case ccui.Layout.BG_COLOR_NONE:break;case ccui.Layout.BG_COLOR_SOLID:this._colorRender=new cc.LayerColor,this._colorRender.setContentSize(this._contentSize),this._colorRender.setOpacity(this._opacity),this._colorRender.setColor(this._color),this.addProtectedChild(this._colorRender,ccui.Layout.BACKGROUND_RENDERER_ZORDER,-1);break;case ccui.Layout.BG_COLOR_GRADIENT:this._gradientRender=new cc.LayerGradient(cc.color(255,0,0,255),cc.color(0,255,0,255)),this._gradientRender.setContentSize(this._contentSize),this._gradientRender.setOpacity(this._opacity),this._gradientRender.setStartColor(this._startColor),this._gradientRender.setEndColor(this._endColor),this._gradientRender.setVector(this._alongVector),this.addProtectedChild(this._gradientRender,ccui.Layout.BACKGROUND_RENDERER_ZORDER,-1)}}},getBackGroundColorType:function(){return this._colorType},setBackGroundColor:function(a,b){b?(this._startColor.r=a.r,this._startColor.g=a.g,this._startColor.b=a.b,this._gradientRender&&this._gradientRender.setStartColor(a),this._endColor.r=b.r,this._endColor.g=b.g,this._endColor.b=b.b,this._gradientRender&&this._gradientRender.setEndColor(b)):(this._color.r=a.r,this._color.g=a.g,this._color.b=a.b,this._colorRender&&this._colorRender.setColor(a))},getBackGroundColor:function(){var a=this._color;return cc.color(a.r,a.g,a.b,a.a)},getBackGroundStartColor:function(){var a=this._startColor;return cc.color(a.r,a.g,a.b,a.a)},getBackGroundEndColor:function(){var a=this._endColor;return cc.color(a.r,a.g,a.b,a.a)},setBackGroundColorOpacity:function(a){switch(this._opacity=a,this._colorType){case ccui.Layout.BG_COLOR_NONE:break;case ccui.Layout.BG_COLOR_SOLID:this._colorRender.setOpacity(a);break;case ccui.Layout.BG_COLOR_GRADIENT:this._gradientRender.setOpacity(a)}},getBackGroundColorOpacity:function(){return this._opacity},setBackGroundColorVector:function(a){this._alongVector.x=a.x,this._alongVector.y=a.y,this._gradientRender&&this._gradientRender.setVector(a)},getBackGroundColorVector:function(){return this._alongVector},setBackGroundImageColor:function(a){this._backGroundImageColor.r=a.r,this._backGroundImageColor.g=a.g,this._backGroundImageColor.b=a.b,this._updateBackGroundImageColor()},setBackGroundImageOpacity:function(a){this._backGroundImageColor.a=a,this.getBackGroundImageColor()},getBackGroundImageColor:function(){var a=this._backGroundImageColor;return cc.color(a.r,a.g,a.b,a.a)},getBackGroundImageOpacity:function(){return this._backGroundImageColor.a},_updateBackGroundImageColor:function(){this._backGroundImage&&this._backGroundImage.setColor(this._backGroundImageColor)},getBackGroundImageTextureSize:function(){return this._backGroundImageTextureSize},setLayoutType:function(a){this._layoutType=a;for(var b=this._children,c=null,d=0;de;e++){var g=b[e];if(null!==g&&g instanceof ccui.Layout)a=g._getLayoutAccumulatedSize(),c.width+=a.width,c.height+=a.height;else if(g instanceof ccui.Widget){d++;var h=g.getLayoutParameter().getMargin();a=g.getContentSize(),c.width+=a.width+.5*(h.right+h.left),c.height+=a.height+.5*(h.top+h.bottom)}}var i=this.getLayoutType();return i===ccui.Layout.LINEAR_HORIZONTAL&&(c.height=c.height-c.height/d*(d-1)),i===ccui.Layout.LINEAR_VERTICAL&&(c.width=c.width-c.width/d*(d-1)),c},_findNearestChildWidgetIndex:function(a,b){if(null==b||b===this)return this._findFirstFocusEnabledWidgetIndex();var c,d=0,e=this.getChildren(),f=e.length,g=cc.FLT_MAX,h=0;if(a===ccui.Widget.LEFT||a===ccui.Widget.RIGHT||a===ccui.Widget.DOWN||a===ccui.Widget.UP){for(c=this._getWorldCenterPoint(b);f>d;){var i=e[d];if(i&&i instanceof ccui.Widget&&i.isFocusEnabled()){var j=i instanceof ccui.Layout?i._calculateNearestDistance(b):cc.pLength(cc.pSub(this._getWorldCenterPoint(i),c));g>j&&(h=d,g=j)}d++}return h}return cc.log("invalid focus direction!"),0},_findFarthestChildWidgetIndex:function(a,b){if(null==b||b===this)return this._findFirstFocusEnabledWidgetIndex();var c=0,d=this.getChildren(),e=d.length,f=-cc.FLT_MAX,g=0;if(a===ccui.Widget.LEFT||a===ccui.Widget.RIGHT||a===ccui.Widget.DOWN||a===ccui.Widget.UP){for(var h=this._getWorldCenterPoint(b);e>c;){var i=d[c];if(i&&i instanceof ccui.Widget&&i.isFocusEnabled()){var j=i instanceof ccui.Layout?i._calculateFarthestDistance(b):cc.pLength(cc.pSub(this._getWorldCenterPoint(i),h));j>f&&(g=c,f=j)}c++}return g}return cc.log("invalid focus direction!!!"),0},_calculateNearestDistance:function(a){for(var b=cc.FLT_MAX,c=this._getWorldCenterPoint(a),d=this._children,e=0,f=d.length;f>e;e++){var g,h=d[e];if(h instanceof ccui.Layout)g=h._calculateNearestDistance(a);else{if(!(h instanceof ccui.Widget&&h.isFocusEnabled()))continue;g=cc.pLength(cc.pSub(this._getWorldCenterPoint(h),c))}b>g&&(b=g)}return b},_calculateFarthestDistance:function(a){for(var b=-cc.FLT_MAX,c=this._getWorldCenterPoint(a),d=this._children,e=0,f=d.length;f>e;e++){var g,h=d[e];if(h instanceof ccui.Layout)g=h._calculateFarthestDistance(a);else{if(!(h instanceof ccui.Widget&&h.isFocusEnabled()))continue;var i=this._getWorldCenterPoint(h);g=cc.pLength(cc.pSub(i,c))}g>b&&(b=g)}return b},_findProperSearchingFunctor:function(a,b){if(null!=b){var c=this._getWorldCenterPoint(b),d=this._getWorldCenterPoint(this._findFirstNonLayoutWidget());a===ccui.Widget.LEFT?this.onPassFocusToChild=c.x>d.x?this._findNearestChildWidgetIndex.bind(this):this._findFarthestChildWidgetIndex.bind(this):a===ccui.Widget.RIGHT?this.onPassFocusToChild=c.x>d.x?this._findFarthestChildWidgetIndex.bind(this):this._findNearestChildWidgetIndex.bind(this):a===ccui.Widget.DOWN?this.onPassFocusToChild=c.y>d.y?this._findNearestChildWidgetIndex.bind(this):this._findFarthestChildWidgetIndex.bind(this):a===ccui.Widget.UP?this.onPassFocusToChild=c.yb;b++){var d=a[b];if(d instanceof ccui.Layout){var e=d._findFirstNonLayoutWidget();if(e)return e}else if(d instanceof ccui.Widget)return d}return null},_findFirstFocusEnabledWidgetIndex:function(){for(var a=0,b=this.getChildren(),c=b.length;c>a;){var d=b[a];if(d&&d instanceof ccui.Widget&&d.isFocusEnabled())return a;a++}return 0},_findFocusEnabledChildWidgetByIndex:function(a){var b=this._getChildWidgetByIndex(a);return b?b.isFocusEnabled()?b:(a+=1,this._findFocusEnabledChildWidgetByIndex(a)):null},_getWorldCenterPoint:function(a){var b=a instanceof ccui.Layout?a._getLayoutAccumulatedSize():a.getContentSize();return a.convertToWorldSpace(cc.p(b.width/2,b.height/2))},_getNextFocusedWidget:function(a,b){var c=null,d=this._children,e=d.indexOf(b);return e+=1,e=0?(c=this._getChildWidgetByIndex(e),c.isFocusEnabled()?c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,c),c):this._getPreviousFocusedWidget(a,c)):this._loopFocus?this._checkFocusEnabledChild()?(e=d.length-1,c=this._getChildWidgetByIndex(e),c.isFocusEnabled()?c instanceof ccui.Layout?(c._isFocusPassing=!0,c.findNextFocusedWidget(a,c)):(this.dispatchFocusEvent(b,c),c):this._getPreviousFocusedWidget(a,c)):b instanceof ccui.Layout?b:ccui.Widget._focusedWidget:this._isLastWidgetInContainer(b,a)?this._isWidgetAncestorSupportLoopFocus(this,a)?ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this):b instanceof ccui.Layout?b:ccui.Widget._focusedWidget:ccui.Widget.prototype.findNextFocusedWidget.call(this,a,this)},_getChildWidgetByIndex:function(a){for(var b=this._children,c=b.length,d=0,e=a;c>a;){var f=b[a];if(f&&f instanceof ccui.Widget)return f;d++,a++}for(var g=0;e>g;){var h=b[g];if(h&&h instanceof ccui.Widget)return h;d++,g++}return null},_isLastWidgetInContainer:function(a,b){var c=a.getParent();if(null==c||!(c instanceof ccui.Layout))return!0;var d=c.getChildren(),e=d.indexOf(a);if(c.getLayoutType()===ccui.Layout.LINEAR_HORIZONTAL){if(b===ccui.Widget.LEFT)return 0===e?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.RIGHT)return e===d.length-1?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.DOWN)return this._isLastWidgetInContainer(c,b);if(b===ccui.Widget.UP)return this._isLastWidgetInContainer(c,b)}else{if(c.getLayoutType()!==ccui.Layout.LINEAR_VERTICAL)return cc.log("invalid layout Type"),!1;if(b===ccui.Widget.UP)return 0===e?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.DOWN)return e===d.length-1?this._isLastWidgetInContainer(c,b):!1;if(b===ccui.Widget.LEFT)return this._isLastWidgetInContainer(c,b);if(b===ccui.Widget.RIGHT)return this._isLastWidgetInContainer(c,b)}},_isWidgetAncestorSupportLoopFocus:function(a,b){var c=a.getParent();if(null==c||!(c instanceof ccui.Layout))return!1;if(c.isLoopFocus()){var d=c.getLayoutType();return d===ccui.Layout.LINEAR_HORIZONTAL?b===ccui.Widget.LEFT||b===ccui.Widget.RIGHT?!0:this._isWidgetAncestorSupportLoopFocus(c,b):d===ccui.Layout.LINEAR_VERTICAL?b===ccui.Widget.DOWN||b===ccui.Widget.UP?!0:this._isWidgetAncestorSupportLoopFocus(c,b):(cc.assert(0,"invalid layout type"),!1)}return this._isWidgetAncestorSupportLoopFocus(c,b)},_passFocusToChild:function(a,b){if(this._checkFocusEnabledChild()){var c=ccui.Widget.getCurrentFocusedWidget();this._findProperSearchingFunctor(a,c);var d=this.onPassFocusToChild(a,c),e=this._getChildWidgetByIndex(d);return e instanceof ccui.Layout?(e._isFocusPassing=!0,e.findNextFocusedWidget(a,e)):(this.dispatchFocusEvent(b,e),e)}return this},_checkFocusEnabledChild:function(){for(var a=this._children,b=0,c=a.length;c>b;b++){var d=a[b];if(d&&d instanceof ccui.Widget&&d.isFocusEnabled())return!0}return!1},getDescription:function(){return"Layout"},_createCloneInstance:function(){return new ccui.Layout},_copyClonedWidgetChildren:function(a){ccui.Widget.prototype._copyClonedWidgetChildren.call(this,a)},_copySpecialProperties:function(a){a instanceof ccui.Layout&&(this.setBackGroundImageScale9Enabled(a._backGroundScale9Enabled),this.setBackGroundImage(a._backGroundImageFileName,a._bgImageTexType),this.setBackGroundImageCapInsets(a._backGroundImageCapInsets),this.setBackGroundColorType(a._colorType),this.setBackGroundColor(a._color),this.setBackGroundColor(a._startColor,a._endColor),this.setBackGroundColorOpacity(a._opacity),this.setBackGroundColorVector(a._alongVector),this.setLayoutType(a._layoutType),this.setClippingEnabled(a._clippingEnabled),this.setClippingType(a._clippingType),this._loopFocus=a._loopFocus,this.__passFocusToChild=a.__passFocusToChild,this._isInterceptTouch=a._isInterceptTouch)},forceDoLayout:function(){this.requestDoLayout(),this._doLayout()},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new ccui.Layout.WebGLRenderCmd(this):new ccui.Layout.CanvasRenderCmd(this)}});var _p=ccui.Layout.prototype;_p.clippingEnabled,cc.defineGetterSetter(_p,"clippingEnabled",_p.isClippingEnabled,_p.setClippingEnabled),_p.clippingType,cc.defineGetterSetter(_p,"clippingType",null,_p.setClippingType),_p.layoutType,cc.defineGetterSetter(_p,"layoutType",_p.getLayoutType,_p.setLayoutType),_p=null,ccui.Layout.create=function(){return new ccui.Layout},ccui.Layout.BG_COLOR_NONE=0,ccui.Layout.BG_COLOR_SOLID=1,ccui.Layout.BG_COLOR_GRADIENT=2,ccui.Layout.ABSOLUTE=0,ccui.Layout.LINEAR_VERTICAL=1,ccui.Layout.LINEAR_HORIZONTAL=2,ccui.Layout.RELATIVE=3,ccui.Layout.CLIPPING_STENCIL=0,ccui.Layout.CLIPPING_SCISSOR=1,ccui.Layout.BACKGROUND_IMAGE_ZORDER=-1,ccui.Layout.BACKGROUND_RENDERER_ZORDER=-2,function(){ccui.Layout.CanvasRenderCmd=function(a){ccui.ProtectedNode.CanvasRenderCmd.call(this,a),this._needDraw=!1,this._clipElemType=!1,this._locCache=null,this._rendererSaveCmd=new cc.CustomRenderCmd(this,this._onRenderSaveCmd),this._rendererSaveCmdSprite=new cc.CustomRenderCmd(this,this._onRenderSaveSpriteCmd),this._rendererClipCmd=new cc.CustomRenderCmd(this,this._onRenderClipCmd),this._rendererRestoreCmd=new cc.CustomRenderCmd(this,this._onRenderRestoreCmd)};var a=ccui.Layout.CanvasRenderCmd.prototype=Object.create(ccui.ProtectedNode.CanvasRenderCmd.prototype);a.constructor=ccui.Layout.CanvasRenderCmd,a.visit=function(a){var b=this._node;if(b._visible)if(b._adaptRenderers(),b._doLayout(),b._clippingEnabled)switch(b._clippingType){case ccui.Layout.CLIPPING_STENCIL:this.stencilClippingVisit(a);break;case ccui.Layout.CLIPPING_SCISSOR:this.scissorClippingVisit(a)}else ccui.Widget.CanvasRenderCmd.prototype.visit.call(this,a)},a._onRenderSaveCmd=function(a,b,c){var d=a||cc._renderContext,e=d.getContext();if(this._clipElemType){var f=e.canvas;this._locCache=ccui.Layout.CanvasRenderCmd._getSharedCache(),this._locCache.width=f.width,this._locCache.height=f.height;var g=this._locCache.getContext("2d");g.drawImage(f,0,0)}else d.save(),d.save(),d.setTransform(this._worldTransform,b,c)},a._onRenderSaveSpriteCmd=function(a){var b=a||cc._renderContext;this._clipElemType&&b.setCompositeOperation("destination-in")},a._onRenderClipCmd=function(a){var b=a||cc._renderContext,c=b.getContext();this._clipElemType||(b.restore(),c.clip())},a._onRenderRestoreCmd=function(a){var b=a||cc._renderContext,c=b.getContext();this._clipElemType?(c.save(),c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation="destination-over",c.drawImage(this._locCache,0,0),c.restore()):b.restore()},a.rebindStencilRendering=function(a){a._renderCmd.rendering=this.__stencilDraw},a.__stencilDraw=function(a,b,c){for(var d=a||cc._renderContext,e=d.getContext(),f=this._buffer,g=0,h=f.length;h>g;g++){var i=f[g],j=i.verts,k=j[0];e.beginPath(),e.moveTo(k.x*b,-k.y*c);for(var l=1,m=j.length;m>l;l++)e.lineTo(j[l].x*b,-j[l].y*c);e.closePath()}},a.stencilClippingVisit=a.scissorClippingVisit=function(a){var b=this._node;if(b._clippingStencil&&b._clippingStencil.isVisible()){if(this._clipElemType=b._stencil instanceof cc.Sprite,this._syncStatus(a),cc.renderer.pushRenderCommand(this._rendererSaveCmd),this._clipElemType&&(cc.ProtectedNode.prototype.visit.call(b,a),cc.renderer.pushRenderCommand(this._rendererSaveCmdSprite)),b._clippingStencil.visit(this),cc.renderer.pushRenderCommand(this._rendererClipCmd),!this._clipElemType){b.sortAllChildren(),b.sortAllProtectedChildren();for(var c,d=b._children,e=0,f=b._protectedChildren,g=0,h=d.length,i=f.length;h>g&&(c=d[g],c&&c.getLocalZOrder()<0);g++)c.visit(this);for(;i>e&&(c=f[e],c&&c.getLocalZOrder()<0);e++)c.visit(this);for(;h>g;g++)d[g].visit(this);for(;i>e;e++)f[e].visit(this);cc.renderer.pushRenderCommand(this._rendererRestoreCmd)}this._dirtyFlag=0}},ccui.Layout.CanvasRenderCmd._getSharedCache=function(){return cc.ClippingNode._sharedCache||(cc.ClippingNode._sharedCache=document.createElement("canvas"))}}(),function(){if(ccui.ProtectedNode.WebGLRenderCmd){ccui.Layout.WebGLRenderCmd=function(a){ccui.ProtectedNode.WebGLRenderCmd.call(this,a),this._needDraw=!1,this._currentStencilEnabled=0,this._currentStencilWriteMask=0,this._currentStencilFunc=0,this._currentStencilRef=0,this._currentStencilValueMask=0,this._currentStencilFail=0,this._currentStencilPassDepthFail=0,this._currentStencilPassDepthPass=0,this._currentDepthWriteMask=!1,this._mask_layer_le=0,this._beforeVisitCmdStencil=new cc.CustomRenderCmd(this,this._onBeforeVisitStencil),this._afterDrawStencilCmd=new cc.CustomRenderCmd(this,this._onAfterDrawStencil),this._afterVisitCmdStencil=new cc.CustomRenderCmd(this,this._onAfterVisitStencil),this._beforeVisitCmdScissor=new cc.CustomRenderCmd(this,this._onBeforeVisitScissor),this._afterVisitCmdScissor=new cc.CustomRenderCmd(this,this._onAfterVisitScissor)};var a=ccui.Layout.WebGLRenderCmd.prototype=Object.create(ccui.ProtectedNode.WebGLRenderCmd.prototype);a.constructor=ccui.Layout.WebGLRenderCmd,a.visit=function(a){var b=this._node;if(b._visible)if(b._adaptRenderers(),b._doLayout(),b._clippingEnabled)switch(b._clippingType){case ccui.Layout.CLIPPING_STENCIL:this.stencilClippingVisit(a);break;case ccui.Layout.CLIPPING_SCISSOR:this.scissorClippingVisit(a)}else ccui.Widget.WebGLRenderCmd.prototype.visit.call(this,a)},a._onBeforeVisitStencil=function(a){var b=a||cc._renderContext;ccui.Layout.WebGLRenderCmd._layer++;var c=1<d&&(f=g[d],f&&f.getLocalZOrder()<0);d++)f.visit(this);for(;j>e&&(f=h[e],f&&f.getLocalZOrder()<0);e++)f.visit(this);for(;i>d;d++)g[d].visit(this);for(;j>e;e++)h[e].visit(this);cc.renderer.pushRenderCommand(this._afterVisitCmdStencil),c.top=c.stack.pop()}},a.scissorClippingVisit=function(a){cc.renderer.pushRenderCommand(this._beforeVisitCmdScissor),cc.ProtectedNode.prototype.visit.call(this._node,a),cc.renderer.pushRenderCommand(this._afterVisitCmdScissor)},ccui.Layout.WebGLRenderCmd._layer=-1,ccui.Layout.WebGLRenderCmd._visit_once=null}}(),ccui.Margin=ccui.Class.extend({left:0,top:0,right:0,bottom:0,ctor:function(a,b,c,d){void 0!==a&&void 0===b&&(this.left=a.left,this.top=a.top,this.right=a.right,this.bottom=a.bottom),void 0!==d&&(this.left=a,this.top=b,this.right=c,this.bottom=d)},setMargin:function(a,b,c,d){this.left=a,this.top=b,this.right=c,this.bottom=d},equals:function(a){return this.left===a.left&&this.top===a.top&&this.right===a.right&&this.bottom===a.bottom}}),ccui.MarginZero=function(){return new ccui.Margin(0,0,0,0)},ccui.LayoutParameter=ccui.Class.extend({_margin:null,_layoutParameterType:null,ctor:function(){this._margin=new ccui.Margin,this._layoutParameterType=ccui.LayoutParameter.NONE},setMargin:function(a){cc.isObject(a)?(this._margin.left=a.left,this._margin.top=a.top,this._margin.right=a.right,this._margin.bottom=a.bottom):(this._margin.left=arguments[0],this._margin.top=arguments[1],this._margin.right=arguments[2],this._margin.bottom=arguments[3])},getMargin:function(){return this._margin},getLayoutType:function(){return this._layoutParameterType},clone:function(){var a=this._createCloneInstance();return a._copyProperties(this),a},_createCloneInstance:function(){return new ccui.LayoutParameter},_copyProperties:function(a){this._margin.bottom=a._margin.bottom,this._margin.left=a._margin.left,this._margin.right=a._margin.right,this._margin.top=a._margin.top}}),ccui.LayoutParameter.create=function(){return new ccui.LayoutParameter},ccui.LayoutParameter.NONE=0,ccui.LayoutParameter.LINEAR=1,ccui.LayoutParameter.RELATIVE=2,ccui.LinearLayoutParameter=ccui.LayoutParameter.extend({_linearGravity:null,ctor:function(){ccui.LayoutParameter.prototype.ctor.call(this),this._linearGravity=ccui.LinearLayoutParameter.NONE,this._layoutParameterType=ccui.LayoutParameter.LINEAR},setGravity:function(a){this._linearGravity=a},getGravity:function(){return this._linearGravity},_createCloneInstance:function(){return new ccui.LinearLayoutParameter},_copyProperties:function(a){ccui.LayoutParameter.prototype._copyProperties.call(this,a),a instanceof ccui.LinearLayoutParameter&&this.setGravity(a._linearGravity)}}),ccui.LinearLayoutParameter.create=function(){return new ccui.LinearLayoutParameter},ccui.LinearLayoutParameter.NONE=0,ccui.LinearLayoutParameter.LEFT=1,ccui.LinearLayoutParameter.TOP=2,ccui.LinearLayoutParameter.RIGHT=3,ccui.LinearLayoutParameter.BOTTOM=4,ccui.LinearLayoutParameter.CENTER_VERTICAL=5,ccui.LinearLayoutParameter.CENTER_HORIZONTAL=6,ccui.RelativeLayoutParameter=ccui.LayoutParameter.extend({_relativeAlign:null,_relativeWidgetName:"",_relativeLayoutName:"",_put:!1,ctor:function(){ +ccui.LayoutParameter.prototype.ctor.call(this),this._relativeAlign=ccui.RelativeLayoutParameter.NONE,this._relativeWidgetName="",this._relativeLayoutName="",this._put=!1,this._layoutParameterType=ccui.LayoutParameter.RELATIVE},setAlign:function(a){this._relativeAlign=a},getAlign:function(){return this._relativeAlign},setRelativeToWidgetName:function(a){this._relativeWidgetName=a},getRelativeToWidgetName:function(){return this._relativeWidgetName},setRelativeName:function(a){this._relativeLayoutName=a},getRelativeName:function(){return this._relativeLayoutName},_createCloneInstance:function(){return new ccui.RelativeLayoutParameter},_copyProperties:function(a){ccui.LayoutParameter.prototype._copyProperties.call(this,a),a instanceof ccui.RelativeLayoutParameter&&(this.setAlign(a._relativeAlign),this.setRelativeToWidgetName(a._relativeWidgetName),this.setRelativeName(a._relativeLayoutName))}}),ccui.RelativeLayoutParameter.create=function(){return new ccui.RelativeLayoutParameter},ccui.RelativeLayoutParameter.NONE=0,ccui.RelativeLayoutParameter.PARENT_TOP_LEFT=1,ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL=2,ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT=3,ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL=4,ccui.RelativeLayoutParameter.CENTER_IN_PARENT=5,ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL=6,ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM=7,ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL=8,ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM=9,ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN=10,ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER=11,ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN=12,ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN=13,ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER=14,ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN=15,ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN=16,ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER=17,ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN=18,ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN=19,ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER=20,ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN=21,ccui.LINEAR_GRAVITY_NONE=0,ccui.LINEAR_GRAVITY_LEFT=1,ccui.LINEAR_GRAVITY_TOP=2,ccui.LINEAR_GRAVITY_RIGHT=3,ccui.LINEAR_GRAVITY_BOTTOM=4,ccui.LINEAR_GRAVITY_CENTER_VERTICAL=5,ccui.LINEAR_GRAVITY_CENTER_HORIZONTAL=6,ccui.RELATIVE_ALIGN_NONE=0,ccui.RELATIVE_ALIGN_PARENT_TOP_LEFT=1,ccui.RELATIVE_ALIGN_PARENT_TOP_CENTER_HORIZONTAL=2,ccui.RELATIVE_ALIGN_PARENT_TOP_RIGHT=3,ccui.RELATIVE_ALIGN_PARENT_LEFT_CENTER_VERTICAL=4,ccui.RELATIVE_ALIGN_PARENT_CENTER=5,ccui.RELATIVE_ALIGN_PARENT_RIGHT_CENTER_VERTICAL=6,ccui.RELATIVE_ALIGN_PARENT_LEFT_BOTTOM=7,ccui.RELATIVE_ALIGN_PARENT_BOTTOM_CENTER_HORIZONTAL=8,ccui.RELATIVE_ALIGN_PARENT_RIGHT_BOTTOM=9,ccui.RELATIVE_ALIGN_LOCATION_ABOVE_LEFT=10,ccui.RELATIVE_ALIGN_LOCATION_ABOVE_CENTER=11,ccui.RELATIVE_ALIGN_LOCATION_ABOVE_RIGHT=12,ccui.RELATIVE_ALIGN_LOCATION_LEFT_TOP=13,ccui.RELATIVE_ALIGN_LOCATION_LEFT_CENTER=14,ccui.RELATIVE_ALIGN_LOCATION_LEFT_BOTTOM=15,ccui.RELATIVE_ALIGN_LOCATION_RIGHT_TOP=16,ccui.RELATIVE_ALIGN_LOCATION_RIGHT_CENTER=17,ccui.RELATIVE_ALIGN_LOCATION_RIGHT_BOTTOM=18,ccui.RELATIVE_ALIGN_LOCATION_BELOW_TOP=19,ccui.RELATIVE_ALIGN_LOCATION_BELOW_CENTER=20,ccui.RELATIVE_ALIGN_LOCATION_BELOW_BOTTOM=21,ccui.getLayoutManager=function(a){switch(a){case ccui.Layout.LINEAR_VERTICAL:return ccui.linearVerticalLayoutManager;case ccui.Layout.LINEAR_HORIZONTAL:return ccui.linearHorizontalLayoutManager;case ccui.Layout.RELATIVE:return ccui.relativeLayoutManager}return null},ccui.linearVerticalLayoutManager={_doLayout:function(a){for(var b=a._getLayoutContentSize(),c=a._getLayoutElements(),d=b.height,e=0,f=c.length;f>e;e++){var g=c[e];if(g){var h=g.getLayoutParameter();if(h){var i=h.getGravity(),j=g.getAnchorPoint(),k=g.getContentSize(),l=j.x*k.width,m=d-(1-j.y)*k.height;switch(i){case ccui.LinearLayoutParameter.NONE:case ccui.LinearLayoutParameter.LEFT:break;case ccui.LinearLayoutParameter.RIGHT:l=b.width-(1-j.x)*k.width;break;case ccui.LinearLayoutParameter.CENTER_HORIZONTAL:l=b.width/2-k.width*(.5-j.x)}var n=h.getMargin();l+=n.left,m-=n.top,g.setPosition(l,m),d=g.getPositionY()-j.y*k.height-n.bottom}}}}},ccui.linearHorizontalLayoutManager={_doLayout:function(a){for(var b=a._getLayoutContentSize(),c=a._getLayoutElements(),d=0,e=0,f=c.length;f>e;e++){var g=c[e];if(g){var h=g.getLayoutParameter();if(h){var i=h.getGravity(),j=g.getAnchorPoint(),k=g.getContentSize(),l=d+j.x*k.width,m=b.height-(1-j.y)*k.height;switch(i){case ccui.LinearLayoutParameter.NONE:case ccui.LinearLayoutParameter.TOP:break;case ccui.LinearLayoutParameter.BOTTOM:m=j.y*k.height;break;case ccui.LinearLayoutParameter.CENTER_VERTICAL:m=b.height/2-k.height*(.5-j.y)}var n=h.getMargin();l+=n.left,m-=n.top,g.setPosition(l,m),d=g.getRightBoundary()+n.right}}}}},ccui.relativeLayoutManager={_unlayoutChildCount:0,_widgetChildren:[],_widget:null,_finalPositionX:0,_finalPositionY:0,_relativeWidgetLP:null,_doLayout:function(a){this._widgetChildren=this._getAllWidgets(a);for(var b=this._widgetChildren;this._unlayoutChildCount>0;){for(var c=0,d=b.length;d>c;c++){this._widget=b[c];var e=this._widget.getLayoutParameter();if(e){if(e._put)continue;var f=this._calculateFinalPositionWithRelativeWidget(a);if(!f)continue;this._calculateFinalPositionWithRelativeAlign(),this._widget.setPosition(this._finalPositionX,this._finalPositionY),e._put=!0}}this._unlayoutChildCount--}this._widgetChildren.length=0},_getAllWidgets:function(a){var b=a._getLayoutElements(),c=this._widgetChildren;c.length=0;for(var d=0,e=b.length;e>d;d++){var f=b[d];if(f){var g=f.getLayoutParameter();g._put=!1,this._unlayoutChildCount++,c.push(f)}}return c},_getRelativeWidget:function(a){var b=null,c=a.getLayoutParameter(),d=c.getRelativeToWidgetName();if(d&&0!==d.length)for(var e=this._widgetChildren,f=0,g=e.length;g>f;f++){var h=e[f];if(h){var i=h.getLayoutParameter();if(i&&i.getRelativeName()===d){b=h,this._relativeWidgetLP=i;break}}}return b},_calculateFinalPositionWithRelativeWidget:function(a){var b=this._widget,c=b.getAnchorPoint(),d=b.getContentSize();this._finalPositionX=0,this._finalPositionY=0;var e=this._getRelativeWidget(b),f=b.getLayoutParameter(),g=f.getAlign(),h=a._getLayoutContentSize();switch(g){case ccui.RelativeLayoutParameter.NONE:case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:this._finalPositionX=c.x*d.width,this._finalPositionY=h.height-(1-c.y)*d.height;break;case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:this._finalPositionX=.5*h.width-d.width*(.5-c.x),this._finalPositionY=h.height-(1-c.y)*d.height;break;case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:this._finalPositionX=h.width-(1-c.x)*d.width,this._finalPositionY=h.height-(1-c.y)*d.height;break;case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:this._finalPositionX=c.x*d.width,this._finalPositionY=.5*h.height-d.height*(.5-c.y);break;case ccui.RelativeLayoutParameter.CENTER_IN_PARENT:this._finalPositionX=.5*h.width-d.width*(.5-c.x),this._finalPositionY=.5*h.height-d.height*(.5-c.y);break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:this._finalPositionX=h.width-(1-c.x)*d.width,this._finalPositionY=.5*h.height-d.height*(.5-c.y);break;case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:this._finalPositionX=c.x*d.width,this._finalPositionY=c.y*d.height;break;case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:this._finalPositionX=.5*h.width-d.width*(.5-c.x),this._finalPositionY=c.y*d.height;break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:this._finalPositionX=h.width-(1-c.x)*d.width,this._finalPositionY=c.y*d.height;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()+c.y*d.height,this._finalPositionX=e.getLeftBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;var i=e.getContentSize();this._finalPositionY=e.getTopBoundary()+c.y*d.height,this._finalPositionX=e.getLeftBoundary()+.5*i.width+c.x*d.width-.5*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()+c.y*d.height,this._finalPositionX=e.getRightBoundary()-(1-c.x)*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()-(1-c.y)*d.height,this._finalPositionX=e.getLeftBoundary()-(1-c.x)*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;var i=e.getContentSize();this._finalPositionX=e.getLeftBoundary()-(1-c.x)*d.width,this._finalPositionY=e.getBottomBoundary()+.5*i.height+c.y*d.height-.5*d.height}break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getBottomBoundary()+c.y*d.height,this._finalPositionX=e.getLeftBoundary()-(1-c.x)*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getTopBoundary()-(1-c.y)*d.height,this._finalPositionX=e.getRightBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;var i=e.getContentSize(),j=e.getRightBoundary();this._finalPositionX=j+c.x*d.width,this._finalPositionY=e.getBottomBoundary()+.5*i.height+c.y*d.height-.5*d.height}break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getBottomBoundary()+c.y*d.height,this._finalPositionX=e.getRightBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getBottomBoundary()-(1-c.y)*d.height,this._finalPositionX=e.getLeftBoundary()+c.x*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;var i=e.getContentSize();this._finalPositionY=e.getBottomBoundary()-(1-c.y)*d.height,this._finalPositionX=e.getLeftBoundary()+.5*i.width+c.x*d.width-.5*d.width}break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:if(e){if(this._relativeWidgetLP&&!this._relativeWidgetLP._put)return!1;this._finalPositionY=e.getBottomBoundary()-(1-c.y)*d.height,this._finalPositionX=e.getRightBoundary()-(1-c.x)*d.width}}return!0},_calculateFinalPositionWithRelativeAlign:function(){var a=this._widget.getLayoutParameter(),b=a.getMargin(),c=a.getAlign();switch(c){case ccui.RelativeLayoutParameter.NONE:case ccui.RelativeLayoutParameter.PARENT_TOP_LEFT:this._finalPositionX+=b.left,this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.PARENT_TOP_CENTER_HORIZONTAL:this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.PARENT_TOP_RIGHT:this._finalPositionX-=b.right,this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.PARENT_LEFT_CENTER_VERTICAL:this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.CENTER_IN_PARENT:break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_CENTER_VERTICAL:this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.PARENT_LEFT_BOTTOM:this._finalPositionX+=b.left,this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.PARENT_BOTTOM_CENTER_HORIZONTAL:this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.PARENT_RIGHT_BOTTOM:this._finalPositionX-=b.right,this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_LEFTALIGN:this._finalPositionY+=b.bottom,this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_RIGHTALIGN:this._finalPositionY+=b.bottom,this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.LOCATION_ABOVE_CENTER:this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_TOPALIGN:this._finalPositionX-=b.right,this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_BOTTOMALIGN:this._finalPositionX-=b.right,this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_LEFT_OF_CENTER:this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_TOPALIGN:this._finalPositionX+=b.left,this._finalPositionY-=b.top;break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_BOTTOMALIGN:this._finalPositionX+=b.left,this._finalPositionY+=b.bottom;break;case ccui.RelativeLayoutParameter.LOCATION_RIGHT_OF_CENTER:this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_LEFTALIGN:this._finalPositionY-=b.top,this._finalPositionX+=b.left;break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_RIGHTALIGN:this._finalPositionY-=b.top,this._finalPositionX-=b.right;break;case ccui.RelativeLayoutParameter.LOCATION_BELOW_CENTER:this._finalPositionY-=b.top}}},ccui.HBox=ccui.Layout.extend({ctor:function(a){ccui.Layout.prototype.ctor.call(this,a),void 0!==a?this.initWithSize(a):this.init()},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL),!0):!1},initWithSize:function(a){return this.init()?(this.setContentSize(a),!0):!1}}),ccui.HBox.create=function(a){return new ccui.HBox(a)},ccui.RelativeBox=ccui.Layout.extend({ctor:function(a){a?this.initWithSize(a):this.init()},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.RELATIVE),!0):!1},initWithSize:function(a){return this.init()?(this.setContentSize(a),!0):!1}}),ccui.RelativeBox.create=function(a){return new ccui.RelativeBox(a)},ccui.VBox=ccui.Layout.extend({ctor:function(a){ccui.Layout.prototype.ctor.call(this,a),void 0!==a?this.initWithSize(a):this.init()},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.LINEAR_VERTICAL),!0):!1},initWithSize:function(a){return this.init()?(this.setContentSize(a),!0):!1}}),ccui.VBox.create=function(a){return new ccui.VBox(a)},ccui.helper={seekWidgetByTag:function(a,b){if(!a)return null;if(a.getTag()===b)return a;for(var c=a.getChildren(),d=c.length,e=0;d>e;e++){var f=c[e],g=ccui.helper.seekWidgetByTag(f,b);if(null!==g)return g}return null},seekWidgetByName:function(a,b){if(!a)return null;if(a.getName()===b)return a;for(var c=a.getChildren(),d=c.length,e=0;d>e;e++){var f=c[e],g=ccui.helper.seekWidgetByName(f,b);if(null!==g)return g}return null},seekWidgetByRelativeName:function(a,b){if(!a)return null;for(var c=a.getChildren(),d=c.length,e=0;d>e;e++){var f=c[e],g=f.getLayoutParameter(ccui.LayoutParameter.RELATIVE);if(g&&g.getRelativeName()===b)return f}return null},seekActionWidgetByActionTag:function(a,b){if(!a)return null;if(a.getActionTag()===b)return a;for(var c=a.getChildren(),d=0;dd;d++){b=c[d];var f=b.getComponent(ccui.LayoutComponent.NAME),g=b.getParent();null!=f&&null!==g&&f.refreshLayout&&f.refreshLayout()}},changeLayoutSystemActiveState:function(a){this._activeLayout=a},restrictCapInsetRect:function(a,b){var c=a.x,d=a.y,e=a.width,f=a.height;return b.width0?this._titleRenderer.getContentSize():cc.size(this._normalTextureSize)},loadTextures:function(a,b,c,d){this.loadTextureNormal(a,d),this.loadTexturePressed(b,d),this.loadTextureDisabled(c,d)},loadTextureNormal:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._normalFileName=a,this._normalTexType=b;var c=this,d=this._buttonNormalRenderer;switch(d._textureLoaded||d.addEventListener("load",function(){c.loadTextureNormal(c._normalFileName,c._normalTexType)}),this._normalTexType){case ccui.Widget.LOCAL_TEXTURE:d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:d.initWithSpriteFrameName(a)}this._normalTextureLoaded=d._textureLoaded,this._normalTextureSize=this._buttonNormalRenderer.getContentSize(),this._updateChildrenDisplayedRGBA(),this._unifySize?this._scale9Enabled&&(d.setCapInsets(this._capInsetsNormal),this._updateContentSizeWithTextureSize(this._getNormalSize())):this._updateContentSizeWithTextureSize(this._normalTextureSize),this._normalTextureAdaptDirty=!0,this._findLayout()}},loadTexturePressed:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._clickedFileName=a,this._pressedTexType=b;var c=this,d=this._buttonClickedRenderer;switch(d._textureLoaded||d.addEventListener("load",function(){c.loadTexturePressed(c._clickedFileName,c._pressedTexType)}),this._pressedTexType){case ccui.Widget.LOCAL_TEXTURE:d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:d.initWithSpriteFrameName(a)}this._scale9Enabled&&d.setCapInsets(this._capInsetsPressed),this._pressedTextureSize=this._buttonClickedRenderer.getContentSize(),this._updateChildrenDisplayedRGBA(),this._pressedTextureLoaded=!0,this._pressedTextureAdaptDirty=!0,this._findLayout()}},loadTextureDisabled:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._disabledFileName=a,this._disabledTexType=b;var c=this,d=this._buttonDisableRenderer;switch(d._textureLoaded||d.addEventListener("load",function(){c.loadTextureDisabled(c._disabledFileName,c._disabledTexType)}),this._disabledTexType){case ccui.Widget.LOCAL_TEXTURE:d.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:d.initWithSpriteFrameName(a)}this._scale9Enabled&&d.setCapInsets(this._capInsetsDisabled),this._disabledTextureSize=this._buttonDisableRenderer.getContentSize(),this._updateChildrenDisplayedRGBA(),this._disabledTextureLoaded=!0,this._disabledTextureAdaptDirty=!0,this._findLayout()}},setCapInsets:function(a){this.setCapInsetsNormalRenderer(a),this.setCapInsetsPressedRenderer(a),this.setCapInsetsDisabledRenderer(a)},setCapInsetsNormalRenderer:function(a){if(a){var b=a.x,c=a.y,d=a.width,e=a.height;this._normalTextureSize.widthb.width?a.width:b.width,d=a.height>b.height?a.height:b.height;return cc.size(c,d)}});var _p=ccui.Button.prototype;_p.titleText,cc.defineGetterSetter(_p,"titleText",_p.getTitleText,_p.setTitleText),_p.titleFont,cc.defineGetterSetter(_p,"titleFont",_p._getTitleFont,_p._setTitleFont),_p.titleFontSize,cc.defineGetterSetter(_p,"titleFontSize",_p.getTitleFontSize,_p.setTitleFontSize),_p.titleFontName,cc.defineGetterSetter(_p,"titleFontName",_p.getTitleFontName,_p.setTitleFontName),_p.titleColor,cc.defineGetterSetter(_p,"titleColor",_p.getTitleColor,_p.setTitleColor),_p=null,ccui.Button.create=function(a,b,c,d){return new ccui.Button(a,b,c,d)},ccui.Button.NORMAL_RENDERER_ZORDER=-2,ccui.Button.PRESSED_RENDERER_ZORDER=-2,ccui.Button.DISABLED_RENDERER_ZORDER=-2,ccui.Button.TITLE_RENDERER_ZORDER=-1,ccui.Button.ZOOM_ACTION_TIME_STEP=.05,ccui.Button.SYSTEM=0,ccui.Button.TTF=1,ccui.CheckBox=ccui.Widget.extend({_backGroundBoxRenderer:null,_backGroundSelectedBoxRenderer:null,_frontCrossRenderer:null,_backGroundBoxDisabledRenderer:null,_frontCrossDisabledRenderer:null,_isSelected:!0,_checkBoxEventListener:null,_checkBoxEventSelector:null,_backGroundTexType:ccui.Widget.LOCAL_TEXTURE,_backGroundSelectedTexType:ccui.Widget.LOCAL_TEXTURE,_frontCrossTexType:ccui.Widget.LOCAL_TEXTURE,_backGroundDisabledTexType:ccui.Widget.LOCAL_TEXTURE,_frontCrossDisabledTexType:ccui.Widget.LOCAL_TEXTURE,_backGroundFileName:"",_backGroundSelectedFileName:"",_frontCrossFileName:"",_backGroundDisabledFileName:"",_frontCrossDisabledFileName:"",_className:"CheckBox",_zoomScale:.1,_backgroundTextureScaleX:.1,_backgroundTextureScaleY:.1,_backGroundBoxRendererAdaptDirty:!0,_backGroundSelectedBoxRendererAdaptDirty:!0,_frontCrossRendererAdaptDirty:!0,_backGroundBoxDisabledRendererAdaptDirty:!0,_frontCrossDisabledRendererAdaptDirty:!0,ctor:function(a,b,c,d,e,f){ccui.Widget.prototype.ctor.call(this),this.setTouchEnabled(!0);for(var g=0,h=0;h100&&(a=100),0>a&&(a=0),a!==this._percent&&(this._percent=a,this._setPercent(a))},_setPercent:function(){var a,b,c,d;this._totalLength<=0||(a=this._percent/100,this._scale9Enabled?this._setScale9Scale():(c=this._barRenderer,d=this._barRendererTextureSize,b=c.getTextureRect(),b.width=d.width*a,c.setTextureRect(cc.rect(b.x,b.y,d.width*a,d.height),c._rectRotated)))},setContentSize:function(a,b){ccui.Widget.prototype.setContentSize.call(this,a,b),this._totalLength=void 0===b?a.width:a},getPercent:function(){return this._percent},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this),this._barRendererAdaptDirty=!0},_adaptRenderers:function(){this._barRendererAdaptDirty&&(this._barRendererScaleChangedWithSize(),this._barRendererAdaptDirty=!1)},ignoreContentAdaptWithSize:function(a){(!this._scale9Enabled||this._scale9Enabled&&!a)&&(ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a)},getVirtualRendererSize:function(){return cc.size(this._barRendererTextureSize)},getVirtualRenderer:function(){return this._barRenderer},_barRendererScaleChangedWithSize:function(){var a=this._barRenderer,b=this._contentSize;if(this._unifySize)this._totalLength=this._contentSize.width,this.setPercent(this._percent);else if(this._ignoreSize)this._scale9Enabled||(this._totalLength=this._barRendererTextureSize.width,a.setScale(1));else if(this._totalLength=b.width,this._scale9Enabled)this._setScale9Scale(),a.setScale(1);else{var c=this._barRendererTextureSize;if(c.width<=0||c.height<=0)return void a.setScale(1);var d=b.width/c.width,e=b.height/c.height;a.setScaleX(d),a.setScaleY(e)}switch(this._direction){case ccui.LoadingBar.TYPE_LEFT:a.setPosition(0,.5*b.height);break;case ccui.LoadingBar.TYPE_RIGHT:a.setPosition(this._totalLength,.5*b.height)}},_setScale9Scale:function(){var a=this._percent/100*this._totalLength;this._barRenderer.setPreferredSize(cc.size(a,this._contentSize.height))},getDescription:function(){return"LoadingBar"},_createCloneInstance:function(){return new ccui.LoadingBar},_copySpecialProperties:function(a){a instanceof ccui.LoadingBar&&(this._prevIgnoreSize=a._prevIgnoreSize,this.setScale9Enabled(a._scale9Enabled),this.loadTexture(a._textureFile,a._renderBarTexType),this.setCapInsets(a._capInsets),this.setPercent(a._percent),this.setDirection(a._direction))}});var _p=ccui.LoadingBar.prototype;_p.direction,cc.defineGetterSetter(_p,"direction",_p.getDirection,_p.setDirection),_p.percent,cc.defineGetterSetter(_p,"percent",_p.getPercent,_p.setPercent),_p=null,ccui.LoadingBar.create=function(a,b){return new ccui.LoadingBar(a,b)},ccui.LoadingBar.TYPE_LEFT=0,ccui.LoadingBar.TYPE_RIGHT=1,ccui.LoadingBar.RENDERER_ZORDER=-1,ccui.Slider=ccui.Widget.extend({_barRenderer:null,_progressBarRenderer:null,_barTextureSize:null,_progressBarTextureSize:null,_slidBallNormalRenderer:null,_slidBallPressedRenderer:null,_slidBallDisabledRenderer:null,_slidBallRenderer:null,_barLength:0,_percent:0,_scale9Enabled:!1,_prevIgnoreSize:!0,_textureFile:"",_progressBarTextureFile:"",_slidBallNormalTextureFile:"",_slidBallPressedTextureFile:"",_slidBallDisabledTextureFile:"",_capInsetsBarRenderer:null,_capInsetsProgressBarRenderer:null,_sliderEventListener:null,_sliderEventSelector:null,_barTexType:ccui.Widget.LOCAL_TEXTURE,_progressBarTexType:ccui.Widget.LOCAL_TEXTURE,_ballNTexType:ccui.Widget.LOCAL_TEXTURE,_ballPTexType:ccui.Widget.LOCAL_TEXTURE,_ballDTexType:ccui.Widget.LOCAL_TEXTURE,_isTextureLoaded:!1,_className:"Slider",_barRendererAdaptDirty:!0,_progressBarRendererDirty:!0,_unifySize:!1,_zoomScale:.1,_sliderBallNormalTextureScaleX:1,_sliderBallNormalTextureScaleY:1,ctor:function(a,b,c){this._barTextureSize=cc.size(0,0),this._progressBarTextureSize=cc.size(0,0),this._capInsetsBarRenderer=cc.rect(0,0,0,0),this._capInsetsProgressBarRenderer=cc.rect(0,0,0,0),ccui.Widget.prototype.ctor.call(this),c=null==c?0:c,this.setTouchEnabled(!0),a&&this.loadBarTexture(a,c),b&&this.loadSlidBallTextures(b,c)},init:function(){return ccui.Widget.prototype.init.call(this)},_initRenderer:function(){this._barRenderer=new cc.Sprite,this._progressBarRenderer=new cc.Sprite,this._progressBarRenderer.setAnchorPoint(0,.5),this.addProtectedChild(this._barRenderer,ccui.Slider.BASEBAR_RENDERER_ZORDER,-1),this.addProtectedChild(this._progressBarRenderer,ccui.Slider.PROGRESSBAR_RENDERER_ZORDER,-1),this._slidBallNormalRenderer=new cc.Sprite,this._slidBallPressedRenderer=new cc.Sprite,this._slidBallPressedRenderer.setVisible(!1),this._slidBallDisabledRenderer=new cc.Sprite,this._slidBallDisabledRenderer.setVisible(!1),this._slidBallRenderer=new cc.Node,this._slidBallRenderer.addChild(this._slidBallNormalRenderer),this._slidBallRenderer.addChild(this._slidBallPressedRenderer),this._slidBallRenderer.addChild(this._slidBallDisabledRenderer),this._slidBallRenderer.setCascadeColorEnabled(!0),this._slidBallRenderer.setCascadeOpacityEnabled(!0),this.addProtectedChild(this._slidBallRenderer,ccui.Slider.BALL_RENDERER_ZORDER,-1)},loadBarTexture:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._textureFile=a,this._barTexType=b;var c=this._barRenderer,d=this;switch(c._textureLoaded||c.addEventListener("load",function(){d.loadBarTexture(d._textureFile,d._barTexType)}),this._barTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA(),this._barRendererAdaptDirty=!0,this._progressBarRendererDirty=!0,this._updateContentSizeWithTextureSize(this._barRenderer.getContentSize()),this._findLayout(),this._barTextureSize=this._barRenderer.getContentSize()}},loadProgressBarTexture:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._progressBarTextureFile=a,this._progressBarTexType=b;var c=this._progressBarRenderer,d=this;switch(c._textureLoaded||c.addEventListener("load",function(){d.loadProgressBarTexture(d._progressBarTextureFile,d._progressBarTexType)}),this._progressBarTexType){case ccui.Widget.LOCAL_TEXTURE:c.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:c.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA(),this._progressBarRenderer.setAnchorPoint(cc.p(0,.5));var e=this._progressBarRenderer.getContentSize();this._progressBarTextureSize={width:e.width,height:e.height},this._progressBarRendererDirty=!0,this._findLayout()}},setScale9Enabled:function(a){if(this._scale9Enabled!==a){if(this._scale9Enabled=a,this.removeProtectedChild(this._barRenderer,!0),this.removeProtectedChild(this._progressBarRenderer,!0),this._barRenderer=null,this._progressBarRenderer=null,this._scale9Enabled?(this._barRenderer=new ccui.Scale9Sprite,this._progressBarRenderer=new ccui.Scale9Sprite):(this._barRenderer=new cc.Sprite,this._progressBarRenderer=new cc.Sprite),this.loadBarTexture(this._textureFile,this._barTexType),this.loadProgressBarTexture(this._progressBarTextureFile,this._progressBarTexType),this.addProtectedChild(this._barRenderer,ccui.Slider.BASEBAR_RENDERER_ZORDER,-1),this.addProtectedChild(this._progressBarRenderer,ccui.Slider.PROGRESSBAR_RENDERER_ZORDER,-1),this._scale9Enabled){var b=this._ignoreSize;this.ignoreContentAdaptWithSize(!1),this._prevIgnoreSize=b}else this.ignoreContentAdaptWithSize(this._prevIgnoreSize);this.setCapInsetsBarRenderer(this._capInsetsBarRenderer),this.setCapInsetProgressBarRenderer(this._capInsetsProgressBarRenderer),this._barRendererAdaptDirty=!0,this._progressBarRendererDirty=!0}},isScale9Enabled:function(){return this._scale9Enabled},ignoreContentAdaptWithSize:function(a){(!this._scale9Enabled||this._scale9Enabled&&!a)&&(ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a),this._prevIgnoreSize=a)},setCapInsets:function(a){this.setCapInsetsBarRenderer(a),this.setCapInsetProgressBarRenderer(a)},setCapInsetsBarRenderer:function(a){if(a){var b=this._capInsetsBarRenderer;b.x=a.x,b.y=a.y,b.width=a.width,b.height=a.height,this._scale9Enabled&&this._barRenderer.setCapInsets(a)}},getCapInsetsBarRenderer:function(){return cc.rect(this._capInsetsBarRenderer)},setCapInsetProgressBarRenderer:function(a){if(a){var b=this._capInsetsProgressBarRenderer;b.x=a.x,b.y=a.y,b.width=a.width,b.height=a.height,this._scale9Enabled&&this._progressBarRenderer.setCapInsets(a)}},getCapInsetsProgressBarRenderer:function(){return cc.rect(this._capInsetsProgressBarRenderer)},loadSlidBallTextures:function(a,b,c,d){this.loadSlidBallTextureNormal(a,d),this.loadSlidBallTexturePressed(b,d),this.loadSlidBallTextureDisabled(c,d)},loadSlidBallTextureNormal:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._slidBallNormalTextureFile=a,this._ballNTexType=b;var c=this;switch(this._slidBallNormalRenderer._textureLoaded||this._slidBallNormalRenderer.addEventListener("load",function(){c.loadSlidBallTextureNormal(c._slidBallNormalTextureFile,c._ballNTexType)}),this._ballNTexType){case ccui.Widget.LOCAL_TEXTURE:this._slidBallNormalRenderer.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:this._slidBallNormalRenderer.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA(),this._findLayout()}},loadSlidBallTexturePressed:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._slidBallPressedTextureFile=a,this._ballPTexType=b;var c=this;switch(this._slidBallPressedRenderer._textureLoaded||this._slidBallPressedRenderer.addEventListener("load",function(){c.loadSlidBallTexturePressed(c._slidBallPressedTextureFile,c._ballPTexType)}),this._ballPTexType){case ccui.Widget.LOCAL_TEXTURE:this._slidBallPressedRenderer.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:this._slidBallPressedRenderer.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA(),this._findLayout()}},loadSlidBallTextureDisabled:function(a,b){if(a){b=b||ccui.Widget.LOCAL_TEXTURE,this._slidBallDisabledTextureFile=a,this._ballDTexType=b;var c=this;switch(this._slidBallDisabledRenderer._textureLoaded||this._slidBallDisabledRenderer.addEventListener("load",function(){c.loadSlidBallTextureDisabled(c._slidBallDisabledTextureFile,c._ballDTexType)}),this._ballDTexType){case ccui.Widget.LOCAL_TEXTURE:this._slidBallDisabledRenderer.initWithFile(a);break;case ccui.Widget.PLIST_TEXTURE:this._slidBallDisabledRenderer.initWithSpriteFrameName(a)}this._updateChildrenDisplayedRGBA(),this._findLayout()}},setPercent:function(a){a>100&&(a=100),0>a&&(a=0),this._percent=a;var b=a/100,c=this._barLength*b;if(this._slidBallRenderer.setPosition(c,this._contentSize.height/2),this._scale9Enabled)this._progressBarRenderer.setPreferredSize(cc.size(c,this._contentSize.height));else{var d=this._progressBarRenderer,e=d.getTextureRect();d.setTextureRect(cc.rect(e.x,e.y,c/d._scaleX,e.height),d.isTextureRectRotated())}},hitTest:function(a){var b=this._slidBallNormalRenderer.convertToNodeSpace(a),c=this._slidBallNormalRenderer.getContentSize(),d=cc.rect(0,0,c.width,c.height); +return b.x>=d.x&&b.x<=d.x+d.width&&b.y>=d.y&&b.y<=d.y+d.height},onTouchBegan:function(a,b){var c=ccui.Widget.prototype.onTouchBegan.call(this,a,b);if(this._hit){var d=this.convertToNodeSpace(this._touchBeganPosition);this.setPercent(this._getPercentWithBallPos(d.x)),this._percentChangedEvent()}return c},onTouchMoved:function(a,b){var c=a.getLocation(),d=this.convertToNodeSpace(c);this.setPercent(this._getPercentWithBallPos(d.x)),this._percentChangedEvent()},onTouchEnded:function(a,b){ccui.Widget.prototype.onTouchEnded.call(this,a,b)},onTouchCancelled:function(a,b){ccui.Widget.prototype.onTouchCancelled.call(this,a,b)},_getPercentWithBallPos:function(a){return a/this._barLength*100},addEventListenerSlider:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._sliderEventSelector=a,this._sliderEventListener=b},_percentChangedEvent:function(){this._sliderEventSelector&&(this._sliderEventListener?this._sliderEventSelector.call(this._sliderEventListener,this,ccui.Slider.EVENT_PERCENT_CHANGED):this._sliderEventSelector(this,ccui.Slider.EVENT_PERCENT_CHANGED)),this._ccEventCallback&&this._ccEventCallback(this,ccui.Slider.EVENT_PERCENT_CHANGED)},getPercent:function(){return this._percent},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this),this._barRendererAdaptDirty=!0,this._progressBarRendererDirty=!0},_adaptRenderers:function(){this._barRendererAdaptDirty&&(this._barRendererScaleChangedWithSize(),this._barRendererAdaptDirty=!1),this._progressBarRendererDirty&&(this._progressBarRendererScaleChangedWithSize(),this._progressBarRendererDirty=!1)},getVirtualRendererSize:function(){return this._barRenderer.getContentSize()},getVirtualRenderer:function(){return this._barRenderer},_barRendererScaleChangedWithSize:function(){if(this._unifySize)this._barLength=this._contentSize.width,this._barRenderer.setPreferredSize(this._contentSize);else if(this._ignoreSize)this._barRenderer.setScale(1),this._barLength=this._contentSize.width;else if(this._barLength=this._contentSize.width,this._scale9Enabled)this._barRenderer.setPreferredSize(this._contentSize),this._barRenderer.setScale(1);else{var a=this._barTextureSize;if(a.width<=0||a.height<=0)this._barRenderer.setScale(1);else{var b=this._contentSize.width/a.width,c=this._contentSize.height/a.height;this._barRenderer.setScaleX(b),this._barRenderer.setScaleY(c)}}this._barRenderer.setPosition(this._contentSize.width/2,this._contentSize.height/2),this.setPercent(this._percent)},_progressBarRendererScaleChangedWithSize:function(){if(this._unifySize)this._progressBarRenderer.setPreferredSize(this._contentSize);else if(this._ignoreSize){if(!this._scale9Enabled){var a=this._progressBarTextureSize,b=this._contentSize.width/a.width,c=this._contentSize.height/a.height;this._progressBarRenderer.setScaleX(b),this._progressBarRenderer.setScaleY(c)}}else if(this._scale9Enabled)this._progressBarRenderer.setPreferredSize(this._contentSize),this._progressBarRenderer.setScale(1);else{var a=this._progressBarTextureSize;if(a.width<=0||a.height<=0)return void this._progressBarRenderer.setScale(1);var b=this._contentSize.width/a.width,c=this._contentSize.height/a.height;this._progressBarRenderer.setScaleX(b),this._progressBarRenderer.setScaleY(c)}this._progressBarRenderer.setPosition(0,this._contentSize.height/2),this.setPercent(this._percent)},_onPressStateChangedToNormal:function(){this._slidBallNormalRenderer.setVisible(!0),this._slidBallPressedRenderer.setVisible(!1),this._slidBallDisabledRenderer.setVisible(!1),this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX,this._sliderBallNormalTextureScaleY)},_onPressStateChangedToPressed:function(){this._slidBallPressedTextureFile?(this._slidBallNormalRenderer.setVisible(!1),this._slidBallPressedRenderer.setVisible(!0),this._slidBallDisabledRenderer.setVisible(!1)):this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX+this._zoomScale,this._sliderBallNormalTextureScaleY+this._zoomScale)},_onPressStateChangedToDisabled:function(){this._slidBallDisabledTextureFile&&(this._slidBallNormalRenderer.setVisible(!1),this._slidBallDisabledRenderer.setVisible(!0)),this._slidBallNormalRenderer.setScale(this._sliderBallNormalTextureScaleX,this._sliderBallNormalTextureScaleY),this._slidBallPressedRenderer.setVisible(!1)},setZoomScale:function(a){this._zoomScale=a},getZoomScale:function(){return this._zoomScale},getDescription:function(){return"Slider"},_createCloneInstance:function(){return new ccui.Slider},_copySpecialProperties:function(a){this._prevIgnoreSize=a._prevIgnoreSize,this.setScale9Enabled(a._scale9Enabled),this.loadBarTexture(a._textureFile,a._barTexType),this.loadProgressBarTexture(a._progressBarTextureFile,a._progressBarTexType),this.loadSlidBallTextureNormal(a._slidBallNormalTextureFile,a._ballNTexType),this.loadSlidBallTexturePressed(a._slidBallPressedTextureFile,a._ballPTexType),this.loadSlidBallTextureDisabled(a._slidBallDisabledTextureFile,a._ballDTexType),this.setPercent(a.getPercent()),this._sliderEventListener=a._sliderEventListener,this._sliderEventSelector=a._sliderEventSelector,this._zoomScale=a._zoomScale,this._ccEventCallback=a._ccEventCallback}});var _p=ccui.Slider.prototype;_p.percent,cc.defineGetterSetter(_p,"percent",_p.getPercent,_p.setPercent),_p=null,ccui.Slider.create=function(a,b,c){return new ccui.Slider(a,b,c)},ccui.Slider.EVENT_PERCENT_CHANGED=0,ccui.Slider.BASEBAR_RENDERER_ZORDER=-3,ccui.Slider.PROGRESSBAR_RENDERER_ZORDER=-2,ccui.Slider.BALL_RENDERER_ZORDER=-1,ccui.Text=ccui.Widget.extend({_touchScaleChangeEnabled:!1,_normalScaleValueX:1,_normalScaleValueY:1,_fontName:"Thonburi",_fontSize:10,_onSelectedScaleOffset:.5,_labelRenderer:"",_textAreaSize:null,_textVerticalAlignment:0,_textHorizontalAlignment:0,_className:"Text",_type:null,_labelRendererAdaptDirty:!0,ctor:function(a,b,c){this._type=ccui.Text.Type.SYSTEM,this._textAreaSize=cc.size(0,0),ccui.Widget.prototype.ctor.call(this),void 0!==c&&this.init(a,b,c)},init:function(a,b,c){return ccui.Widget.prototype.init.call(this)?(arguments.length>0?(this.setFontName(b),this.setFontSize(c),this.setString(a)):this.setFontName(this._fontName),!0):!1},_initRenderer:function(){this._labelRenderer=new cc.LabelTTF,this.addProtectedChild(this._labelRenderer,ccui.Text.RENDERER_ZORDER,-1)},setText:function(a){cc.log("Please use the setString"),this.setString(a)},setString:function(a){a!==this._labelRenderer.getString()&&(this._labelRenderer.setString(a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=!0)},getStringValue:function(){return cc.log("Please use the getString"),this._labelRenderer.getString()},getString:function(){return this._labelRenderer.getString()},getStringLength:function(){return this._labelRenderer.getStringLength()},setFontSize:function(a){this._labelRenderer.setFontSize(a),this._fontSize=a,this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=!0},getFontSize:function(){return this._fontSize},setFontName:function(a){this._fontName=a,this._labelRenderer.setFontName(a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=!0},getFontName:function(){return this._fontName},_setFont:function(a){var b=cc.LabelTTF._fontStyleRE.exec(a);b&&(this._fontSize=parseInt(b[1]),this._fontName=b[2],this._labelRenderer._setFont(a),this._labelScaleChangedWithSize())},_getFont:function(){return this._labelRenderer._getFont()},getType:function(){return this._type},setTextAreaSize:function(a){this._labelRenderer.setDimensions(a),this._ignoreSize||(this._customSize=a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=!0},getTextAreaSize:function(){return this._labelRenderer.getDimensions()},setTextHorizontalAlignment:function(a){this._labelRenderer.setHorizontalAlignment(a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=!0},getTextHorizontalAlignment:function(){return this._labelRenderer.getHorizontalAlignment()},setTextVerticalAlignment:function(a){this._labelRenderer.setVerticalAlignment(a),this._updateContentSizeWithTextureSize(this._labelRenderer.getContentSize()),this._labelRendererAdaptDirty=!0},getTextVerticalAlignment:function(){return this._labelRenderer.getVerticalAlignment()},setTouchScaleChangeEnabled:function(a){this._touchScaleChangeEnabled=a},isTouchScaleChangeEnabled:function(){return this._touchScaleChangeEnabled},_onPressStateChangedToNormal:function(){this._touchScaleChangeEnabled&&(this._labelRenderer.setScaleX(this._normalScaleValueX),this._labelRenderer.setScaleY(this._normalScaleValueY))},_onPressStateChangedToPressed:function(){this._touchScaleChangeEnabled&&(this._labelRenderer.setScaleX(this._normalScaleValueX+this._onSelectedScaleOffset),this._labelRenderer.setScaleY(this._normalScaleValueY+this._onSelectedScaleOffset))},_onPressStateChangedToDisabled:function(){},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this),this._labelRendererAdaptDirty=!0},_adaptRenderers:function(){this._labelRendererAdaptDirty&&(this._labelScaleChangedWithSize(),this._labelRendererAdaptDirty=!1)},getVirtualRendererSize:function(){return this._labelRenderer.getContentSize()},getVirtualRenderer:function(){return this._labelRenderer},getAutoRenderSize:function(){var a=this._labelRenderer.getContentSize();return this._ignoreSize||(this._labelRenderer.setDimensions(0,0),a=this._labelRenderer.getContentSize(),this._labelRenderer.setDimensions(this._contentSize.width,this._contentSize.height)),a},_labelScaleChangedWithSize:function(){var a=this._contentSize;if(this._ignoreSize)this._labelRenderer.setDimensions(0,0),this._labelRenderer.setScale(1),this._normalScaleValueX=this._normalScaleValueY=1;else{this._labelRenderer.setDimensions(cc.size(a.width,a.height));var b=this._labelRenderer.getContentSize();if(b.width<=0||b.height<=0)return void this._labelRenderer.setScale(1);var c=a.width/b.width,d=a.height/b.height;this._labelRenderer.setScaleX(c),this._labelRenderer.setScaleY(d),this._normalScaleValueX=c,this._normalScaleValueY=d}this._labelRenderer.setPosition(a.width/2,a.height/2)},getDescription:function(){return"Label"},enableShadow:function(a,b,c){this._labelRenderer.enableShadow(a,b,c)},enableOutline:function(a,b){this._labelRenderer.enableStroke(a,b)},enableGlow:function(a){this._type===ccui.Text.Type.TTF&&this._labelRenderer.enableGlow(a)},disableEffect:function(){this._labelRenderer.disableEffect&&this._labelRenderer.disableEffect()},_createCloneInstance:function(){return new ccui.Text},_copySpecialProperties:function(a){a instanceof ccui.Text&&(this.setFontName(a._fontName),this.setFontSize(a.getFontSize()),this.setString(a.getString()),this.setTouchScaleChangeEnabled(a.touchScaleEnabled),this.setTextAreaSize(a._textAreaSize),this.setTextHorizontalAlignment(a._labelRenderer.getHorizontalAlignment()),this.setTextVerticalAlignment(a._labelRenderer.getVerticalAlignment()),this.setContentSize(a.getContentSize()),this.setTextColor(a.getTextColor()))},_setBoundingWidth:function(a){this._textAreaSize.width=a,this._labelRenderer._setBoundingWidth(a),this._labelScaleChangedWithSize()},_setBoundingHeight:function(a){this._textAreaSize.height=a,this._labelRenderer._setBoundingHeight(a),this._labelScaleChangedWithSize()},_getBoundingWidth:function(){return this._textAreaSize.width},_getBoundingHeight:function(){return this._textAreaSize.height},_changePosition:function(){this._adaptRenderers()},setColor:function(a){cc.ProtectedNode.prototype.setColor.call(this,a),this._labelRenderer.setColor(a)},setTextColor:function(a){this._labelRenderer.setFontFillColor(a)},getTextColor:function(){return this._labelRenderer._getFillStyle()}});var _p=ccui.Text.prototype;_p.boundingWidth,cc.defineGetterSetter(_p,"boundingWidth",_p._getBoundingWidth,_p._setBoundingWidth),_p.boundingHeight,cc.defineGetterSetter(_p,"boundingHeight",_p._getBoundingHeight,_p._setBoundingHeight),_p.string,cc.defineGetterSetter(_p,"string",_p.getString,_p.setString),_p.stringLength,cc.defineGetterSetter(_p,"stringLength",_p.getStringLength),_p.font,cc.defineGetterSetter(_p,"font",_p._getFont,_p._setFont),_p.fontSize,cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize),_p.fontName,cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName),_p.textAlign,cc.defineGetterSetter(_p,"textAlign",_p.getTextHorizontalAlignment,_p.setTextHorizontalAlignment),_p.verticalAlign,cc.defineGetterSetter(_p,"verticalAlign",_p.getTextVerticalAlignment,_p.setTextVerticalAlignment),_p=null,ccui.Label=ccui.Text.create=function(a,b,c){return new ccui.Text(a,b,c)},ccui.Text.RENDERER_ZORDER=-1,ccui.Text.Type={SYSTEM:0,TTF:1},ccui.TextAtlas=ccui.Widget.extend({_labelAtlasRenderer:null,_stringValue:"",_charMapFileName:"",_itemWidth:0,_itemHeight:0,_startCharMap:"",_className:"TextAtlas",_labelAtlasRendererAdaptDirty:null,ctor:function(a,b,c,d,e){ccui.Widget.prototype.ctor.call(this),void 0!==e&&this.setProperty(a,b,c,d,e)},_initRenderer:function(){this._labelAtlasRenderer=new cc.LabelAtlas,this._labelAtlasRenderer.setAnchorPoint(cc.p(.5,.5)),this.addProtectedChild(this._labelAtlasRenderer,ccui.TextAtlas.RENDERER_ZORDER,-1)},setProperty:function(a,b,c,d,e){this._stringValue=a,this._charMapFileName=b,this._itemWidth=c,this._itemHeight=d,this._startCharMap=e,this._labelAtlasRenderer.initWithString(a,this._charMapFileName,this._itemWidth,this._itemHeight,this._startCharMap[0]),this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()),this._labelAtlasRendererAdaptDirty=!0},setString:function(a){a!==this._labelAtlasRenderer.getString()&&(this._stringValue=a,this._labelAtlasRenderer.setString(a),this._updateContentSizeWithTextureSize(this._labelAtlasRenderer.getContentSize()),this._labelAtlasRendererAdaptDirty=!0)},setStringValue:function(a){cc.log("Please use the setString"),this.setString(a)},getStringValue:function(){return cc.log("Please use the getString"),this.getString()},getString:function(){return this._labelAtlasRenderer.getString()},getStringLength:function(){return this._labelAtlasRenderer.getStringLength()},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this),this._labelAtlasRendererAdaptDirty=!0},_adaptRenderers:function(){this._labelAtlasRendererAdaptDirty&&(this._labelAtlasScaleChangedWithSize(),this._labelAtlasRendererAdaptDirty=!1)},getVirtualRendererSize:function(){return this._labelAtlasRenderer.getContentSize()},getVirtualRenderer:function(){return this._labelAtlasRenderer},_labelAtlasScaleChangedWithSize:function(){var a=this._labelAtlasRenderer;if(this._ignoreSize)a.setScale(1);else{var b=a.getContentSize();if(b.width<=0||b.height<=0)return void a.setScale(1);a.setScaleX(this._contentSize.width/b.width),a.setScaleY(this._contentSize.height/b.height)}a.setPosition(this._contentSize.width/2,this._contentSize.height/2)},getDescription:function(){return"LabelAtlas"},_copySpecialProperties:function(a){a&&this.setProperty(a._stringValue,a._charMapFileName,a._itemWidth,a._itemHeight,a._startCharMap)},_createCloneInstance:function(){return new ccui.TextAtlas}});var _p=ccui.TextAtlas.prototype;_p.string,cc.defineGetterSetter(_p,"string",_p.getString,_p.setString),_p=null,ccui.TextAtlas.create=function(a,b,c,d,e){return new ccui.TextAtlas(a,b,c,d,e)},ccui.TextAtlas.RENDERER_ZORDER=-1,ccui.LabelBMFont=ccui.TextBMFont=ccui.Widget.extend({_labelBMFontRenderer:null,_fntFileHasInit:!1,_fntFileName:"",_stringValue:"",_className:"TextBMFont",_labelBMFontRendererAdaptDirty:!0,ctor:function(a,b){ccui.Widget.prototype.ctor.call(this),void 0!=b&&(this.setFntFile(b),this.setString(a))},_initRenderer:function(){this._labelBMFontRenderer=new cc.LabelBMFont,this.addProtectedChild(this._labelBMFontRenderer,ccui.TextBMFont.RENDERER_ZORDER,-1)},setFntFile:function(a){if(a){this._fntFileName=a,this._fntFileHasInit=!0,this._labelBMFontRenderer.initWithString(this._stringValue,a),this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()),this._labelBMFontRendererAdaptDirty=!0;var b=this,c=b._labelBMFontRenderer;c._textureLoaded||c.addEventListener("load",function(){b.setFntFile(b._fntFileName)})}},setText:function(a){cc.log("Please use the setString"),this.setString(a)},setString:function(a){a!==this._labelBMFontRenderer.getString()&&(this._stringValue=a,this._labelBMFontRenderer.setString(a),this._fntFileHasInit&&(this._updateContentSizeWithTextureSize(this._labelBMFontRenderer.getContentSize()),this._labelBMFontRendererAdaptDirty=!0))},getString:function(){return this._stringValue},getStringLength:function(){return this._labelBMFontRenderer.getStringLength()},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this),this._labelBMFontRendererAdaptDirty=!0},_adaptRenderers:function(){this._labelBMFontRendererAdaptDirty&&(this._labelBMFontScaleChangedWithSize(),this._labelBMFontRendererAdaptDirty=!1)},getVirtualRendererSize:function(){return this._labelBMFontRenderer.getContentSize()},getVirtualRenderer:function(){return this._labelBMFontRenderer},_labelBMFontScaleChangedWithSize:function(){var a=this._labelBMFontRenderer;if(this._ignoreSize)a.setScale(1);else{var b=a.getContentSize();if(b.width<=0||b.height<=0)return void a.setScale(1);a.setScaleX(this._contentSize.width/b.width),a.setScaleY(this._contentSize.height/b.height)}a.setPosition(this._contentSize.width/2,this._contentSize.height/2)},getDescription:function(){return"TextBMFont"},_createCloneInstance:function(){return new ccui.TextBMFont},_copySpecialProperties:function(a){this.setFntFile(a._fntFileName),this.setString(a._stringValue)}});var _p=ccui.TextBMFont.prototype;_p.string,cc.defineGetterSetter(_p,"string",_p.getString,_p.setString),_p=null,ccui.TextBMFont.create=function(a,b){return new ccui.TextBMFont(a,b)},ccui.TextBMFont.RENDERER_ZORDER=-1,ccui._TextFieldRenderer=cc.TextFieldTTF.extend({_maxLengthEnabled:!1,_maxLength:0,_passwordEnabled:!1,_passwordStyleText:"",_attachWithIME:!1,_detachWithIME:!1,_insertText:!1,_deleteBackward:!1,_className:"_TextFieldRenderer",ctor:function(){cc.TextFieldTTF.prototype.ctor.call(this),this._maxLengthEnabled=!1,this._maxLength=0,this._passwordEnabled=!1,this._passwordStyleText="*",this._attachWithIME=!1,this._detachWithIME=!1,this._insertText=!1,this._deleteBackward=!1},onEnter:function(){cc.TextFieldTTF.prototype.onEnter.call(this),cc.TextFieldTTF.prototype.setDelegate.call(this,this)},onTextFieldAttachWithIME:function(a){return this.setAttachWithIME(!0),!1},onTextFieldInsertText:function(a,b,c){return 1===c&&"\n"===b?!1:(this.setInsertText(!0),this._maxLengthEnabled&&cc.TextFieldTTF.prototype.getCharCount.call(this)>=this._maxLength)},onTextFieldDeleteBackward:function(a,b,c){return this.setDeleteBackward(!0),!1},onTextFieldDetachWithIME:function(a){return this.setDetachWithIME(!0),!1},insertText:function(a,b){var c=a;if("\n"!==a&&this._maxLengthEnabled){var d=this.getString().length;if(d>=this._maxLength)return void(this._passwordEnabled&&this.setPasswordText(this.getString()))}cc.TextFieldTTF.prototype.insertText.call(this,c,b),this._passwordEnabled&&cc.TextFieldTTF.prototype.getCharCount.call(this)>0&&this.setPasswordText(this.getString())},deleteBackward:function(){cc.TextFieldTTF.prototype.deleteBackward.call(this),cc.TextFieldTTF.prototype.getCharCount.call(this)>0&&this._passwordEnabled&&this.setPasswordText(this._inputText)},openIME:function(){cc.TextFieldTTF.prototype.attachWithIME.call(this)},closeIME:function(){cc.TextFieldTTF.prototype.detachWithIME.call(this)},setMaxLengthEnabled:function(a){this._maxLengthEnabled=a},isMaxLengthEnabled:function(){return this._maxLengthEnabled},setMaxLength:function(a){this._maxLength=a},getMaxLength:function(){return this._maxLength},getCharCount:function(){return cc.TextFieldTTF.prototype.getCharCount.call(this)},setPasswordEnabled:function(a){this._passwordEnabled=a},isPasswordEnabled:function(){return this._passwordEnabled},setPasswordStyleText:function(a){if(!(a.length>1)){var b=a.charCodeAt(0);33>b||b>126||(this._passwordStyleText=a)}},setPasswordText:function(a){var b="",c=a.length,d=c;this._maxLengthEnabled&&c>this._maxLength&&(d=this._maxLength);for(var e=0;d>e;++e)b+=this._passwordStyleText;cc.LabelTTF.prototype.setString.call(this,b)},setAttachWithIME:function(a){this._attachWithIME=a},getAttachWithIME:function(){return this._attachWithIME},setDetachWithIME:function(a){this._detachWithIME=a},getDetachWithIME:function(){return this._detachWithIME},setInsertText:function(a){this._insertText=a},getInsertText:function(){return this._insertText},setDeleteBackward:function(a){this._deleteBackward=a},getDeleteBackward:function(){return this._deleteBackward},onDraw:function(a){return!1}}),ccui._TextFieldRenderer.create=function(a,b,c){var d=new ccui._TextFieldRenderer;return d&&d.initWithString("",b,c)?(a&&d.setPlaceHolder(a),d):null},ccui.TextField=ccui.Widget.extend({_textFieldRenderer:null,_touchWidth:0,_touchHeight:0,_useTouchArea:!1,_textFieldEventListener:null,_textFieldEventSelector:null,_passwordStyleText:"",_textFieldRendererAdaptDirty:!0,_fontName:"",_fontSize:12,_ccEventCallback:null,ctor:function(a,b,c){ccui.Widget.prototype.ctor.call(this),b&&this.setFontName(b),c&&this.setFontSize(c),a&&this.setPlaceHolder(a)},init:function(){return ccui.Widget.prototype.init.call(this)?(this.setTouchEnabled(!0),!0):!1},onEnter:function(){ccui.Widget.prototype.onEnter.call(this),this.scheduleUpdate()},_initRenderer:function(){this._textFieldRenderer=ccui._TextFieldRenderer.create("input words here","Thonburi",20),this.addProtectedChild(this._textFieldRenderer,ccui.TextField.RENDERER_ZORDER,-1)},setTouchSize:function(a){this._touchWidth=a.width,this._touchHeight=a.height},setTouchAreaEnabled:function(a){this._useTouchArea=a},hitTest:function(a){if(this._useTouchArea){var b=this.convertToNodeSpace(a),c=cc.rect(-this._touchWidth*this._anchorPoint.x,-this._touchHeight*this._anchorPoint.y,this._touchWidth,this._touchHeight);return b.x>=c.x&&b.x<=c.x+c.width&&b.y>=c.y&&b.y<=c.y+c.height}return ccui.Widget.prototype.hitTest.call(this,a)},getTouchSize:function(){return cc.size(this._touchWidth,this._touchHeight)},setText:function(a){cc.log("Please use the setString"),this.setString(a)},setString:function(a){null!=a&&(a=String(a),this.isMaxLengthEnabled()&&(a=a.substr(0,this.getMaxLength())),this.isPasswordEnabled()?(this._textFieldRenderer.setPasswordText(a),this._textFieldRenderer.setString(""),this._textFieldRenderer.insertText(a,a.length)):this._textFieldRenderer.setString(a),this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()))},setPlaceHolder:function(a){this._textFieldRenderer.setPlaceHolder(a),this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())},getPlaceHolder:function(){return this._textFieldRenderer.getPlaceHolder()},getPlaceHolderColor:function(){return this._textFieldRenderer.getPlaceHolderColor()},setPlaceHolderColor:function(a){this._textFieldRenderer.setColorSpaceHolder(a)},setTextColor:function(a){this._textFieldRenderer.setTextColor(a)},setFontSize:function(a){this._textFieldRenderer.setFontSize(a),this._fontSize=a,this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())},getFontSize:function(){return this._fontSize},setFontName:function(a){this._textFieldRenderer.setFontName(a),this._fontName=a,this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize())},getFontName:function(){return this._fontName},didNotSelectSelf:function(){this._textFieldRenderer.detachWithIME()},getStringValue:function(){return cc.log("Please use the getString"),this.getString()},getString:function(){return this._textFieldRenderer.getString()},getStringLength:function(){return this._textFieldRenderer.getStringLength()},onTouchBegan:function(a,b){var c=this,d=ccui.Widget.prototype.onTouchBegan.call(c,a,b);return c._hit?setTimeout(function(){c._textFieldRenderer.attachWithIME()},0):setTimeout(function(){c._textFieldRenderer.detachWithIME()},0),d},setMaxLengthEnabled:function(a){this._textFieldRenderer.setMaxLengthEnabled(a)},isMaxLengthEnabled:function(){return this._textFieldRenderer.isMaxLengthEnabled()},setMaxLength:function(a){this._textFieldRenderer.setMaxLength(a),this.setString(this.getString())},getMaxLength:function(){return this._textFieldRenderer.getMaxLength()},setPasswordEnabled:function(a){this._textFieldRenderer.setPasswordEnabled(a)},isPasswordEnabled:function(){return this._textFieldRenderer.isPasswordEnabled()},setPasswordStyleText:function(a){this._textFieldRenderer.setPasswordStyleText(a),this._passwordStyleText=a,this.setString(this.getString())},getPasswordStyleText:function(){return this._passwordStyleText},update:function(a){this.getDetachWithIME()&&(this._detachWithIMEEvent(),this.setDetachWithIME(!1)),this.getAttachWithIME()&&(this._attachWithIMEEvent(),this.setAttachWithIME(!1)),this.getInsertText()&&(this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()),this._insertTextEvent(),this.setInsertText(!1)),this.getDeleteBackward()&&(this._textFieldRendererAdaptDirty=!0,this._updateContentSizeWithTextureSize(this._textFieldRenderer.getContentSize()),this._deleteBackwardEvent(),this.setDeleteBackward(!1))},getAttachWithIME:function(){return this._textFieldRenderer.getAttachWithIME()},setAttachWithIME:function(a){this._textFieldRenderer.setAttachWithIME(a)},getDetachWithIME:function(){return this._textFieldRenderer.getDetachWithIME()},setDetachWithIME:function(a){this._textFieldRenderer.setDetachWithIME(a)},getInsertText:function(){return this._textFieldRenderer.getInsertText()},setInsertText:function(a){this._textFieldRenderer.setInsertText(a)},getDeleteBackward:function(){return this._textFieldRenderer.getDeleteBackward()},setDeleteBackward:function(a){this._textFieldRenderer.setDeleteBackward(a)},_attachWithIMEEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,this,ccui.TextField.EVENT_ATTACH_WITH_IME):this._textFieldEventSelector(this,ccui.TextField.EVENT_ATTACH_WITH_IME)),this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_ATTACH_WITH_IME)},_detachWithIMEEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,this,ccui.TextField.EVENT_DETACH_WITH_IME):this._textFieldEventSelector(this,ccui.TextField.EVENT_DETACH_WITH_IME)),this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_DETACH_WITH_IME)},_insertTextEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,this,ccui.TextField.EVENT_INSERT_TEXT):this._textFieldEventSelector(this,ccui.TextField.EVENT_INSERT_TEXT)),this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_INSERT_TEXT)},_deleteBackwardEvent:function(){this._textFieldEventSelector&&(this._textFieldEventListener?this._textFieldEventSelector.call(this._textFieldEventListener,this,ccui.TextField.EVENT_DELETE_BACKWARD):this._textFieldEventSelector(this,ccui.TextField.EVENT_DELETE_BACKWARD)),this._ccEventCallback&&this._ccEventCallback(this,ccui.TextField.EVENT_DELETE_BACKWARD)},addEventListenerTextField:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._textFieldEventSelector=a,this._textFieldEventListener=b},_onSizeChanged:function(){ccui.Widget.prototype._onSizeChanged.call(this),this._textFieldRendererAdaptDirty=!0},_adaptRenderers:function(){this._textFieldRendererAdaptDirty&&(this._textfieldRendererScaleChangedWithSize(),this._textFieldRendererAdaptDirty=!1)},_textfieldRendererScaleChangedWithSize:function(){this._ignoreSize||this._textFieldRenderer.setDimensions(this._contentSize),this._textFieldRenderer.setPosition(this._contentSize.width/2,this._contentSize.height/2)},getAutoRenderSize:function(){var a=this._textFieldRenderer.getContentSize();return this._ignoreSize||(this._textFieldRenderer.setDimensions(0,0),a=this._textFieldRenderer.getContentSize(),this._textFieldRenderer.setDimensions(this._contentSize.width,this._contentSize.height)),a},getVirtualRendererSize:function(){return this._textFieldRenderer.getContentSize()},getVirtualRenderer:function(){return this._textFieldRenderer},getDescription:function(){return"TextField"},attachWithIME:function(){this._textFieldRenderer.attachWithIME()},_createCloneInstance:function(){return new ccui.TextField},_copySpecialProperties:function(a){this.setString(a._textFieldRenderer.getString()),this.setPlaceHolder(a.getString()),this.setFontSize(a._textFieldRenderer.getFontSize()),this.setFontName(a._textFieldRenderer.getFontName()),this.setMaxLengthEnabled(a.isMaxLengthEnabled()),this.setMaxLength(a.getMaxLength()),this.setPasswordEnabled(a.isPasswordEnabled()),this.setPasswordStyleText(a._passwordStyleText),this.setAttachWithIME(a.getAttachWithIME()),this.setDetachWithIME(a.getDetachWithIME()),this.setInsertText(a.getInsertText()),this.setDeleteBackward(a.getDeleteBackward()),this._ccEventCallback=a._ccEventCallback,this._textFieldEventListener=a._textFieldEventListener,this._textFieldEventSelector=a._textFieldEventSelector},setTextAreaSize:function(a){this.setContentSize(a)},setTextHorizontalAlignment:function(a){this._textFieldRenderer.setHorizontalAlignment(a)},setTextVerticalAlignment:function(a){this._textFieldRenderer.setVerticalAlignment(a)},_setFont:function(a){this._textFieldRenderer._setFont(a),this._textFieldRendererAdaptDirty=!0},_getFont:function(){return this._textFieldRenderer._getFont()},_changePosition:function(){this._adaptRenderers()}}),ccui.TextField.create=function(a,b,c){return new ccui.TextField(a,b,c)};var _p=ccui.TextField.prototype;_p.string,cc.defineGetterSetter(_p,"string",_p.getString,_p.setString),_p.placeHolder,cc.defineGetterSetter(_p,"placeHolder",_p.getPlaceHolder,_p.setPlaceHolder),_p.font,cc.defineGetterSetter(_p,"font",_p._getFont,_p._setFont),_p.fontSize,cc.defineGetterSetter(_p,"fontSize",_p.getFontSize,_p.setFontSize),_p.fontName,cc.defineGetterSetter(_p,"fontName",_p.getFontName,_p.setFontName),_p.maxLengthEnabled,cc.defineGetterSetter(_p,"maxLengthEnabled",_p.isMaxLengthEnabled,_p.setMaxLengthEnabled),_p.maxLength,cc.defineGetterSetter(_p,"maxLength",_p.getMaxLength,_p.setMaxLength),_p.passwordEnabled,cc.defineGetterSetter(_p,"passwordEnabled",_p.isPasswordEnabled,_p.setPasswordEnabled),_p=null,ccui.TextField.EVENT_ATTACH_WITH_IME=0,ccui.TextField.EVENT_DETACH_WITH_IME=1,ccui.TextField.EVENT_INSERT_TEXT=2,ccui.TextField.EVENT_DELETE_BACKWARD=3,ccui.TextField.RENDERER_ZORDER=-1,ccui.RichElement=ccui.Class.extend({_type:0,_tag:0,_color:null,_opacity:0,ctor:function(){this._type=0,this._tag=0,this._color=cc.color(255,255,255,255)},init:function(a,b,c){this._tag=a,this._color.r=b.r,this._color.g=b.g,this._color.b=b.b,this._opacity=c,void 0===c?this._color.a=b.a:this._color.a=c}}),ccui.RichElementText=ccui.RichElement.extend({_text:"",_fontName:"",_fontSize:0,_fontDefinition:null,ctor:function(a,b,c,d,e,f){ccui.RichElement.prototype.ctor.call(this),this._type=ccui.RichElement.TEXT,this._text="",this._fontName="",this._fontSize=0,b&&b instanceof cc.FontDefinition?this.initWithStringAndTextDefinition(a,d,b,c):f&&this.init(a,b,c,d,e,f)},init:function(a,b,c,d,e,f){ccui.RichElement.prototype.init.call(this,a,b,c),this._text=d,this._fontName=e,this._fontSize=f},initWithStringAndTextDefinition:function(a,b,c,d){ccui.RichElement.prototype.init.call(this,a,c.fillStyle,d),this._fontDefinition=c,this._text=b,this._fontName=c.fontName,this._fontSize=c.fontSize}}),ccui.RichElementText.create=function(a,b,c,d,e,f){ +return new ccui.RichElementText(a,b,c,d,e,f)},ccui.RichElementImage=ccui.RichElement.extend({_filePath:"",_textureRect:null,_textureType:0,ctor:function(a,b,c,d){ccui.RichElement.prototype.ctor.call(this),this._type=ccui.RichElement.IMAGE,this._filePath="",this._textureRect=cc.rect(0,0,0,0),this._textureType=0,void 0!==d&&this.init(a,b,c,d)},init:function(a,b,c,d){ccui.RichElement.prototype.init.call(this,a,b,c),this._filePath=d}}),ccui.RichElementImage.create=function(a,b,c,d){return new ccui.RichElementImage(a,b,c,d)},ccui.RichElementCustomNode=ccui.RichElement.extend({_customNode:null,ctor:function(a,b,c,d){ccui.RichElement.prototype.ctor.call(this),this._type=ccui.RichElement.CUSTOM,this._customNode=null,void 0!==d&&this.init(a,b,c,d)},init:function(a,b,c,d){ccui.RichElement.prototype.init.call(this,a,b,c),this._customNode=d}}),ccui.RichElementCustomNode.create=function(a,b,c,d){return new ccui.RichElementCustomNode(a,b,c,d)},ccui.RichText=ccui.Widget.extend({_formatTextDirty:!1,_richElements:null,_elementRenders:null,_leftSpaceWidth:0,_verticalSpace:0,_elementRenderersContainer:null,_lineBreakOnSpace:!1,_textHorizontalAlignment:null,_textVerticalAlignment:null,ctor:function(){ccui.Widget.prototype.ctor.call(this),this._formatTextDirty=!1,this._richElements=[],this._elementRenders=[],this._leftSpaceWidth=0,this._verticalSpace=0,this._textHorizontalAlignment=cc.TEXT_ALIGNMENT_LEFT,this._textVerticalAlignment=cc.VERTICAL_TEXT_ALIGNMENT_TOP},_initRenderer:function(){this._elementRenderersContainer=new cc.Node,this._elementRenderersContainer.setAnchorPoint(.5,.5),this.addProtectedChild(this._elementRenderersContainer,0,-1)},insertElement:function(a,b){this._richElements.splice(b,0,a),this._formatTextDirty=!0},pushBackElement:function(a){this._richElements.push(a),this._formatTextDirty=!0},removeElement:function(a){cc.isNumber(a)?this._richElements.splice(a,1):cc.arrayRemoveObject(this._richElements,a),this._formatTextDirty=!0},formatText:function(){if(this._formatTextDirty){this._elementRenderersContainer.removeAllChildren(),this._elementRenders.length=0;var a,b,c=this._richElements;if(this._ignoreSize)for(this._addNewLine(),a=0;a0;if(this._lineBreakOnSpace){var n=k.lastIndexOf(" ");j=-1===n?j:n+1,l=h.substr(j,h.length-1),m=j>0&&" "!==l}if(m){var o=null;b instanceof cc.FontDefinition?(o=new cc.LabelTTF(k.substr(0,j),b),o.setOpacity(b.fillStyle.a)):(o=new cc.LabelTTF(k.substr(0,j),b,c),o.setColor(d),o.setOpacity(d.a)),this._pushToContainer(o)}this._addNewLine(),this._handleTextRenderer(l,b,c,d)}else b instanceof cc.FontDefinition?e.setOpacity(b.fillStyle.a):(e.setColor(d),e.setOpacity(d.a)),this._pushToContainer(e)}},_handleImageRenderer:function(a,b,c){var d=new cc.Sprite(a);this._handleCustomRenderer(d)},_handleCustomRenderer:function(a){var b=a.getContentSize();this._leftSpaceWidth-=b.width,this._leftSpaceWidth<0?(this._addNewLine(),this._pushToContainer(a),this._leftSpaceWidth-=b.width):this._pushToContainer(a)},_addNewLine:function(){this._leftSpaceWidth=this._customSize.width,this._elementRenders.push([])},formatRenderers:function(){var a,b,c,d,e,f,g,h=0,i=this._elementRenderersContainer,j=this._elementRenders;if(this._ignoreSize){var k=0;for(c=j[0],d=0,b=0;ba;a++)j[a].length=0;this._elementRenders.length=0,this.setContentSize(this._ignoreSize?this.getVirtualRendererSize():this._customSize),this._updateContentSizeWithTextureSize(this._contentSize),i.setPosition(.5*this._contentSize.width,.5*this._contentSize.height)},_pushToContainer:function(a){this._elementRenders.length<=0||this._elementRenders[this._elementRenders.length-1].push(a)},_adaptRenderers:function(){this.formatText()},setVerticalSpace:function(a){this._verticalSpace=a},setAnchorPoint:function(a){ccui.Widget.prototype.setAnchorPoint.call(this,a),this._elementRenderersContainer.setAnchorPoint(a)},_setAnchorX:function(a){ccui.Widget.prototype._setAnchorX.call(this,a),this._elementRenderersContainer._setAnchorX(a)},_setAnchorY:function(a){ccui.Widget.prototype._setAnchorY.call(this,a),this._elementRenderersContainer._setAnchorY(a)},getVirtualRendererSize:function(){return this._elementRenderersContainer.getContentSize()},ignoreContentAdaptWithSize:function(a){this._ignoreSize!==a&&(this._formatTextDirty=!0,ccui.Widget.prototype.ignoreContentAdaptWithSize.call(this,a))},getContentSize:function(){return this.formatText(),cc.Node.prototype.getContentSize.call(this)},_getWidth:function(){return this.formatText(),cc.Node.prototype._getWidth.call(this)},_getHeight:function(){return this.formatText(),cc.Node.prototype._getHeight.call(this)},setContentSize:function(a,b){var c=void 0===b?a.width:a,d=void 0===b?a.height:b;ccui.Widget.prototype.setContentSize.call(this,c,d),this._formatTextDirty=!0},getDescription:function(){return"RichText"},setCascadeOpacityEnabled:function(a){this._super(a),this._elementRenderersContainer.setCascadeOpacityEnabled(a)},setLineBreakOnSpace:function(a){this._lineBreakOnSpace=a,this._formatTextDirty=!0,this.formatText()},setTextHorizontalAlignment:function(a){a!==this._textHorizontalAlignment&&(this._textHorizontalAlignment=a,this.formatText())},setTextVerticalAlignment:function(a){a!==this._textVerticalAlignment&&(this._textVerticalAlignment=a,this.formatText())}}),ccui.RichText.create=function(){return new ccui.RichText},ccui.RichElement.TEXT=0,ccui.RichElement.IMAGE=1,ccui.RichElement.CUSTOM=2,ccui.ScrollView=ccui.Layout.extend({_innerContainer:null,direction:null,_autoScrollDir:null,_topBoundary:0,_bottomBoundary:0,_leftBoundary:0,_rightBoundary:0,_bounceTopBoundary:0,_bounceBottomBoundary:0,_bounceLeftBoundary:0,_bounceRightBoundary:0,_autoScroll:!1,_autoScrollAddUpTime:0,_autoScrollOriginalSpeed:0,_autoScrollAcceleration:0,_isAutoScrollSpeedAttenuated:!1,_needCheckAutoScrollDestination:!1,_autoScrollDestination:null,_bePressed:!1,_slidTime:0,_moveChildPoint:null,_childFocusCancelOffset:0,_leftBounceNeeded:!1,_topBounceNeeded:!1,_rightBounceNeeded:!1,_bottomBounceNeeded:!1,bounceEnabled:!1,_bouncing:!1,_bounceDir:null,_bounceOriginalSpeed:0,inertiaScrollEnabled:!1,_scrollViewEventListener:null,_scrollViewEventSelector:null,_className:"ScrollView",ctor:function(){ccui.Layout.prototype.ctor.call(this),this.direction=ccui.ScrollView.DIR_NONE,this._autoScrollDir=cc.p(0,0),this._autoScrollAcceleration=-1e3,this._autoScrollDestination=cc.p(0,0),this._slidTime=0,this._moveChildPoint=cc.p(0,0),this._childFocusCancelOffset=5,this._bounceDir=cc.p(0,0),this._bounceOriginalSpeed=0,this.inertiaScrollEnabled=!0,this.setTouchEnabled(!0)},init:function(){return ccui.Layout.prototype.init.call(this)?(this.setClippingEnabled(!0),this._innerContainer.setTouchEnabled(!1),!0):!1},onEnter:function(){ccui.Layout.prototype.onEnter.call(this),this.scheduleUpdate(!0)},findNextFocusedWidget:function(a,b){return this.getLayoutType()===ccui.Layout.LINEAR_VERTICAL||this.getLayoutType()===ccui.Layout.LINEAR_HORIZONTAL?this._innerContainer.findNextFocusedWidget(a,b):ccui.Widget.prototype.findNextFocusedWidget.call(this,a,b)},_initRenderer:function(){ccui.Layout.prototype._initRenderer.call(this),this._innerContainer=new ccui.Layout,this._innerContainer.setColor(cc.color(255,255,255)),this._innerContainer.setOpacity(255),this._innerContainer.setCascadeColorEnabled(!0),this._innerContainer.setCascadeOpacityEnabled(!0),this.addProtectedChild(this._innerContainer,1,1)},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_WEBGL?new ccui.ScrollView.WebGLRenderCmd(this):new ccui.ScrollView.CanvasRenderCmd(this)},_onSizeChanged:function(){ccui.Layout.prototype._onSizeChanged.call(this);var a=this._contentSize;this._topBoundary=a.height,this._rightBoundary=a.width;var b=a.width/3,c=a.height/3;this._bounceTopBoundary=a.height-c,this._bounceBottomBoundary=c,this._bounceLeftBoundary=b,this._bounceRightBoundary=a.width-b;var d=this._innerContainer.getContentSize();this._innerContainer.setContentSize(cc.size(Math.max(d.width,a.width),Math.max(d.height,a.height))),this._innerContainer.setPosition(0,a.height-this._innerContainer.getContentSize().height)},setInnerContainerSize:function(a){var b,c,d=this._innerContainer,e=this._contentSize,f=e.width,g=e.height,h=d.getContentSize(),i=this._renderCmd;switch(a.width0&&d.setPosition(n.x*l.width,m.y),d.getRightBoundary()0&&d.setPosition(m.x,n.y*l.height),d.getTopBoundary()a?cc.log("Inner width <= scrollview width, it will be force sized!"):c=a,d.width=c,this.direction){case ccui.ScrollView.DIR_HORIZONTAL:case ccui.ScrollView.DIR_BOTH:if(d.getRightBoundary()<=b){var f=d.width,g=e-f;this._scrollChildren(g,0)}}var h=d.anchorX;d.getLeftBoundary()>0&&(d.x=h*c),d.getRightBoundary()a?cc.log("Inner height <= scrollview height, it will be force sized!"):c=a,d.height=c,this.direction){case ccui.ScrollView.DIR_VERTICAL:case ccui.ScrollView.DIR_BOTH:var f=c,g=e-f;this._scrollChildren(0,g)}var h=d.anchorY;d.getLeftBoundary()>0&&(d.y=h*c),d.getRightBoundary()=e.height-f.y||g+c.height<=-f.y||(h=b.x-d.x*c.width)>=e.width-f.x||h+c.width<=-f.x?!1:!0},updateChildren:function(){var a,b,c,d=this._innerContainer._children;for(b=0,c=d.length;c>b;b++)a=d[b],a._inViewRect===!0&&this._isInContainer(a)===!1?a._inViewRect=!1:a._inViewRect===!1&&this._isInContainer(a)===!0&&(a._inViewRect=!0)},addChild:function(a,b,c){return a?(this._isInContainer(a)===!1&&(a._inViewRect=!1),b=b||a.getLocalZOrder(),c=c||a.getTag(),this._innerContainer.addChild(a,b,c)):!1},removeAllChildren:function(){this.removeAllChildrenWithCleanup(!0)},removeAllChildrenWithCleanup:function(a){this._innerContainer.removeAllChildrenWithCleanup(a)},removeChild:function(a,b){return this._innerContainer.removeChild(a,b)},getChildren:function(){return this._innerContainer.getChildren()},getChildrenCount:function(){return this._innerContainer.getChildrenCount()},getChildByTag:function(a){return this._innerContainer.getChildByTag(a)},getChildByName:function(a){return this._innerContainer.getChildByName(a)},_moveChildren:function(a,b){var c=this._innerContainer;this._moveChildPoint.x=c.x+a,this._moveChildPoint.y=c.y+b,this._innerContainer.setPosition(this._moveChildPoint),0!==this._innerContainer._children.length&&this.updateChildren()},_autoScrollChildren:function(a){var b=this._autoScrollAddUpTime;if(this._autoScrollAddUpTime+=a,this._isAutoScrollSpeedAttenuated){var c=this._autoScrollOriginalSpeed+this._autoScrollAcceleration*this._autoScrollAddUpTime;if(0>=c)this._stopAutoScrollChildren(),this._checkNeedBounce();else{var d=2*b+a,e=(this._autoScrollOriginalSpeed+this._autoScrollAcceleration*d*.5)*a,f=e*this._autoScrollDir.x,g=e*this._autoScrollDir.y;this._scrollChildren(f,g)||(this._stopAutoScrollChildren(),this._checkNeedBounce())}}else if(this._needCheckAutoScrollDestination){var h=this._autoScrollDir.x*a*this._autoScrollOriginalSpeed,i=this._autoScrollDir.y*a*this._autoScrollOriginalSpeed,j=this._checkCustomScrollDestination(h,i),k=this._scrollChildren(h,i);j&&k||(this._stopAutoScrollChildren(),this._checkNeedBounce())}else this._scrollChildren(this._autoScrollDir.x*a*this._autoScrollOriginalSpeed,this._autoScrollDir.y*a*this._autoScrollOriginalSpeed)||(this._stopAutoScrollChildren(),this._checkNeedBounce())},_bounceChildren:function(a){var b=this._bounceOriginalSpeed,c=this._bounceDir;0>=b&&this._stopBounceChildren(),this._bounceScrollChildren(c.x*a*b,c.y*a*b)||this._stopBounceChildren()},_checkNeedBounce:function(){if(!this.bounceEnabled)return!1;this._checkBounceBoundary();var a=this._topBounceNeeded,b=this._bottomBounceNeeded,c=this._leftBounceNeeded,d=this._rightBounceNeeded;if(a||b||c||d){var e,f,g=this._contentSize,h=this._innerContainer;return a&&c?(e=cc.pSub(cc.p(0,g.height),cc.p(h.getLeftBoundary(),h.getTopBoundary())),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):a&&d?(e=cc.pSub(cc.p(g.width,g.height),cc.p(h.getRightBoundary(),h.getTopBoundary())),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):b&&c?(e=cc.pSub(cc.p(0,0),cc.p(h.getLeftBoundary(),h.getBottomBoundary())),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):b&&d?(e=cc.pSub(cc.p(g.width,0),cc.p(h.getRightBoundary(),h.getBottomBoundary())),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):a?(e=cc.pSub(cc.p(0,g.height),cc.p(0,h.getTopBoundary())),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):b?(e=cc.pSub(cc.p(0,0),cc.p(0,h.getBottomBoundary())),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):c?(e=cc.pSub(cc.p(0,0),cc.p(h.getLeftBoundary(),0)),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)):d&&(e=cc.pSub(cc.p(g.width,0),cc.p(h.getRightBoundary(),0)),f=cc.pLength(e)/.2,this._bounceDir=cc.pNormalize(e),this._startBounceChildren(f)),!0}return!1},_checkBounceBoundary:function(){var a=this._innerContainer,b=a.getBottomBoundary();b>this._bottomBoundary?(this._scrollToBottomEvent(),this._bottomBounceNeeded=!0):this._bottomBounceNeeded=!1;var c=a.getTopBoundary();cthis._leftBoundary?(this._scrollToLeftEvent(),this._leftBounceNeeded=!0):this._leftBounceNeeded=!1},_startBounceChildren:function(a){this._bounceOriginalSpeed=a,this._bouncing=!0},_stopBounceChildren:function(){this._bouncing=!1,this._bounceOriginalSpeed=0,this._leftBounceNeeded=!1,this._rightBounceNeeded=!1,this._topBounceNeeded=!1,this._bottomBounceNeeded=!1},_startAutoScrollChildrenWithOriginalSpeed:function(a,b,c,d){this._stopAutoScrollChildren(),this._autoScrollDir.x=a.x,this._autoScrollDir.y=a.y,this._isAutoScrollSpeedAttenuated=c,this._autoScrollOriginalSpeed=b,this._autoScroll=!0,this._autoScrollAcceleration=d},_startAutoScrollChildrenWithDestination:function(a,b,c){this._needCheckAutoScrollDestination=!1,this._autoScrollDestination=a;var d=cc.pSub(a,this._innerContainer.getPosition()),e=cc.pNormalize(d),f=0,g=-1e3,h=cc.pLength(d);c?(g=-(2*h)/(b*b),f=2*h/b):(this._needCheckAutoScrollDestination=!0,f=h/b),this._startAutoScrollChildrenWithOriginalSpeed(e,f,c,g)},_jumpToDestination:function(a,b){void 0!==a.x&&(b=a.y,a=a.x);var c=a,d=b;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:0>=b&&(d=Math.max(b,this._contentSize.height-this._innerContainer.getContentSize().height));break;case ccui.ScrollView.DIR_HORIZONTAL:0>=a&&(c=Math.max(a,this._contentSize.width-this._innerContainer.getContentSize().width));break;case ccui.ScrollView.DIR_BOTH:0>=b&&(d=Math.max(b,this._contentSize.height-this._innerContainer.getContentSize().height)),0>=a&&(c=Math.max(a,this._contentSize.width-this._innerContainer.getContentSize().width))}this._innerContainer.setPosition(c,d)},_stopAutoScrollChildren:function(){this._autoScroll=!1,this._autoScrollOriginalSpeed=0,this._autoScrollAddUpTime=0},_bounceScrollChildren:function(a,b){var c,d,e,f,g,h=!0,i=this._innerContainer;if(a>0&&b>0)c=a,d=b,e=i.getRightBoundary(),e+c>=this._rightBoundary&&(c=this._rightBoundary-e,this._bounceRightEvent(),h=!1),f=i.getTopBoundary(),f+b>=this._topBoundary&&(d=this._topBoundary-f,this._bounceTopEvent(),h=!1),this._moveChildren(c,d);else if(0>a&&b>0)c=a,d=b,j=i.getLeftBoundary(),j+c<=this._leftBoundary&&(c=this._leftBoundary-j,this._bounceLeftEvent(),h=!1),f=i.getTopBoundary(),f+b>=this._topBoundary&&(d=this._topBoundary-f,this._bounceTopEvent(),h=!1),this._moveChildren(c,d);else if(0>a&&0>b){c=a,d=b;var j=i.getLeftBoundary();j+c<=this._leftBoundary&&(c=this._leftBoundary-j,this._bounceLeftEvent(),h=!1),g=i.getBottomBoundary(),g+b<=this._bottomBoundary&&(d=this._bottomBoundary-g,this._bounceBottomEvent(),h=!1),this._moveChildren(c,d)}else if(a>0&&0>b)c=a,d=b,e=i.getRightBoundary(),e+c>=this._rightBoundary&&(c=this._rightBoundary-e,this._bounceRightEvent(),h=!1),g=i.getBottomBoundary(),g+b<=this._bottomBoundary&&(d=this._bottomBoundary-g,this._bounceBottomEvent(),h=!1),this._moveChildren(c,d);else if(0===a&&b>0)d=b,f=i.getTopBoundary(),f+b>=this._topBoundary&&(d=this._topBoundary-f,this._bounceTopEvent(),h=!1),this._moveChildren(0,d);else if(0===a&&0>b)d=b,g=i.getBottomBoundary(),g+b<=this._bottomBoundary&&(d=this._bottomBoundary-g,this._bounceBottomEvent(),h=!1),this._moveChildren(0,d);else if(a>0&&0===b)c=a,e=i.getRightBoundary(),e+c>=this._rightBoundary&&(c=this._rightBoundary-e,this._bounceRightEvent(),h=!1),this._moveChildren(c,0);else if(0>a&&0===b){c=a;var k=i.getLeftBoundary();k+c<=this._leftBoundary&&(c=this._leftBoundary-k,this._bounceLeftEvent(),h=!1),this._moveChildren(c,0)}return h},_checkCustomScrollDestination:function(a,b){var c,d,e,f,g=!0,h=this._innerContainer,i=this._autoScrollDestination;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:this._autoScrollDir.y>0?(c=h.getBottomBoundary(),c+b>=i.y&&(b=i.y-c,g=!1)):(c=h.getBottomBoundary(),c+b<=i.y&&(b=i.y-c,g=!1));break;case ccui.ScrollView.DIR_HORIZONTAL:this._autoScrollDir.x>0?(d=h.getLeftBoundary(),d+a>=i.x&&(a=i.x-d,g=!1)):(d=h.getLeftBoundary(),d+a<=i.x&&(a=i.x-d,g=!1));break;case ccui.ScrollView.DIR_BOTH:a>0&&b>0?(d=h.getLeftBoundary(),d+a>=i.x&&(a=i.x-d,g=!1),c=h.getBottomBoundary(),c+b>=i.y&&(b=i.y-c,g=!1)):0>a&&b>0?(e=h.getRightBoundary(),e+a<=i.x&&(a=i.x-e,g=!1),c=h.getBottomBoundary(),c+b>=i.y&&(b=i.y-c,g=!1)):0>a&&0>b?(e=h.getRightBoundary(),e+a<=i.x&&(a=i.x-e,g=!1),f=h.getTopBoundary(),f+b<=i.y&&(b=i.y-f,g=!1)):a>0&&0>b?(d=h.getLeftBoundary(),d+a>=i.x&&(a=i.x-d,g=!1),f=h.getTopBoundary(),f+b<=i.y&&(b=i.y-f,g=!1)):0===a&&b>0?(c=h.getBottomBoundary(),c+b>=i.y&&(b=i.y-c,g=!1)):0>a&&0===b?(e=h.getRightBoundary(),e+a<=i.x&&(a=i.x-e,g=!1)):0===a&&0>b?(f=h.getTopBoundary(),f+b<=i.y&&(b=i.y-f,g=!1)):a>0&&0===b&&(d=h.getLeftBoundary(),d+a>=i.x&&(a=i.x-d,g=!1))}return g},_scrollChildren:function(a,b){var c=!0;switch(this._scrollingEvent(),this.direction){case ccui.ScrollView.DIR_VERTICAL:c=this._scrollChildrenVertical(a,b);break;case ccui.ScrollView.DIR_HORIZONTAL:c=this._scrollChildrenHorizontal(a,b);break;case ccui.ScrollView.DIR_BOTH:c=this._scrollChildrenBoth(a,b)}return c},_scrollChildrenVertical:function(a,b){var c,d,e=b,f=!0,g=this._innerContainer;return this.bounceEnabled?(c=g.getBottomBoundary(),c+b>=this._bounceBottomBoundary&&(e=this._bounceBottomBoundary-c,this._scrollToBottomEvent(),f=!1),d=g.getTopBoundary(),d+b<=this._bounceTopBoundary&&(e=this._bounceTopBoundary-d,this._scrollToTopEvent(),f=!1)):(c=g.getBottomBoundary(),c+b>=this._bottomBoundary&&(e=this._bottomBoundary-c,this._scrollToBottomEvent(),f=!1),d=g.getTopBoundary(),d+b<=this._topBoundary&&(e=this._topBoundary-d,this._scrollToTopEvent(),f=!1)),this._moveChildren(0,e),f},_scrollChildrenHorizontal:function(a,b){var c,d,e=!0,f=a,g=this._innerContainer;return this.bounceEnabled?(c=g.getRightBoundary(),c+a<=this._bounceRightBoundary&&(f=this._bounceRightBoundary-c,this._scrollToRightEvent(),e=!1),d=g.getLeftBoundary(),d+a>=this._bounceLeftBoundary&&(f=this._bounceLeftBoundary-d,this._scrollToLeftEvent(),e=!1)):(c=g.getRightBoundary(),c+a<=this._rightBoundary&&(f=this._rightBoundary-c,this._scrollToRightEvent(),e=!1),d=g.getLeftBoundary(),d+a>=this._leftBoundary&&(f=this._leftBoundary-d,this._scrollToLeftEvent(),e=!1)),this._moveChildren(f,0),e},_scrollChildrenBoth:function(a,b){var c,d,e,f,g=!0,h=a,i=b,j=this._innerContainer;return this.bounceEnabled?a>0&&b>0?(c=j.getLeftBoundary(),c+a>=this._bounceLeftBoundary&&(h=this._bounceLeftBoundary-c,this._scrollToLeftEvent(),g=!1),d=j.getBottomBoundary(),d+b>=this._bounceBottomBoundary&&(i=this._bounceBottomBoundary-d,this._scrollToBottomEvent(),g=!1)):0>a&&b>0?(e=j.getRightBoundary(),e+a<=this._bounceRightBoundary&&(h=this._bounceRightBoundary-e,this._scrollToRightEvent(),g=!1),d=j.getBottomBoundary(),d+b>=this._bounceBottomBoundary&&(i=this._bounceBottomBoundary-d,this._scrollToBottomEvent(),g=!1)):0>a&&0>b?(e=j.getRightBoundary(),e+a<=this._bounceRightBoundary&&(h=this._bounceRightBoundary-e,this._scrollToRightEvent(),g=!1),f=j.getTopBoundary(),f+b<=this._bounceTopBoundary&&(i=this._bounceTopBoundary-f,this._scrollToTopEvent(),g=!1)):a>0&&0>b?(c=j.getLeftBoundary(),c+a>=this._bounceLeftBoundary&&(h=this._bounceLeftBoundary-c,this._scrollToLeftEvent(),g=!1),f=j.getTopBoundary(),f+b<=this._bounceTopBoundary&&(i=this._bounceTopBoundary-f,this._scrollToTopEvent(),g=!1)):0===a&&b>0?(d=j.getBottomBoundary(),d+b>=this._bounceBottomBoundary&&(i=this._bounceBottomBoundary-d,this._scrollToBottomEvent(),g=!1)):0>a&&0===b?(e=j.getRightBoundary(),e+a<=this._bounceRightBoundary&&(h=this._bounceRightBoundary-e,this._scrollToRightEvent(),g=!1)):0===a&&0>b?(f=j.getTopBoundary(),f+b<=this._bounceTopBoundary&&(i=this._bounceTopBoundary-f,this._scrollToTopEvent(),g=!1)):a>0&&0===b&&(c=j.getLeftBoundary(),c+a>=this._bounceLeftBoundary&&(h=this._bounceLeftBoundary-c,this._scrollToLeftEvent(),g=!1)):a>0&&b>0?(c=j.getLeftBoundary(),c+a>=this._leftBoundary&&(h=this._leftBoundary-c,this._scrollToLeftEvent(),g=!1),d=j.getBottomBoundary(),d+b>=this._bottomBoundary&&(i=this._bottomBoundary-d,this._scrollToBottomEvent(),g=!1)):0>a&&b>0?(e=j.getRightBoundary(),e+a<=this._rightBoundary&&(h=this._rightBoundary-e,this._scrollToRightEvent(),g=!1),d=j.getBottomBoundary(),d+b>=this._bottomBoundary&&(i=this._bottomBoundary-d,this._scrollToBottomEvent(),g=!1)):0>a&&0>b?(e=j.getRightBoundary(),e+a<=this._rightBoundary&&(h=this._rightBoundary-e,this._scrollToRightEvent(),g=!1),f=j.getTopBoundary(),f+b<=this._topBoundary&&(i=this._topBoundary-f,this._scrollToTopEvent(),g=!1)):a>0&&0>b?(c=j.getLeftBoundary(),c+a>=this._leftBoundary&&(h=this._leftBoundary-c,this._scrollToLeftEvent(),g=!1),f=this._innerContainer.getTopBoundary(),f+b<=this._topBoundary&&(i=this._topBoundary-f,this._scrollToTopEvent(),g=!1)):0===a&&b>0?(d=this._innerContainer.getBottomBoundary(),d+b>=this._bottomBoundary&&(i=this._bottomBoundary-d,this._scrollToBottomEvent(),g=!1)):0>a&&0===b?(e=this._innerContainer.getRightBoundary(),e+a<=this._rightBoundary&&(h=this._rightBoundary-e,this._scrollToRightEvent(),g=!1)):0===a&&0>b?(f=this._innerContainer.getTopBoundary(),f+b<=this._topBoundary&&(i=this._topBoundary-f,this._scrollToTopEvent(),g=!1)):a>0&&0===b&&(c=this._innerContainer.getLeftBoundary(),c+a>=this._leftBoundary&&(h=this._leftBoundary-c,this._scrollToLeftEvent(),g=!1)),this._moveChildren(h,i),g},scrollToBottom:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(),0),a,b)},scrollToTop:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(),this._contentSize.height-this._innerContainer.getContentSize().height),a,b)},scrollToLeft:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(0,this._innerContainer.getPositionY()),a,b)},scrollToRight:function(a,b){this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width-this._innerContainer.getContentSize().width,this._innerContainer.getPositionY()),a,b)},scrollToTopLeft:function(a,b){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._startAutoScrollChildrenWithDestination(cc.p(0,this._contentSize.height-this._innerContainer.getContentSize().height),a,b)},scrollToTopRight:function(a,b){if(this.direction!==ccui.ScrollView.DIR_BOTH)return void cc.log("Scroll direction is not both!");var c=this._innerContainer.getContentSize();this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width-c.width,this._contentSize.height-c.height),a,b)},scrollToBottomLeft:function(a,b){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._startAutoScrollChildrenWithDestination(cc.p(0,0),a,b)},scrollToBottomRight:function(a,b){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._startAutoScrollChildrenWithDestination(cc.p(this._contentSize.width-this._innerContainer.getContentSize().width,0),a,b)},scrollToPercentVertical:function(a,b,c){var d=this._contentSize.height-this._innerContainer.getContentSize().height,e=-d;this._startAutoScrollChildrenWithDestination(cc.p(this._innerContainer.getPositionX(),d+a*e/100),b,c)},scrollToPercentHorizontal:function(a,b,c){var d=this._innerContainer.getContentSize().width-this._contentSize.width;this._startAutoScrollChildrenWithDestination(cc.p(-(a*d/100),this._innerContainer.getPositionY()),b,c)},scrollToPercentBothDirection:function(a,b,c){if(this.direction===ccui.ScrollView.DIR_BOTH){var d=this._contentSize.height-this._innerContainer.getContentSize().height,e=-d,f=this._innerContainer.getContentSize().width-this._contentSize.width;this._startAutoScrollChildrenWithDestination(cc.p(-(a.x*f/100),d+a.y*e/100),b,c)}},jumpToBottom:function(){this._jumpToDestination(this._innerContainer.getPositionX(),0)},jumpToTop:function(){this._jumpToDestination(this._innerContainer.getPositionX(),this._contentSize.height-this._innerContainer.getContentSize().height)},jumpToLeft:function(){this._jumpToDestination(0,this._innerContainer.getPositionY())},jumpToRight:function(){this._jumpToDestination(this._contentSize.width-this._innerContainer.getContentSize().width,this._innerContainer.getPositionY())},jumpToTopLeft:function(){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._jumpToDestination(0,this._contentSize.height-this._innerContainer.getContentSize().height)},jumpToTopRight:function(){if(this.direction!==ccui.ScrollView.DIR_BOTH)return void cc.log("Scroll direction is not both!");var a=this._innerContainer.getContentSize();this._jumpToDestination(this._contentSize.width-a.width,this._contentSize.height-a.height)},jumpToBottomLeft:function(){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._jumpToDestination(0,0)},jumpToBottomRight:function(){return this.direction!==ccui.ScrollView.DIR_BOTH?void cc.log("Scroll direction is not both!"):void this._jumpToDestination(this._contentSize.width-this._innerContainer.getContentSize().width,0)},jumpToPercentVertical:function(a){var b=this._contentSize.height-this._innerContainer.getContentSize().height,c=-b;this._jumpToDestination(this._innerContainer.getPositionX(),b+a*c/100)},jumpToPercentHorizontal:function(a){var b=this._innerContainer.getContentSize().width-this._contentSize.width;this._jumpToDestination(-(a*b/100),this._innerContainer.getPositionY())},jumpToPercentBothDirection:function(a){if(this.direction===ccui.ScrollView.DIR_BOTH){var b=this._innerContainer.getContentSize(),c=this._contentSize.height-b.height,d=-c,e=b.width-this._contentSize.width;this._jumpToDestination(-(a.x*e/100),c+a.y*d/100)}},_startRecordSlidAction:function(){this._autoScroll&&this._stopAutoScrollChildren(),this._bouncing&&this._stopBounceChildren(),this._slidTime=0},_endRecordSlidAction:function(){if(!this._checkNeedBounce()&&this.inertiaScrollEnabled){if(this._slidTime<=.016)return;var a,b=0,c=this.convertToNodeSpace(this._touchEndPosition),d=this.convertToNodeSpace(this._touchBeganPosition);switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:b=c.y-d.y,a=0>b?ccui.ScrollView.SCROLLDIR_DOWN:ccui.ScrollView.SCROLLDIR_UP;break;case ccui.ScrollView.DIR_HORIZONTAL:b=c.x-d.x,a=0>b?ccui.ScrollView.SCROLLDIR_LEFT:ccui.ScrollView.SCROLLDIR_RIGHT;break;case ccui.ScrollView.DIR_BOTH:var e=cc.pSub(c,d);b=cc.pLength(e),a=cc.pNormalize(e);break;default:a=cc.p(0,0)}var f=Math.min(Math.abs(b)/this._slidTime,ccui.ScrollView.AUTO_SCROLL_MAX_SPEED); +this._startAutoScrollChildrenWithOriginalSpeed(a,f,!0,-1e3),this._slidTime=0}},_handlePressLogic:function(a){this._startRecordSlidAction(),this._bePressed=!0},_handleMoveLogic:function(a){var b=this.convertToNodeSpace(a.getLocation()),c=this.convertToNodeSpace(a.getPreviousLocation()),d=cc.pSub(b,c);switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:this._scrollChildren(0,d.y);break;case ccui.ScrollView.DIR_HORIZONTAL:this._scrollChildren(d.x,0);break;case ccui.ScrollView.DIR_BOTH:this._scrollChildren(d.x,d.y)}},_handleReleaseLogic:function(a){this._endRecordSlidAction(),this._bePressed=!1},onTouchBegan:function(a,b){var c=ccui.Layout.prototype.onTouchBegan.call(this,a,b);return this._isInterceptTouch||this._hit&&this._handlePressLogic(a),c},onTouchMoved:function(a,b){ccui.Layout.prototype.onTouchMoved.call(this,a,b),this._isInterceptTouch||this._handleMoveLogic(a)},onTouchEnded:function(a,b){ccui.Layout.prototype.onTouchEnded.call(this,a,b),this._isInterceptTouch||this._handleReleaseLogic(a),this._isInterceptTouch=!1},onTouchCancelled:function(a,b){ccui.Layout.prototype.onTouchCancelled.call(this,a,b),this._isInterceptTouch||this.handleReleaseLogic(a),this._isInterceptTouch=!1},update:function(a){this._autoScroll&&this._autoScrollChildren(a),this._bouncing&&this._bounceChildren(a),this._recordSlidTime(a)},_recordSlidTime:function(a){this._bePressed&&(this._slidTime+=a)},interceptTouchEvent:function(a,b,c){if(!this._touchEnabled)return void ccui.Layout.prototype.interceptTouchEvent.call(this,a,b,c);var d=c.getLocation();switch(a){case ccui.Widget.TOUCH_BEGAN:this._isInterceptTouch=!0,this._touchBeganPosition.x=d.x,this._touchBeganPosition.y=d.y,this._handlePressLogic(c);break;case ccui.Widget.TOUCH_MOVED:var e=cc.pLength(cc.pSub(b.getTouchBeganPosition(),d));this._touchMovePosition.x=d.x,this._touchMovePosition.y=d.y,e>this._childFocusCancelOffset&&(b.setHighlighted(!1),this._handleMoveLogic(c));break;case ccui.Widget.TOUCH_CANCELED:case ccui.Widget.TOUCH_ENDED:this._touchEndPosition.x=d.x,this._touchEndPosition.y=d.y,this._handleReleaseLogic(c),b.isSwallowTouches()&&(this._isInterceptTouch=!1)}},_scrollToTopEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_TOP):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_TOP)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_TOP)},_scrollToBottomEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM)},_scrollToLeftEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_LEFT)},_scrollToRightEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLL_TO_RIGHT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLL_TO_RIGHT)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLL_TO_RIGHT)},_scrollingEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_SCROLLING):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_SCROLLING)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_SCROLLING)},_bounceTopEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_TOP):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_TOP)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_TOP)},_bounceBottomEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_BOTTOM)},_bounceLeftEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_LEFT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_LEFT)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_LEFT)},_bounceRightEvent:function(){this._scrollViewEventSelector&&(this._scrollViewEventListener?this._scrollViewEventSelector.call(this._scrollViewEventListener,this,ccui.ScrollView.EVENT_BOUNCE_RIGHT):this._scrollViewEventSelector(this,ccui.ScrollView.EVENT_BOUNCE_RIGHT)),this._ccEventCallback&&this._ccEventCallback(this,ccui.ScrollView.EVENT_BOUNCE_RIGHT)},addEventListenerScrollView:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._scrollViewEventSelector=a,this._scrollViewEventListener=b},setDirection:function(a){this.direction=a},getDirection:function(){return this.direction},setBounceEnabled:function(a){this.bounceEnabled=a},isBounceEnabled:function(){return this.bounceEnabled},setInertiaScrollEnabled:function(a){this.inertiaScrollEnabled=a},isInertiaScrollEnabled:function(){return this.inertiaScrollEnabled},getInnerContainer:function(){return this._innerContainer},setLayoutType:function(a){this._innerContainer.setLayoutType(a)},getLayoutType:function(){return this._innerContainer.getLayoutType()},_doLayout:function(){this._doLayoutDirty&&(this._doLayoutDirty=!1)},getDescription:function(){return"ScrollView"},_createCloneInstance:function(){return new ccui.ScrollView},_copyClonedWidgetChildren:function(a){ccui.Layout.prototype._copyClonedWidgetChildren.call(this,a)},_copySpecialProperties:function(a){a instanceof ccui.ScrollView&&(ccui.Layout.prototype._copySpecialProperties.call(this,a),this.setInnerContainerSize(a.getInnerContainerSize()),this.setDirection(a.direction),this.setBounceEnabled(a.bounceEnabled),this.setInertiaScrollEnabled(a.inertiaScrollEnabled),this._scrollViewEventListener=a._scrollViewEventListener,this._scrollViewEventSelector=a._scrollViewEventSelector,this._ccEventCallback=a._ccEventCallback)},getNodeByTag:function(a){return this._innerContainer.getNodeByTag(a)},getNodes:function(){return this._innerContainer.getNodes()},removeNode:function(a){this._innerContainer.removeNode(a)},removeNodeByTag:function(a){this._innerContainer.removeNodeByTag(a)},removeAllNodes:function(){this._innerContainer.removeAllNodes()},addNode:function(a,b,c){this._innerContainer.addNode(a,b,c)}});var _p=ccui.ScrollView.prototype;_p.innerWidth,cc.defineGetterSetter(_p,"innerWidth",_p._getInnerWidth,_p._setInnerWidth),_p.innerHeight,cc.defineGetterSetter(_p,"innerHeight",_p._getInnerHeight,_p._setInnerHeight),_p=null,ccui.ScrollView.create=function(){return new ccui.ScrollView},ccui.ScrollView.DIR_NONE=0,ccui.ScrollView.DIR_VERTICAL=1,ccui.ScrollView.DIR_HORIZONTAL=2,ccui.ScrollView.DIR_BOTH=3,ccui.ScrollView.EVENT_SCROLL_TO_TOP=0,ccui.ScrollView.EVENT_SCROLL_TO_BOTTOM=1,ccui.ScrollView.EVENT_SCROLL_TO_LEFT=2,ccui.ScrollView.EVENT_SCROLL_TO_RIGHT=3,ccui.ScrollView.EVENT_SCROLLING=4,ccui.ScrollView.EVENT_BOUNCE_TOP=5,ccui.ScrollView.EVENT_BOUNCE_BOTTOM=6,ccui.ScrollView.EVENT_BOUNCE_LEFT=7,ccui.ScrollView.EVENT_BOUNCE_RIGHT=8,ccui.ScrollView.AUTO_SCROLL_MAX_SPEED=1e3,ccui.ScrollView.SCROLLDIR_UP=cc.p(0,1),ccui.ScrollView.SCROLLDIR_DOWN=cc.p(0,-1),ccui.ScrollView.SCROLLDIR_LEFT=cc.p(-1,0),ccui.ScrollView.SCROLLDIR_RIGHT=cc.p(1,0),function(){if(ccui.ProtectedNode.CanvasRenderCmd){ccui.ScrollView.CanvasRenderCmd=function(a){ccui.Layout.CanvasRenderCmd.call(this,a),this._needDraw=!0,this._dirty=!1};var a=ccui.ScrollView.CanvasRenderCmd.prototype=Object.create(ccui.Layout.CanvasRenderCmd.prototype);a.constructor=ccui.ScrollView.CanvasRenderCmd,a.visit=function(a){var b=this._node;if(b._visible){var c=b.__instanceId;cc.renderer.pushRenderCommand(this),cc.renderer._turnToCacheMode(c),ccui.Layout.CanvasRenderCmd.prototype.visit.call(this,a),this._dirtyFlag=0,cc.renderer._turnToNormalMode()}},a.rendering=function(a){var b,c,d=this._node.__instanceId,e=cc.renderer._cacheToCanvasCmds[d],f=cc.view.getScaleX(),g=cc.view.getScaleY(),h=a||cc._renderContext;for(h.computeRealOffsetY(),b=0,c=e.length;c>b;b++){var i=e[b]._node;i instanceof ccui.ScrollView||i&&i._parent&&i._parent._inViewRect===!1||e[b].rendering(h,f,g)}}}}(),ccui.ListView=ccui.ScrollView.extend({_model:null,_items:null,_gravity:null,_itemsMargin:0,_curSelectedIndex:0,_refreshViewDirty:!0,_listViewEventListener:null,_listViewEventSelector:null,ctor:function(){ccui.ScrollView.prototype.ctor.call(this),this._items=[],this._gravity=ccui.ListView.GRAVITY_CENTER_VERTICAL,this.setTouchEnabled(!0),this.init()},init:function(){return ccui.ScrollView.prototype.init.call(this)?(this.setLayoutType(ccui.Layout.LINEAR_VERTICAL),!0):!1},setItemModel:function(a){return a?void(this._model=a):void cc.log("Can't set a null to item model!")},_updateInnerContainerSize:function(){var a,b,c=this._items;switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:a=c.length;var d=(a-1)*this._itemsMargin;for(b=0;a>b;b++)d+=c[b].getContentSize().height;this.setInnerContainerSize(cc.size(this._contentSize.width,d));break;case ccui.ScrollView.DIR_HORIZONTAL:a=c.length;var e=(a-1)*this._itemsMargin;for(b=0;a>b;b++)e+=c[b].getContentSize().width;this.setInnerContainerSize(cc.size(e,this._contentSize.height))}},_remedyLayoutParameter:function(a){cc.assert(null!=a,"ListView Item can't be nil!");var b=a.getLayoutParameter(),c=!0;b||(b=new ccui.LinearLayoutParameter,c=!1);var d=this.getIndex(a);switch(this.direction){case ccui.ScrollView.DIR_VERTICAL:this._remedyVerticalLayoutParameter(b,d);break;case ccui.ScrollView.DIR_HORIZONTAL:this._remedyHorizontalLayoutParameter(b,d)}c||a.setLayoutParameter(b)},_remedyVerticalLayoutParameter:function(a,b){switch(cc.assert(null!=a,"Layout parameter can't be nil!"),this._gravity){case ccui.ListView.GRAVITY_LEFT:a.setGravity(ccui.LinearLayoutParameter.LEFT);break;case ccui.ListView.GRAVITY_RIGHT:a.setGravity(ccui.LinearLayoutParameter.RIGHT);break;case ccui.ListView.GRAVITY_CENTER_HORIZONTAL:a.setGravity(ccui.LinearLayoutParameter.CENTER_HORIZONTAL)}0===b?a.setMargin(ccui.MarginZero()):a.setMargin(new ccui.Margin(0,this._itemsMargin,0,0))},_remedyHorizontalLayoutParameter:function(a,b){switch(cc.assert(null!=a,"Layout parameter can't be nil!"),this._gravity){case ccui.ListView.GRAVITY_TOP:a.setGravity(ccui.LinearLayoutParameter.TOP);break;case ccui.ListView.GRAVITY_BOTTOM:a.setGravity(ccui.LinearLayoutParameter.BOTTOM);break;case ccui.ListView.GRAVITY_CENTER_VERTICAL:a.setGravity(ccui.LinearLayoutParameter.CENTER_VERTICAL)}0===b?a.setMargin(ccui.MarginZero()):a.setMargin(new ccui.Margin(this._itemsMargin,0,0,0))},pushBackDefaultItem:function(){if(null!=this._model){var a=this._model.clone();this._remedyLayoutParameter(a),this.addChild(a),this._refreshViewDirty=!0}},insertDefaultItem:function(a){if(null!=this._model){var b=this._model.clone();this._items.splice(a,0,b),ccui.ScrollView.prototype.addChild.call(this,b),this._remedyLayoutParameter(b),this._refreshViewDirty=!0}},pushBackCustomItem:function(a){this._remedyLayoutParameter(a),this.addChild(a),this._refreshViewDirty=!0},addChild:function(a,b,c){a&&(b=b||a.getLocalZOrder(),c=c||a.getName(),ccui.ScrollView.prototype.addChild.call(this,a,b,c),a instanceof ccui.Widget&&this._items.push(a))},removeChild:function(a,b){if(a){var c=this._items.indexOf(a);c>-1&&this._items.splice(c,1),ccui.ScrollView.prototype.removeChild.call(this,a,b)}},removeAllChildren:function(){this.removeAllChildrenWithCleanup(!0)},removeAllChildrenWithCleanup:function(a){ccui.ScrollView.prototype.removeAllChildrenWithCleanup.call(this,a),this._items=[]},insertCustomItem:function(a,b){this._items.splice(b,0,a),ccui.ScrollView.prototype.addChild.call(this,a),this._remedyLayoutParameter(a),this._refreshViewDirty=!0},removeItem:function(a){var b=this.getItem(a);null!=b&&(this.removeChild(b,!0),this._refreshViewDirty=!0)},removeLastItem:function(){this.removeItem(this._items.length-1)},removeAllItems:function(){this.removeAllChildren()},getItem:function(a){return 0>a||a>=this._items.length?null:this._items[a]},getItems:function(){return this._items},getIndex:function(a){return null==a?-1:this._items.indexOf(a)},setGravity:function(a){this._gravity!==a&&(this._gravity=a,this._refreshViewDirty=!0)},setItemsMargin:function(a){this._itemsMargin!==a&&(this._itemsMargin=a,this._refreshViewDirty=!0)},getItemsMargin:function(){return this._itemsMargin},setDirection:function(a){switch(a){case ccui.ScrollView.DIR_VERTICAL:this.setLayoutType(ccui.Layout.LINEAR_VERTICAL);break;case ccui.ScrollView.DIR_HORIZONTAL:this.setLayoutType(ccui.Layout.LINEAR_HORIZONTAL);break;case ccui.ScrollView.DIR_BOTH:return;default:return}ccui.ScrollView.prototype.setDirection.call(this,a)},requestRefreshView:function(){this._refreshViewDirty=!0},refreshView:function(){for(var a=this._items,b=0;bb)){var d=this._getPageCount();if(0>b||b>=d){if(c){b>d&&cc.log("pageIdx is %d, it will be added as page id [%d]",b,d);var e=this._createPage();e.addChild(a),this.addPage(e)}}else{var f=this._pages[b];f&&f.addChild(a)}}},_createPage:function(){var a=new ccui.Layout;return a.setContentSize(this.getContentSize()),a},addPage:function(a){a&&-1===this._pages.indexOf(a)&&(this.addChild(a),this._pages.push(a),this._doLayoutDirty=!0)},insertPage:function(a,b){if(!(0>b)&&a&&-1===this._pages.indexOf(a)){var c=this._getPageCount();b>=c?this.addPage(a):(this._pages[b]=a,this.addChild(a)),this._doLayoutDirty=!0}},removePage:function(a){if(a){this.removeChild(a);var b=this._pages.indexOf(a);b>-1&&this._pages.splice(b,1),this._doLayoutDirty=!0}},removePageAtIndex:function(a){if(!(0>a||a>=this._pages.length)){var b=this._pages[a];b&&this.removePage(b)}},removeAllPages:function(){for(var a=this._pages,b=0,c=a.length;c>b;b++)this.removeChild(a[b]);this._pages.length=0},_updateBoundaryPages:function(){var a=this._pages;return a.length<=0?(this._leftBoundaryChild=null,void(this._rightBoundaryChild=null)):(this._leftBoundaryChild=a[0],void(this._rightBoundaryChild=a[a.length-1]))},_getPageCount:function(){return this._pages.length},_getPositionXByIndex:function(a){return this.getContentSize().width*(a-this._curPageIdx)},_onSizeChanged:function(){ccui.Layout.prototype._onSizeChanged.call(this),this._rightBoundary=this.getContentSize().width,this._doLayoutDirty=!0},_updateAllPagesSize:function(){for(var a=this.getContentSize(),b=this._pages,c=0,d=b.length;d>c;c++)b[c].setContentSize(a)},_updateAllPagesPosition:function(){var a=this._getPageCount();if(0>=a)return void(this._curPageIdx=0);this._curPageIdx>=a&&(this._curPageIdx=a-1);for(var b=this.getContentSize().width,c=this._pages,d=0;a>d;d++)c[d].setPosition(cc.p((d-this._curPageIdx)*b,0))},scrollToPage:function(a){if(!(0>a||a>=this._pages.length)){this._curPageIdx=a;var b=this._pages[a];this._autoScrollDistance=-b.getPosition().x,this._autoScrollSpeed=Math.abs(this._autoScrollDistance)/.2,this._autoScrollDirection=this._autoScrollDistance>0?ccui.PageView.DIRECTION_RIGHT:ccui.PageView.DIRECTION_LEFT,this._isAutoScrolling=!0}},update:function(a){this._isAutoScrolling&&this._autoScroll(a)},setLayoutType:function(a){},getLayoutType:function(){return ccui.Layout.ABSOLUTE},_autoScroll:function(a){var b;switch(this._autoScrollDirection){case ccui.PageView.DIRECTION_LEFT:b=this._autoScrollSpeed*a,this._autoScrollDistance+b>=0?(b=-this._autoScrollDistance,this._autoScrollDistance=0,this._isAutoScrolling=!1):this._autoScrollDistance+=b,this._scrollPages(-b),this._isAutoScrolling||this._pageTurningEvent();break;case ccui.PageView.DIRECTION_RIGHT:b=this._autoScrollSpeed*a,this._autoScrollDistance-b<=0?(b=this._autoScrollDistance,this._autoScrollDistance=0,this._isAutoScrolling=!1):this._autoScrollDistance-=b,this._scrollPages(b),this._isAutoScrolling||this._pageTurningEvent()}},onTouchMoved:function(a,b){ccui.Layout.prototype.onTouchMoved.call(this,a,b),this._isInterceptTouch||this._handleMoveLogic(a)},onTouchEnded:function(a,b){ccui.Layout.prototype.onTouchEnded.call(this,a,b),this._isInterceptTouch||this._handleReleaseLogic(a),this._isInterceptTouch=!1},onTouchCancelled:function(a,b){ccui.Layout.prototype.onTouchCancelled.call(this,a,b),this._isInterceptTouch||this._handleReleaseLogic(a),this._isInterceptTouch=!1},_doLayout:function(){this._doLayoutDirty&&(this._updateAllPagesPosition(),this._updateAllPagesSize(),this._updateBoundaryPages(),this._doLayoutDirty=!1)},_movePages:function(a){for(var b=this._pages,c=b.length,d=0;c>d;d++){var e=b[d];e.setPositionX(e.getPositionX()+a)}},_scrollPages:function(a){if(this._pages.length<=0)return!1;if(!this._leftBoundaryChild||!this._rightBoundaryChild)return!1;var b=a;switch(this._touchMoveDirection){case ccui.PageView.TOUCH_DIR_LEFT:var c=this._rightBoundaryChild.getRightBoundary();if(c+a<=this._rightBoundary)return b=this._rightBoundary-c,this._movePages(b),!1;break;case ccui.PageView.TOUCH_DIR_RIGHT:var d=this._leftBoundaryChild.getLeftBoundary();if(d+a>=this._leftBoundary)return b=this._leftBoundary-d,this._movePages(b),!1}return this._movePages(b),!0},_handleMoveLogic:function(a){var b=a.getLocation().x-a.getPreviousLocation().x;0>b?this._touchMoveDirection=ccui.PageView.TOUCH_DIR_LEFT:b>0&&(this._touchMoveDirection=ccui.PageView.TOUCH_DIR_RIGHT),this._scrollPages(b)},setCustomScrollThreshold:function(a){cc.assert(a>0,"Invalid threshold!"),this._customScrollThreshold=a,this.setUsingCustomScrollThreshold(!0)},getCustomScrollThreshold:function(){return this._customScrollThreshold},setUsingCustomScrollThreshold:function(a){this._usingCustomScrollThreshold=a},isUsingCustomScrollThreshold:function(){return this._usingCustomScrollThreshold},_handleReleaseLogic:function(a){if(!(this._pages.length<=0)){var b=this._pages[this._curPageIdx];if(b){var c=b.getPosition(),d=this._pages.length,e=c.x,f=this.getSize().width;this._usingCustomScrollThreshold||(this._customScrollThreshold=f/2);var g=this._customScrollThreshold;-g>=e?this._curPageIdx>=d-1?this._scrollPages(-e):this.scrollToPage(this._curPageIdx+1):e>=g?this._curPageIdx<=0?this._scrollPages(-e):this.scrollToPage(this._curPageIdx-1):this.scrollToPage(this._curPageIdx)}}},interceptTouchEvent:function(a,b,c){if(!this._touchEnabled)return void ccui.Layout.prototype.interceptTouchEvent.call(this,a,b,c);var d=c.getLocation();switch(a){case ccui.Widget.TOUCH_BEGAN:this._touchBeganPosition.x=d.x,this._touchBeganPosition.y=d.y,this._isInterceptTouch=!0;break;case ccui.Widget.TOUCH_MOVED:this._touchMovePosition.x=d.x,this._touchMovePosition.y=d.y;var e=0;e=Math.abs(b.getTouchBeganPosition().x-d.x),e>this._childFocusCancelOffset&&(b.setHighlighted(!1),this._handleMoveLogic(c));break;case ccui.Widget.TOUCH_ENDED:case ccui.Widget.TOUCH_CANCELED:this._touchEndPosition.x=d.x,this._touchEndPosition.y=d.y,this._handleReleaseLogic(c),b.isSwallowTouches()&&(this._isInterceptTouch=!1)}},_pageTurningEvent:function(){this._pageViewEventSelector&&(this._pageViewEventListener?this._pageViewEventSelector.call(this._pageViewEventListener,this,ccui.PageView.EVENT_TURNING):this._pageViewEventSelector(this,ccui.PageView.EVENT_TURNING)),this._ccEventCallback&&this._ccEventCallback(this,ccui.PageView.EVENT_TURNING)},addEventListenerPageView:function(a,b){this.addEventListener(a,b)},addEventListener:function(a,b){this._pageViewEventSelector=a,this._pageViewEventListener=b},getCurPageIndex:function(){return this._curPageIdx},getPages:function(){return this._pages},getPage:function(a){return 0>a||a>=this._pages.length?null:this._pages[a]},getDescription:function(){return"PageView"},_createCloneInstance:function(){return new ccui.PageView},_copyClonedWidgetChildren:function(a){for(var b=a.getPages(),c=0;cb;b++){var g=e[b]._node;g instanceof ccui.ScrollView||g&&g._parent&&g._parent._inViewRect===!1||e[b].rendering(f)}}}}();cc.pool={_pool:{},_releaseCB:function(){this.release()},_autoRelease:function(a){var b=void 0===a._running?!1:!a._running;cc.director.getScheduler().schedule(this._releaseCB,a,0,0,0,b)},putInPool:function(a){var b=a.constructor.prototype.__pid;if(!b){var c={writable:!0,enumerable:!1,configurable:!0};c.value=ClassManager.getNewID(),Object.defineProperty(a.constructor.prototype,"__pid",c)}this._pool[b]||(this._pool[b]=[]),a.retain&&a.retain(),a.unuse&&a.unuse(),this._pool[b].push(a)},hasObject:function(a){var b=a.prototype.__pid,c=this._pool[b];return c&&0!==c.length?!0:!1},removeObject:function(a){var b=a.constructor.prototype.__pid;if(b){var c=this._pool[b];if(c)for(var d=0;da.space.sleepTimeThreshold?cc.color(84,84,84,128):cc.color(255,0,0,128)},cc.DrawShape=function(a,b){var c=a.body,d=cc.ColorForBody(c);switch(a.collisionCode){case cp.CircleShape.prototype.collisionCode:this.drawDot(a.tc,Math.max(a.r,1),d),this.drawSegment(a.tc,cp.v.add(a.tc,cp.v.mult(c.rot,a.r)),1,d);break;case cp.SegmentShape.prototype.collisionCode:this.drawSegment(a.ta,a.tb,Math.max(a.r,2),d);break;case cp.PolyShape.prototype.collisionCode:var e=cc.color(d.r,d.g,d.b,cc.lerp(d.a,255,.5));this.drawPoly(cc.__convertVerts(a.tVerts),d,1,e);break;default:cc.log("cc.DrawShape(): Bad assertion in DrawShape()")}},cc.DrawConstraint=function(a,b){var c,d,e=a.a,f=a.b;if(a instanceof cp.PinJoint)c=e.local2World(a.anchr1),d=f.local2World(a.anchr2),this.drawDot(c,3,cc.CONSTRAINT_COLOR),this.drawDot(d,3,cc.CONSTRAINT_COLOR),this.drawSegment(c,d,1,cc.CONSTRAINT_COLOR);else if(a instanceof cp.SlideJoint)c=e.local2World(a.anchr1),d=f.local2World(a.anchr2),this.drawDot(c,3,cc.CONSTRAINT_COLOR),this.drawDot(d,3,cc.CONSTRAINT_COLOR),this.drawSegment(c,d,1,cc.CONSTRAINT_COLOR);else if(a instanceof cp.PivotJoint)c=e.local2World(a.anchr1),d=f.local2World(a.anchr2),this.drawDot(c,3,cc.CONSTRAINT_COLOR),this.drawDot(d,3,cc.CONSTRAINT_COLOR);else if(a instanceof cp.GrooveJoint){c=e.local2World(a.grv_a),d=e.local2World(a.grv_b);var g=f.local2World(a.anchr2);this.drawDot(g,3,cc.CONSTRAINT_COLOR),this.drawSegment(c,d,1,cc.CONSTRAINT_COLOR)}else a instanceof cp.DampedSpring},cc.CONSTRAINT_COLOR=cc.color(0,255,0,128),cc.PhysicsDebugNode=cc.DrawNode.extend({_space:null,_className:"PhysicsDebugNode",ctor:function(a){cc.DrawNode.prototype.ctor.call(this),this._space=a},getSpace:function(){return this._space},setSpace:function(a){this._space=a},draw:function(a){this._space&&(this._space.eachShape(cc.DrawShape.bind(this)),this._space.eachConstraint(cc.DrawConstraint.bind(this)),cc.DrawNode.prototype.draw.call(this),this.clear())},_createRenderCmd:function(){return cc._renderType===cc.game.RENDER_TYPE_CANVAS?new cc.PhysicsDebugNode.CanvasRenderCmd(this):new cc.PhysicsDebugNode.WebGLRenderCmd(this)}}),cc.PhysicsDebugNode.create=function(a){return new cc.PhysicsDebugNode(a)},function(){cc.PhysicsDebugNode.CanvasRenderCmd=function(a){cc.Node.CanvasRenderCmd.call(this,a),this._buffer=a._buffer,this._needDraw=!0};var a=cc.PhysicsDebugNode.CanvasRenderCmd.prototype=Object.create(cc.Node.CanvasRenderCmd.prototype);a.constructor=cc.PhysicsDebugNode.CanvasRenderCmd,a.rendering=function(a,b,c){var d=this._node;d._space&&(d._space.eachShape(cc.DrawShape.bind(d)),d._space.eachConstraint(cc.DrawConstraint.bind(d)),cc.DrawNode.CanvasRenderCmd.prototype.rendering.call(this,a,b,c),d.clear())},a._drawDot=cc.DrawNode.CanvasRenderCmd.prototype._drawDot,a._drawSegment=cc.DrawNode.CanvasRenderCmd.prototype._drawSegment,a._drawPoly=cc.DrawNode.CanvasRenderCmd.prototype._drawPoly}();!function(){cc.PhysicsDebugNode.WebGLRenderCmd=function(a){cc.Node.WebGLRenderCmd.call(this,a),this._needDraw=!0},cc.PhysicsDebugNode.WebGLRenderCmd.prototype=Object.create(cc.Node.WebGLRenderCmd.prototype),cc.PhysicsDebugNode.WebGLRenderCmd.prototype.constructor=cc.PhysicsDebugNode.WebGLRenderCmd,cc.PhysicsDebugNode.WebGLRenderCmd.prototype.rendering=function(a){var b=this._node;b._space&&(b._space.eachShape(cc.DrawShape.bind(b)),b._space.eachConstraint(cc.DrawConstraint.bind(b)),cc.glBlendFunc(b._blendFunc.src,b._blendFunc.dst),this._shaderProgram.use(),this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix),b._render(),b.clear())}}(),function(){cc.PhysicsSprite.WebGLRenderCmd=function(a){cc.Sprite.WebGLRenderCmd.call(this,a),this._needDraw=!0};var a=cc.PhysicsSprite.WebGLRenderCmd.prototype=Object.create(cc.Sprite.WebGLRenderCmd.prototype);a.constructor=cc.PhysicsSprite.WebGLRenderCmd,a.rendering=function(a){var b=this._node;b._syncPosition(),b._ignoreBodyRotation||b._syncRotation(),this.transform(this.getParentRenderCmd(),!0),cc.Sprite.WebGLRenderCmd.prototype.rendering.call(this,a)},a.getNodeToParentTransform=function(){var a=this._node,b=a._body,c=this._anchorPointInPoints,d=a._scaleX,e=a._scaleY,f=b.p.x,g=b.p.y;this._ignoreAnchorPointForPosition&&(f+=c.x,g+=c.y);var h=b.a,i=1,j=0;return h&&!a._ignoreBodyRotation&&(i=Math.cos(h),j=Math.sin(h)),cc._rectEqualToZero(c)||(f+=i*-c.x*d+-j*-c.y*e,g+=j*-c.x*d+i*-c.y*e),this._transform=cc.affineTransformMake(i*d,j*d,-j*e,i*e,f,g),this._transform},a.updateTransform=function(){var a=this._node,b=a.isDirty();if(b){var c=a._renderCmd;c&&c.setDirtyRecursively(!0)}cc.Sprite.WebGLRenderCmd.prototype.updateTransform.call(this)}}();!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.io=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0&&!this.encoding){var a=this.packetBuffer.shift();this.packet(a)}},d.prototype.cleanup=function(){for(var a;a=this.subs.shift();)a.destroy();this.packetBuffer=[],this.encoding=!1,this.decoder.destroy()},d.prototype.close=d.prototype.disconnect=function(){this.skipReconnect=!0,this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},d.prototype.onclose=function(a){k("close"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",a),this._reconnection&&!this.skipReconnect&&this.reconnect()},d.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var a=this;if(this.backoff.attempts>=this._reconnectionAttempts)k("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var b=this.backoff.duration();k("will wait %dms before reconnect attempt",b),this.reconnecting=!0;var c=setTimeout(function(){a.skipReconnect||(k("attempting reconnect"),a.emitAll("reconnect_attempt",a.backoff.attempts),a.emitAll("reconnecting",a.backoff.attempts),a.skipReconnect||a.open(function(b){b?(k("reconnect attempt error"),a.reconnecting=!1,a.reconnect(),a.emitAll("reconnect_error",b.data)):(k("reconnect success"),a.onreconnect())}))},b);this.subs.push({destroy:function(){clearTimeout(c)}})}},d.prototype.onreconnect=function(){var a=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",a)}},{"./on":4,"./socket":5,"./url":6,backo2:7,"component-bind":8,"component-emitter":9,debug:10,"engine.io-client":11,indexof:42,"object-component":43,"socket.io-parser":46}],4:[function(a,b,c){function d(a,b,c){return a.on(b,c),{destroy:function(){a.removeListener(b,c)}}}b.exports=d},{}],5:[function(a,b,c){function d(a,b){this.io=a,this.nsp=b,this.json=this,this.ids=0,this.acks={},this.io.autoConnect&&this.open(),this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0}var e=a("socket.io-parser"),f=a("component-emitter"),g=a("to-array"),h=a("./on"),i=a("component-bind"),j=a("debug")("socket.io-client:socket"),k=a("has-binary");b.exports=c=d;var l={connect:1,connect_error:1,connect_timeout:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1},m=f.prototype.emit;f(d.prototype),d.prototype.subEvents=function(){if(!this.subs){var a=this.io;this.subs=[h(a,"open",i(this,"onopen")),h(a,"packet",i(this,"onpacket")),h(a,"close",i(this,"onclose"))]}},d.prototype.open=d.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),"open"==this.io.readyState&&this.onopen(),this)},d.prototype.send=function(){var a=g(arguments);return a.unshift("message"),this.emit.apply(this,a),this},d.prototype.emit=function(a){if(l.hasOwnProperty(a))return m.apply(this,arguments),this;var b=g(arguments),c=e.EVENT;k(b)&&(c=e.BINARY_EVENT);var d={type:c,data:b};return"function"==typeof b[b.length-1]&&(j("emitting packet with ack id %d",this.ids),this.acks[this.ids]=b.pop(),d.id=this.ids++),this.connected?this.packet(d):this.sendBuffer.push(d),this},d.prototype.packet=function(a){a.nsp=this.nsp,this.io.packet(a)},d.prototype.onopen=function(){j("transport is open - connecting"),"/"!=this.nsp&&this.packet({type:e.CONNECT})},d.prototype.onclose=function(a){j("close (%s)",a),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",a)},d.prototype.onpacket=function(a){if(a.nsp==this.nsp)switch(a.type){case e.CONNECT:this.onconnect();break;case e.EVENT:this.onevent(a);break;case e.BINARY_EVENT:this.onevent(a);break;case e.ACK:this.onack(a);break;case e.BINARY_ACK:this.onack(a);break;case e.DISCONNECT:this.ondisconnect();break;case e.ERROR:this.emit("error",a.data)}},d.prototype.onevent=function(a){var b=a.data||[];j("emitting event %j",b),null!=a.id&&(j("attaching ack callback to event"),b.push(this.ack(a.id))),this.connected?m.apply(this,b):this.receiveBuffer.push(b)},d.prototype.ack=function(a){var b=this,c=!1;return function(){if(!c){c=!0;var d=g(arguments);j("sending ack %j",d);var f=k(d)?e.BINARY_ACK:e.ACK;b.packet({type:f,id:a,data:d})}}},d.prototype.onack=function(a){j("calling ack %s with %j",a.id,a.data);var b=this.acks[a.id];b.apply(this,a.data),delete this.acks[a.id]},d.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},d.prototype.emitBuffered=function(){var a;for(a=0;a0&&a.jitter<=1?a.jitter:0,this.attempts=0}b.exports=d,d.prototype.duration=function(){var a=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var b=Math.random(),c=Math.floor(b*this.jitter*a);a=0==(1&Math.floor(10*b))?a-c:a+c}return 0|Math.min(a,this.max)},d.prototype.reset=function(){this.attempts=0},d.prototype.setMin=function(a){this.ms=a},d.prototype.setMax=function(a){this.max=a},d.prototype.setJitter=function(a){this.jitter=a}},{}],8:[function(a,b,c){var d=[].slice;b.exports=function(a,b){if("string"==typeof b&&(b=a[b]),"function"!=typeof b)throw new Error("bind() requires a function");var c=d.call(arguments,2);return function(){return b.apply(a,c.concat(d.call(arguments)))}}},{}],9:[function(a,b,c){function d(a){return a?e(a):void 0}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}b.exports=d,d.prototype.on=d.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},c.fn=b,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=d.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;for(var d,e=0;ed;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],10:[function(a,b,c){function d(a){return d.enabled(a)?function(b){b=e(b);var c=new Date,f=c-(d[a]||c);d[a]=c,b=a+" "+b+" +"+d.humanize(f),window.console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}:function(){}}function e(a){return a instanceof Error?a.stack||a.message:a}b.exports=d,d.names=[],d.skips=[],d.enable=function(a){try{localStorage.debug=a}catch(b){}for(var c=(a||"").split(/[\s,]+/),e=c.length,f=0;e>f;f++)a=c[f].replace("*",".*?"),"-"===a[0]?d.skips.push(new RegExp("^"+a.substr(1)+"$")):d.names.push(new RegExp("^"+a+"$"))},d.disable=function(){d.enable("")},d.humanize=function(a){var b=1e3,c=6e4,d=60*c;return a>=d?(a/d).toFixed(1)+"h":a>=c?(a/c).toFixed(1)+"m":a>=b?(a/b|0)+"s":a+"ms"},d.enabled=function(a){for(var b=0,c=d.skips.length;c>b;b++)if(d.skips[b].test(a))return!1;for(var b=0,c=d.names.length;c>b;b++)if(d.names[b].test(a))return!0;return!1};try{window.localStorage&&d.enable(localStorage.debug)}catch(f){}},{}],11:[function(a,b,c){b.exports=a("./lib/")},{"./lib/":12}],12:[function(a,b,c){b.exports=a("./socket"),b.exports.parser=a("engine.io-parser")},{"./socket":13,"engine.io-parser":25}],13:[function(a,b,c){(function(c){function d(a,b){if(!(this instanceof d))return new d(a,b);if(b=b||{},a&&"object"==typeof a&&(b=a,a=null),a&&(a=k(a),b.host=a.host,b.secure="https"==a.protocol||"wss"==a.protocol,b.port=a.port,a.query&&(b.query=a.query)),this.secure=null!=b.secure?b.secure:c.location&&"https:"==location.protocol,b.host){var e=b.host.split(":");b.hostname=e.shift(),e.length?b.port=e.pop():b.port||(b.port=this.secure?"443":"80")}this.agent=b.agent||!1,this.hostname=b.hostname||(c.location?location.hostname:"localhost"),this.port=b.port||(c.location&&location.port?location.port:this.secure?443:80),this.query=b.query||{},"string"==typeof this.query&&(this.query=m.decode(this.query)),this.upgrade=!1!==b.upgrade,this.path=(b.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!b.forceJSONP,this.jsonp=!1!==b.jsonp,this.forceBase64=!!b.forceBase64,this.enablesXDR=!!b.enablesXDR,this.timestampParam=b.timestampParam||"t",this.timestampRequests=b.timestampRequests,this.transports=b.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.callbackBuffer=[],this.policyPort=b.policyPort||843,this.rememberUpgrade=b.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=b.onlyBinaryUpgrades,this.pfx=b.pfx||null,this.key=b.key||null,this.passphrase=b.passphrase||null,this.cert=b.cert||null,this.ca=b.ca||null,this.ciphers=b.ciphers||null,this.rejectUnauthorized=b.rejectUnauthorized||null,this.open()}function e(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}var f=a("./transports"),g=a("component-emitter"),h=a("debug")("engine.io-client:socket"),i=a("indexof"),j=a("engine.io-parser"),k=a("parseuri"),l=a("parsejson"),m=a("parseqs");b.exports=d,d.priorWebsocketSuccess=!1,g(d.prototype),d.protocol=j.protocol,d.Socket=d,d.Transport=a("./transport"),d.transports=a("./transports"),d.parser=a("engine.io-parser"),d.prototype.createTransport=function(a){h('creating transport "%s"',a);var b=e(this.query);b.EIO=j.protocol,b.transport=a,this.id&&(b.sid=this.id);var c=new f[a]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:b,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized});return c},d.prototype.open=function(){var a;if(this.rememberUpgrade&&d.priorWebsocketSuccess&&-1!=this.transports.indexOf("websocket"))a="websocket";else{if(0==this.transports.length){var b=this;return void setTimeout(function(){b.emit("error","No transports available")},0)}a=this.transports[0]}this.readyState="opening";var a;try{a=this.createTransport(a)}catch(c){return this.transports.shift(),void this.open()}a.open(),this.setTransport(a)},d.prototype.setTransport=function(a){h("setting transport %s",a.name);var b=this;this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=a,a.on("drain",function(){b.onDrain()}).on("packet",function(a){b.onPacket(a)}).on("error",function(a){b.onError(a)}).on("close",function(){b.onClose("transport close")})},d.prototype.probe=function(a){function b(){if(m.onlyBinaryUpgrades){var b=!this.supportsBinary&&m.transport.supportsBinary;l=l||b}l||(h('probe transport "%s" opened',a),k.send([{type:"ping",data:"probe"}]),k.once("packet",function(b){if(!l)if("pong"==b.type&&"probe"==b.data){if(h('probe transport "%s" pong',a),m.upgrading=!0,m.emit("upgrading",k),!k)return;d.priorWebsocketSuccess="websocket"==k.name,h('pausing current transport "%s"',m.transport.name),m.transport.pause(function(){l||"closed"!=m.readyState&&(h("changing transport and sending upgrade packet"),j(),m.setTransport(k),k.send([{type:"upgrade"}]),m.emit("upgrade",k),k=null,m.upgrading=!1,m.flush())})}else{h('probe transport "%s" failed',a);var c=new Error("probe error");c.transport=k.name,m.emit("upgradeError",c)}}))}function c(){l||(l=!0,j(),k.close(),k=null)}function e(b){var d=new Error("probe error: "+b);d.transport=k.name,c(),h('probe transport "%s" failed because of error: %s',a,b),m.emit("upgradeError",d)}function f(){e("transport closed")}function g(){e("socket closed")}function i(a){k&&a.name!=k.name&&(h('"%s" works - aborting "%s"',a.name,k.name),c())}function j(){k.removeListener("open",b),k.removeListener("error",e),k.removeListener("close",f),m.removeListener("close",g),m.removeListener("upgrading",i)}h('probing transport "%s"',a);var k=this.createTransport(a,{probe:1}),l=!1,m=this;d.priorWebsocketSuccess=!1,k.once("open",b),k.once("error",e),k.once("close",f),this.once("close",g),this.once("upgrading",i),k.open()},d.prototype.onOpen=function(){if(h("socket open"),this.readyState="open",d.priorWebsocketSuccess="websocket"==this.transport.name,this.emit("open"),this.flush(),"open"==this.readyState&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var a=0,b=this.upgrades.length;b>a;a++)this.probe(this.upgrades[a])}},d.prototype.onPacket=function(a){if("opening"==this.readyState||"open"==this.readyState)switch(h('socket receive: type "%s", data "%s"',a.type,a.data),this.emit("packet",a),this.emit("heartbeat"),a.type){case"open":this.onHandshake(l(a.data));break;case"pong":this.setPing();break;case"error":var b=new Error("server error");b.code=a.data,this.emit("error",b);break;case"message":this.emit("data",a.data),this.emit("message",a.data)}else h('packet received with socket readyState "%s"',this.readyState)},d.prototype.onHandshake=function(a){this.emit("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this.upgrades=this.filterUpgrades(a.upgrades),this.pingInterval=a.pingInterval,this.pingTimeout=a.pingTimeout,this.onOpen(),"closed"!=this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},d.prototype.onHeartbeat=function(a){clearTimeout(this.pingTimeoutTimer);var b=this;b.pingTimeoutTimer=setTimeout(function(){"closed"!=b.readyState&&b.onClose("ping timeout")},a||b.pingInterval+b.pingTimeout)},d.prototype.setPing=function(){var a=this;clearTimeout(a.pingIntervalTimer),a.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",a.pingTimeout),a.ping(),a.onHeartbeat(a.pingTimeout)},a.pingInterval)},d.prototype.ping=function(){this.sendPacket("ping")},d.prototype.onDrain=function(){for(var a=0;ac;c++)~i(this.transports,a[c])&&b.push(a[c]);return b}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./transport":14,"./transports":15,"component-emitter":9,debug:22,"engine.io-parser":25,indexof:42,parsejson:34,parseqs:35,parseuri:36}],14:[function(a,b,c){function d(a){this.path=a.path,this.hostname=a.hostname,this.port=a.port,this.secure=a.secure,this.query=a.query,this.timestampParam=a.timestampParam,this.timestampRequests=a.timestampRequests,this.readyState="",this.agent=a.agent||!1,this.socket=a.socket,this.enablesXDR=a.enablesXDR,this.pfx=a.pfx,this.key=a.key,this.passphrase=a.passphrase,this.cert=a.cert,this.ca=a.ca,this.ciphers=a.ciphers,this.rejectUnauthorized=a.rejectUnauthorized}var e=a("engine.io-parser"),f=a("component-emitter");b.exports=d,f(d.prototype),d.timestamps=0,d.prototype.onError=function(a,b){var c=new Error(a);return c.type="TransportError",c.description=b,this.emit("error",c),this},d.prototype.open=function(){return("closed"==this.readyState||""==this.readyState)&&(this.readyState="opening",this.doOpen()),this},d.prototype.close=function(){return("opening"==this.readyState||"open"==this.readyState)&&(this.doClose(),this.onClose()),this},d.prototype.send=function(a){if("open"!=this.readyState)throw new Error("Transport not open");this.write(a)},d.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},d.prototype.onData=function(a){var b=e.decodePacket(a,this.socket.binaryType);this.onPacket(b)},d.prototype.onPacket=function(a){this.emit("packet",a)},d.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":9,"engine.io-parser":25}],15:[function(a,b,c){(function(b){function d(a){var c,d=!1,h=!1,i=!1!==a.jsonp;if(b.location){var j="https:"==location.protocol,k=location.port;k||(k=j?443:80),d=a.hostname!=location.hostname||k!=a.port,h=a.secure!=j}if(a.xdomain=d,a.xscheme=h,c=new e(a),"open"in c&&!a.forceJSONP)return new f(a);if(!i)throw new Error("JSONP disabled");return new g(a)}var e=a("xmlhttprequest"),f=a("./polling-xhr"),g=a("./polling-jsonp"),h=a("./websocket");c.polling=d,c.websocket=h}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling-jsonp":16,"./polling-xhr":17,"./websocket":19,xmlhttprequest:20}],16:[function(a,b,c){(function(c){function d(){}function e(a){f.call(this,a),this.query=this.query||{},h||(c.___eio||(c.___eio=[]),h=c.___eio),this.index=h.length;var b=this;h.push(function(a){b.onData(a)}),this.query.j=this.index,c.document&&c.addEventListener&&c.addEventListener("beforeunload",function(){b.script&&(b.script.onerror=d)},!1)}var f=a("./polling"),g=a("component-inherit");b.exports=e;var h,i=/\n/g,j=/\\n/g;g(e,f),e.prototype.supportsBinary=!1,e.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),f.prototype.doClose.call(this)},e.prototype.doPoll=function(){var a=this,b=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.uri(),b.onerror=function(b){a.onError("jsonp poll error",b)};var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c),this.script=b;var d="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent);d&&setTimeout(function(){var a=document.createElement("iframe");document.body.appendChild(a),document.body.removeChild(a)},100)},e.prototype.doWrite=function(a,b){function c(){d(),b()}function d(){if(e.iframe)try{e.form.removeChild(e.iframe)}catch(a){e.onError("jsonp polling iframe removal error",a)}try{var b='