Merge branch 'v3' into v3_CameraMaskFor2DAnd3DRendering
|
@ -2111,6 +2111,29 @@ Reference* Bundle3D::seekToFirstType(unsigned int type, const std::string& id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<Vec3> Bundle3D::getTrianglesList(const std::string& path)
|
||||
{
|
||||
std::vector<Vec3> trianglesList;
|
||||
auto bundle = Bundle3D::createBundle();
|
||||
if (!bundle->load(path))
|
||||
{
|
||||
Bundle3D::destroyBundle(bundle);
|
||||
return trianglesList;
|
||||
}
|
||||
MeshDatas meshs;
|
||||
bundle->loadMeshDatas(meshs);
|
||||
Bundle3D::destroyBundle(bundle);
|
||||
for (auto iter : meshs.meshDatas){
|
||||
int preVertexSize = iter->getPerVertexSize() / sizeof(float);
|
||||
for (auto indexArray : iter->subMeshIndices){
|
||||
for (auto i : indexArray){
|
||||
trianglesList.push_back(Vec3(iter->vertex[i * preVertexSize], iter->vertex[i * preVertexSize + 1], iter->vertex[i * preVertexSize + 2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return trianglesList;
|
||||
}
|
||||
|
||||
Bundle3D::Bundle3D()
|
||||
: _modelPath(""),
|
||||
_path(""),
|
||||
|
|
|
@ -85,6 +85,12 @@ public:
|
|||
//since 3.3, to support reskin
|
||||
virtual bool loadMaterials(MaterialDatas& materialdatas);
|
||||
|
||||
/**
|
||||
* load triangle list
|
||||
* @param path the file path to load
|
||||
*/
|
||||
static std::vector<Vec3> getTrianglesList(const std::string& path);
|
||||
|
||||
//load .obj file
|
||||
static bool loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeDatas& nodedatas, const std::string& fullPath, const char* mtl_basepath = nullptr);
|
||||
|
||||
|
|
|
@ -262,9 +262,9 @@ bool Terrain::initHeightMap(const char * heightMap)
|
|||
Terrain::Terrain()
|
||||
{
|
||||
_alphaMap = nullptr;
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
_customCommand.setTransparent(false);
|
||||
_customCommand.set3D(true);
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
auto _backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED,
|
||||
[this](EventCustom*)
|
||||
{
|
||||
|
|
|
@ -40,6 +40,8 @@ NS_CC_BEGIN
|
|||
|
||||
class CC_DLL Data
|
||||
{
|
||||
friend class Properties;
|
||||
|
||||
public:
|
||||
/**
|
||||
* This parameter is defined for convenient reference if a null Data object is needed.
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
|
||||
|
||||
#include "CCProperties.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "math/Vec2.h"
|
||||
|
@ -32,37 +35,8 @@
|
|||
#include "deprecated/CCString.h"
|
||||
|
||||
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
static void printProperties(Properties* properties)
|
||||
{
|
||||
// Print the name and ID of the current namespace.
|
||||
const char* spacename = properties->getNamespace();
|
||||
const char* id = properties->getId();
|
||||
CCLOG("Namespace: %s ID: %s\n{", spacename, id);
|
||||
|
||||
// Print all properties in this namespace.
|
||||
const char* name = properties->getNextProperty();
|
||||
const char* value = NULL;
|
||||
while (name != NULL)
|
||||
{
|
||||
value = properties->getString(name);
|
||||
CCLOG("%s = %s", name, value);
|
||||
name = properties->getNextProperty();
|
||||
}
|
||||
|
||||
// Print the properties of every namespace within this one.
|
||||
Properties* space = properties->getNextNamespace();
|
||||
while (space != NULL)
|
||||
{
|
||||
printProperties(space);
|
||||
space = properties->getNextNamespace();
|
||||
}
|
||||
|
||||
CCLOG("}\n");
|
||||
}
|
||||
|
||||
// Utility functions (shared with SceneLoader).
|
||||
/** @script{ignore} */
|
||||
void calculateNamespacePath(const std::string& urlString, std::string& fileString, std::vector<std::string>& namespacePath);
|
||||
|
@ -72,6 +46,7 @@ Properties* getPropertiesFromNamespacePath(Properties* properties, const std::ve
|
|||
Properties::Properties()
|
||||
: _variables(nullptr), _dirPath(nullptr), _parent(nullptr), _dataIdx(nullptr), _data(nullptr)
|
||||
{
|
||||
_properties.reserve(32);
|
||||
}
|
||||
|
||||
Properties::Properties(const Properties& copy)
|
||||
|
@ -80,12 +55,10 @@ Properties::Properties(const Properties& copy)
|
|||
_dataIdx(copy._dataIdx), _data(copy._data)
|
||||
{
|
||||
setDirectoryPath(copy._dirPath);
|
||||
_namespaces = std::vector<Properties*>();
|
||||
std::vector<Properties*>::const_iterator it;
|
||||
for (it = copy._namespaces.begin(); it < copy._namespaces.end(); ++it)
|
||||
|
||||
for (const auto space: copy._namespaces)
|
||||
{
|
||||
GP_ASSERT(*it);
|
||||
_namespaces.push_back(new (std::nothrow) Properties(**it));
|
||||
_namespaces.push_back(new (std::nothrow) Properties(*space));
|
||||
}
|
||||
rewind();
|
||||
}
|
||||
|
@ -112,7 +85,7 @@ Properties::Properties(Data* data, ssize_t* dataIdx, const std::string& name, co
|
|||
rewind();
|
||||
}
|
||||
|
||||
Properties* Properties::create(const std::string& url)
|
||||
Properties* Properties::createWithoutAutorelease(const std::string& url)
|
||||
{
|
||||
if (url.size() == 0)
|
||||
{
|
||||
|
@ -214,7 +187,7 @@ void Properties::readProperties()
|
|||
else
|
||||
{
|
||||
trimWhiteSpace(line);
|
||||
const int len = strlen(line);
|
||||
const auto len = strlen(line);
|
||||
if (len >= 2 && strncmp(line + (len - 2), "*/", 2) == 0)
|
||||
comment = false;
|
||||
}
|
||||
|
@ -441,7 +414,7 @@ signed char Properties::readChar()
|
|||
{
|
||||
if (eof())
|
||||
return EOF;
|
||||
return _data->getBytes()[(*_dataIdx)++];
|
||||
return _data->_bytes[(*_dataIdx)++];
|
||||
}
|
||||
|
||||
char* Properties::readLine(char* output, int num)
|
||||
|
@ -451,15 +424,20 @@ char* Properties::readLine(char* output, int num)
|
|||
if (eof())
|
||||
return nullptr;
|
||||
|
||||
auto c = readChar();
|
||||
while (c!=EOF && c!='\n' && idx-1<num)
|
||||
{
|
||||
output[idx++] = c;
|
||||
c = readChar();
|
||||
// little optimization: avoid uneeded dereferences
|
||||
ssize_t dataIdx = *_dataIdx;
|
||||
|
||||
while (dataIdx<_data->_size && _data->_bytes[dataIdx]!='\n' && idx-1<num)
|
||||
{
|
||||
dataIdx++; idx++;
|
||||
}
|
||||
|
||||
memcpy(output, &_data->_bytes[*_dataIdx], idx);
|
||||
output[idx] = '\0';
|
||||
|
||||
// restore value
|
||||
*_dataIdx = dataIdx;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -472,7 +450,7 @@ bool Properties::seekFromCurrent(int offset)
|
|||
|
||||
bool Properties::eof()
|
||||
{
|
||||
return (*_dataIdx >= _data->getSize());
|
||||
return (*_dataIdx >= _data->_size);
|
||||
}
|
||||
|
||||
void Properties::skipWhiteSpace()
|
||||
|
@ -563,10 +541,9 @@ void Properties::resolveInheritance(const char* id)
|
|||
derived->_properties = parent->_properties;
|
||||
derived->_namespaces = std::vector<Properties*>();
|
||||
std::vector<Properties*>::const_iterator itt;
|
||||
for (itt = parent->_namespaces.begin(); itt < parent->_namespaces.end(); ++itt)
|
||||
for (const auto space: parent->_namespaces)
|
||||
{
|
||||
GP_ASSERT(*itt);
|
||||
derived->_namespaces.push_back(new (std::nothrow) Properties(**itt));
|
||||
derived->_namespaces.push_back(new (std::nothrow) Properties(*space));
|
||||
}
|
||||
derived->rewind();
|
||||
|
||||
|
@ -595,7 +572,7 @@ void Properties::resolveInheritance(const char* id)
|
|||
|
||||
void Properties::mergeWith(Properties* overrides)
|
||||
{
|
||||
GP_ASSERT(overrides);
|
||||
CCASSERT(overrides, "Invalid overrides");
|
||||
|
||||
// Overwrite or add each property found in child.
|
||||
overrides->rewind();
|
||||
|
@ -685,7 +662,7 @@ void Properties::rewind()
|
|||
|
||||
Properties* Properties::getNamespace(const char* id, bool searchNames, bool recurse) const
|
||||
{
|
||||
GP_ASSERT(id);
|
||||
CCASSERT(id, "invalid id");
|
||||
|
||||
for (std::vector<Properties*>::const_iterator it = _namespaces.begin(); it < _namespaces.end(); ++it)
|
||||
{
|
||||
|
@ -720,7 +697,7 @@ bool Properties::exists(const char* name) const
|
|||
if (name == NULL)
|
||||
return false;
|
||||
|
||||
for (std::list<Property>::const_iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
|
||||
for (std::vector<Property>::const_iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
|
||||
{
|
||||
if (itr->name == name)
|
||||
return true;
|
||||
|
@ -731,7 +708,7 @@ bool Properties::exists(const char* name) const
|
|||
|
||||
static const bool isStringNumeric(const char* str)
|
||||
{
|
||||
GP_ASSERT(str);
|
||||
CCASSERT(str, "invalid str");
|
||||
|
||||
// The first character may be '-'
|
||||
if (*str == '-')
|
||||
|
@ -810,7 +787,7 @@ const char* Properties::getString(const char* name, const char* defaultValue) co
|
|||
return getVariable(variable, defaultValue);
|
||||
}
|
||||
|
||||
for (std::list<Property>::const_iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
|
||||
for (std::vector<Property>::const_iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
|
||||
{
|
||||
if (itr->name == name)
|
||||
{
|
||||
|
@ -844,7 +821,7 @@ bool Properties::setString(const char* name, const char* value)
|
|||
{
|
||||
if (name)
|
||||
{
|
||||
for (std::list<Property>::iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
|
||||
for (std::vector<Property>::iterator itr = _properties.begin(); itr != _properties.end(); ++itr)
|
||||
{
|
||||
if (itr->name == name)
|
||||
{
|
||||
|
@ -939,7 +916,7 @@ long Properties::getLong(const char* name) const
|
|||
|
||||
bool Properties::getMat4(const char* name, Mat4* out) const
|
||||
{
|
||||
GP_ASSERT(out);
|
||||
CCASSERT(out, "Invalid out");
|
||||
|
||||
const char* valueString = getString(name);
|
||||
if (valueString)
|
||||
|
@ -997,7 +974,7 @@ bool Properties::getColor(const char* name, Vec4* out) const
|
|||
|
||||
bool Properties::getPath(const char* name, std::string* path) const
|
||||
{
|
||||
GP_ASSERT(name && path);
|
||||
CCASSERT(name && path, "Invalid name or path");
|
||||
const char* valueString = getString(name);
|
||||
if (valueString)
|
||||
{
|
||||
|
@ -1052,7 +1029,7 @@ const char* Properties::getVariable(const char* name, const char* defaultValue)
|
|||
|
||||
void Properties::setVariable(const char* name, const char* value)
|
||||
{
|
||||
GP_ASSERT(name);
|
||||
CCASSERT(name, "Invalid name");
|
||||
|
||||
Property* prop = NULL;
|
||||
|
||||
|
@ -1102,7 +1079,7 @@ Properties* Properties::clone()
|
|||
|
||||
for (size_t i = 0, count = _namespaces.size(); i < count; i++)
|
||||
{
|
||||
GP_ASSERT(_namespaces[i]);
|
||||
CCASSERT(_namespaces[i], "Invalid namespace");
|
||||
Properties* child = _namespaces[i]->clone();
|
||||
p->_namespaces.push_back(child);
|
||||
child->_parent = p;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <string>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "renderer/CCTexture2D.h"
|
||||
#include "platform/CCPlatformMacros.h"
|
||||
|
@ -105,7 +105,7 @@ class Data;
|
|||
|
||||
@verbatim
|
||||
// Create the top-level Properties object.
|
||||
Properties* properties = Properties::create("example.properties");
|
||||
Properties* properties = Properties::createWithoutAutorelease("example.properties");
|
||||
// Retrieve the "spriteTexture" namespace.
|
||||
Properties* spriteTexture = properties->getNamespace("spriteTexture");
|
||||
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
* @return The created Properties or NULL if there was an error.
|
||||
* @script{create}
|
||||
*/
|
||||
static Properties* create(const std::string& url);
|
||||
static Properties* createWithoutAutorelease(const std::string& url);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
|
@ -579,7 +579,7 @@ private:
|
|||
bool seekFromCurrent(int offset);
|
||||
bool eof();
|
||||
|
||||
// Called after create(); copies info from parents into derived namespaces.
|
||||
// Called after createWithoutAutorelease(); copies info from parents into derived namespaces.
|
||||
void resolveInheritance(const char* id = NULL);
|
||||
|
||||
// Called by resolveInheritance().
|
||||
|
@ -602,8 +602,8 @@ private:
|
|||
std::string _namespace;
|
||||
std::string _id;
|
||||
std::string _parentID;
|
||||
std::list<Property> _properties;
|
||||
std::list<Property>::iterator _propertiesItr;
|
||||
std::vector<Property> _properties;
|
||||
std::vector<Property>::iterator _propertiesItr;
|
||||
std::vector<Properties*> _namespaces;
|
||||
std::vector<Properties*>::const_iterator _namespacesItr;
|
||||
std::vector<Property>* _variables;
|
||||
|
|
|
@ -562,11 +562,12 @@ static Data getData(const std::string& filename, bool forString)
|
|||
else
|
||||
mode = "rb";
|
||||
|
||||
auto fileutils = FileUtils::getInstance();
|
||||
do
|
||||
{
|
||||
// Read the file from hardware
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename);
|
||||
FILE *fp = fopen(FileUtils::getInstance()->getSuitableFOpen(fullPath).c_str(), mode);
|
||||
std::string fullPath = fileutils->fullPathForFilename(filename);
|
||||
FILE *fp = fopen(fileutils->getSuitableFOpen(fullPath).c_str(), mode);
|
||||
CC_BREAK_IF(!fp);
|
||||
fseek(fp,0,SEEK_END);
|
||||
size = ftell(fp);
|
||||
|
@ -593,9 +594,7 @@ static Data getData(const std::string& filename, bool forString)
|
|||
|
||||
if (nullptr == buffer || 0 == readsize)
|
||||
{
|
||||
std::string msg = "Get data from file(";
|
||||
msg.append(filename).append(") failed!");
|
||||
CCLOG("%s", msg.c_str());
|
||||
CCLOG("Get data from file %s failed", filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -101,6 +101,15 @@ public class Cocos2dxLocalStorage {
|
|||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
try {
|
||||
String sql = "delete from "+TABLE_NAME;
|
||||
mDatabase.execSQL(sql);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This creates/opens the database.
|
||||
|
|
|
@ -109,10 +109,13 @@ bool Material::initWithFile(const std::string& validfilename)
|
|||
char* bytes = (char*)data.getBytes();
|
||||
bytes[data.getSize()-1]='\0';
|
||||
|
||||
Properties* properties = Properties::create(validfilename);
|
||||
// Warning: properties is not a "Ref" object, must be manually deleted
|
||||
Properties* properties = Properties::createWithoutAutorelease(validfilename);
|
||||
|
||||
// get the first material
|
||||
parseProperties((strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace());
|
||||
|
||||
CC_SAFE_DELETE(properties);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -20069,6 +20069,78 @@ TextFieldTTF : function (
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ParallaxNode
|
||||
*/
|
||||
cc.ParallaxNode = {
|
||||
|
||||
/**
|
||||
* @method getParallaxArray
|
||||
* @return {cc._ccArray|cc._ccArray}
|
||||
*/
|
||||
getParallaxArray : function(
|
||||
)
|
||||
{
|
||||
return cc._ccArray;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method addChild
|
||||
* @param {cc.Node} arg0
|
||||
* @param {int} arg1
|
||||
* @param {vec2_object} arg2
|
||||
* @param {vec2_object} arg3
|
||||
*/
|
||||
addChild : function (
|
||||
node,
|
||||
int,
|
||||
vec2,
|
||||
vec2
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeAllChildrenWithCleanup
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
removeAllChildrenWithCleanup : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setParallaxArray
|
||||
* @param {cc._ccArray} arg0
|
||||
*/
|
||||
setParallaxArray : function (
|
||||
_ccarray
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @return {cc.ParallaxNode}
|
||||
*/
|
||||
create : function (
|
||||
)
|
||||
{
|
||||
return cc.ParallaxNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method ParallaxNode
|
||||
* @constructor
|
||||
*/
|
||||
ParallaxNode : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class TMXObjectGroup
|
||||
*/
|
||||
|
@ -20634,7 +20706,7 @@ cc.TMXLayer = {
|
|||
* @method getTileGIDAt
|
||||
* @param {vec2_object} arg0
|
||||
* @param {cc.TMXTileFlags_} arg1
|
||||
* @return {int}
|
||||
* @return {unsigned int}
|
||||
*/
|
||||
getTileGIDAt : function (
|
||||
vec2,
|
||||
|
@ -20666,6 +20738,14 @@ int
|
|||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method releaseMap
|
||||
*/
|
||||
releaseMap : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setTiles
|
||||
* @param {unsigned int} arg0
|
||||
|
@ -20737,13 +20817,19 @@ vec2
|
|||
},
|
||||
|
||||
/**
|
||||
* @method getProperties
|
||||
* @return {map_object|map_object}
|
||||
* @method initWithTilesetInfo
|
||||
* @param {cc.TMXTilesetInfo} arg0
|
||||
* @param {cc.TMXLayerInfo} arg1
|
||||
* @param {cc.TMXMapInfo} arg2
|
||||
* @return {bool}
|
||||
*/
|
||||
getProperties : function(
|
||||
initWithTilesetInfo : function (
|
||||
tmxtilesetinfo,
|
||||
tmxlayerinfo,
|
||||
map
|
||||
)
|
||||
{
|
||||
return map_object;
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -20754,23 +20840,9 @@ setupTiles : function (
|
|||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setupTileSprite
|
||||
* @param {cc.Sprite} arg0
|
||||
* @param {vec2_object} arg1
|
||||
* @param {int} arg2
|
||||
*/
|
||||
setupTileSprite : function (
|
||||
sprite,
|
||||
vec2,
|
||||
int
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setTileGID
|
||||
* @param {int|int} int
|
||||
* @param {unsigned int|unsigned int} int
|
||||
* @param {vec2_object|vec2_object} vec2
|
||||
* @param {cc.TMXTileFlags_} tmxtileflags_
|
||||
*/
|
||||
|
@ -20844,6 +20916,16 @@ getTileSet : function (
|
|||
return cc.TMXTilesetInfo;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getProperties
|
||||
* @return {map_object|map_object}
|
||||
*/
|
||||
getProperties : function(
|
||||
)
|
||||
{
|
||||
return map_object;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTileAt
|
||||
* @param {vec2_object} arg0
|
||||
|
@ -20861,7 +20943,7 @@ vec2
|
|||
* @param {cc.TMXTilesetInfo} arg0
|
||||
* @param {cc.TMXLayerInfo} arg1
|
||||
* @param {cc.TMXMapInfo} arg2
|
||||
* @return {cc.experimental::TMXLayer}
|
||||
* @return {cc.TMXLayer}
|
||||
*/
|
||||
create : function (
|
||||
tmxtilesetinfo,
|
||||
|
@ -20869,7 +20951,7 @@ tmxlayerinfo,
|
|||
map
|
||||
)
|
||||
{
|
||||
return cc.experimental::TMXLayer;
|
||||
return cc.TMXLayer;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -20942,6 +21024,32 @@ getObjectGroups : function(
|
|||
return new Array();
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithXML
|
||||
* @param {String} arg0
|
||||
* @param {String} arg1
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithXML : function (
|
||||
str,
|
||||
str
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method initWithTMXFile
|
||||
* @param {String} arg0
|
||||
* @return {bool}
|
||||
*/
|
||||
initWithTMXFile : function (
|
||||
str
|
||||
)
|
||||
{
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method getTileSize
|
||||
* @return {size_object}
|
||||
|
@ -20974,14 +21082,16 @@ getProperties : function (
|
|||
|
||||
/**
|
||||
* @method getPropertiesForGID
|
||||
* @param {int} arg0
|
||||
* @return {cc.Value}
|
||||
* @param {int|int} int
|
||||
* @param {cc.Value} value
|
||||
* @return {bool|cc.Value}
|
||||
*/
|
||||
getPropertiesForGID : function(
|
||||
int
|
||||
int,
|
||||
value
|
||||
)
|
||||
{
|
||||
return cc.Value;
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -21007,13 +21117,13 @@ map
|
|||
/**
|
||||
* @method getLayer
|
||||
* @param {String} arg0
|
||||
* @return {cc.experimental::TMXLayer}
|
||||
* @return {cc.TMXLayer}
|
||||
*/
|
||||
getLayer : function (
|
||||
str
|
||||
)
|
||||
{
|
||||
return cc.experimental::TMXLayer;
|
||||
return cc.TMXLayer;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -21039,97 +21149,34 @@ int
|
|||
/**
|
||||
* @method create
|
||||
* @param {String} arg0
|
||||
* @return {cc.experimental::TMXTiledMap}
|
||||
* @return {cc.TMXTiledMap}
|
||||
*/
|
||||
create : function (
|
||||
str
|
||||
)
|
||||
{
|
||||
return cc.experimental::TMXTiledMap;
|
||||
return cc.TMXTiledMap;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method createWithXML
|
||||
* @param {String} arg0
|
||||
* @param {String} arg1
|
||||
* @return {cc.experimental::TMXTiledMap}
|
||||
* @return {cc.TMXTiledMap}
|
||||
*/
|
||||
createWithXML : function (
|
||||
str,
|
||||
str
|
||||
)
|
||||
{
|
||||
return cc.experimental::TMXTiledMap;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @class ParallaxNode
|
||||
*/
|
||||
cc.ParallaxNode = {
|
||||
|
||||
/**
|
||||
* @method getParallaxArray
|
||||
* @return {cc._ccArray|cc._ccArray}
|
||||
*/
|
||||
getParallaxArray : function(
|
||||
)
|
||||
{
|
||||
return cc._ccArray;
|
||||
return cc.TMXTiledMap;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method addChild
|
||||
* @param {cc.Node} arg0
|
||||
* @param {int} arg1
|
||||
* @param {vec2_object} arg2
|
||||
* @param {vec2_object} arg3
|
||||
*/
|
||||
addChild : function (
|
||||
node,
|
||||
int,
|
||||
vec2,
|
||||
vec2
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method removeAllChildrenWithCleanup
|
||||
* @param {bool} arg0
|
||||
*/
|
||||
removeAllChildrenWithCleanup : function (
|
||||
bool
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setParallaxArray
|
||||
* @param {cc._ccArray} arg0
|
||||
*/
|
||||
setParallaxArray : function (
|
||||
_ccarray
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @return {cc.ParallaxNode}
|
||||
*/
|
||||
create : function (
|
||||
)
|
||||
{
|
||||
return cc.ParallaxNode;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method ParallaxNode
|
||||
* @method TMXTiledMap
|
||||
* @constructor
|
||||
*/
|
||||
ParallaxNode : function (
|
||||
TMXTiledMap : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
|
|
@ -3624,6 +3624,20 @@ bool js_cocos2dx_TextFieldTTF_attachWithIME(JSContext *cx, uint32_t argc, jsval
|
|||
bool js_cocos2dx_TextFieldTTF_textFieldWithPlaceHolder(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TextFieldTTF_TextFieldTTF(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_ParallaxNode_class;
|
||||
extern JSObject *jsb_cocos2d_ParallaxNode_prototype;
|
||||
|
||||
bool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_ParallaxNode_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_ParallaxNode(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_setParallaxArray(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_ParallaxNode(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_TMXObjectGroup_class;
|
||||
extern JSObject *jsb_cocos2d_TMXObjectGroup_prototype;
|
||||
|
||||
|
@ -3707,8 +3721,8 @@ bool js_cocos2dx_TMXMapInfo_create(JSContext *cx, uint32_t argc, jsval *vp);
|
|||
bool js_cocos2dx_TMXMapInfo_createWithXML(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXMapInfo_TMXMapInfo(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_experimental_TMXLayer_class;
|
||||
extern JSObject *jsb_cocos2d_experimental_TMXLayer_prototype;
|
||||
extern JSClass *jsb_cocos2d_TMXLayer_class;
|
||||
extern JSObject *jsb_cocos2d_TMXLayer_prototype;
|
||||
|
||||
bool js_cocos2dx_TMXLayer_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_TMXLayer_finalize(JSContext *cx, JSObject *obj);
|
||||
|
@ -3717,6 +3731,7 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
|||
bool js_cocos2dx_TMXLayer_getTileGIDAt(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getPositionAt(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setLayerOrientation(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_releaseMap(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setTiles(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getLayerSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setMapTileSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
@ -3724,9 +3739,8 @@ bool js_cocos2dx_TMXLayer_getLayerOrientation(JSContext *cx, uint32_t argc, jsva
|
|||
bool js_cocos2dx_TMXLayer_setProperties(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setLayerName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_removeTileAt(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_initWithTilesetInfo(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setupTiles(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setupTileSprite(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setTileGID(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getMapTileSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getProperty(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
@ -3734,12 +3748,13 @@ bool js_cocos2dx_TMXLayer_setLayerSize(JSContext *cx, uint32_t argc, jsval *vp);
|
|||
bool js_cocos2dx_TMXLayer_getLayerName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_setTileSet(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getTileSet(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getProperties(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_getTileAt(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXLayer_TMXLayer(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_experimental_TMXTiledMap_class;
|
||||
extern JSObject *jsb_cocos2d_experimental_TMXTiledMap_prototype;
|
||||
extern JSClass *jsb_cocos2d_TMXTiledMap_class;
|
||||
extern JSObject *jsb_cocos2d_TMXTiledMap_prototype;
|
||||
|
||||
bool js_cocos2dx_TMXTiledMap_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_TMXTiledMap_finalize(JSContext *cx, JSObject *obj);
|
||||
|
@ -3750,6 +3765,8 @@ bool js_cocos2dx_TMXTiledMap_getProperty(JSContext *cx, uint32_t argc, jsval *vp
|
|||
bool js_cocos2dx_TMXTiledMap_setMapSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_getObjectGroup(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_getObjectGroups(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_initWithXML(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_initWithTMXFile(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_getTileSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_getMapSize(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_getProperties(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
@ -3761,20 +3778,7 @@ bool js_cocos2dx_TMXTiledMap_getMapOrientation(JSContext *cx, uint32_t argc, jsv
|
|||
bool js_cocos2dx_TMXTiledMap_setMapOrientation(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_createWithXML(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_ParallaxNode_class;
|
||||
extern JSObject *jsb_cocos2d_ParallaxNode_prototype;
|
||||
|
||||
bool js_cocos2dx_ParallaxNode_constructor(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
void js_cocos2dx_ParallaxNode_finalize(JSContext *cx, JSObject *obj);
|
||||
void js_register_cocos2dx_ParallaxNode(JSContext *cx, JS::HandleObject global);
|
||||
void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
||||
bool js_cocos2dx_ParallaxNode_getParallaxArray(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_addChild(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_removeAllChildrenWithCleanup(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_setParallaxArray(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_ParallaxNode_ParallaxNode(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_TMXTiledMap_TMXTiledMap(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
extern JSClass *jsb_cocos2d_TileMapAtlas_class;
|
||||
extern JSObject *jsb_cocos2d_TileMapAtlas_prototype;
|
||||
|
|
|
@ -69,5 +69,15 @@ bool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Arguments: char*, char*
|
||||
// Ret value: void
|
||||
bool JSB_localStorageClear(JSContext *cx, uint32_t argc, jsval *vp) {
|
||||
JSB_PRECONDITION2( argc == 0, cx, false, "Invalid number of arguments" );
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
||||
localStorageClear();
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
//#endif // JSB_INCLUDE_SYSTEM
|
||||
|
|
|
@ -12,6 +12,7 @@ extern "C" {
|
|||
bool JSB_localStorageGetItem(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool JSB_localStorageRemoveItem(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool JSB_localStorageSetItem(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool JSB_localStorageClear(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
JS_DefineFunction(_cx, system, "getItem", JSB_localStorageGetItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE );
|
||||
JS_DefineFunction(_cx, system, "removeItem", JSB_localStorageRemoveItem, 1, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE );
|
||||
JS_DefineFunction(_cx, system, "setItem", JSB_localStorageSetItem, 2, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE );
|
||||
JS_DefineFunction(_cx, system, "clear", JSB_localStorageClear, 0, JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_ENUMERATE );
|
||||
|
||||
|
||||
//#endif // JSB_INCLUDE_SYSTEM
|
||||
|
|
|
@ -69,7 +69,7 @@ jsval spbonedata_to_jsval(JSContext* cx, const spBoneData* v)
|
|||
|
||||
// root haven't parent
|
||||
JS::RootedValue parentVal(cx);
|
||||
if (strcmp(v->name, "root"))
|
||||
if (strcmp(v->name, "root") && v->parent)
|
||||
parentVal = spbonedata_to_jsval(cx, v->parent);
|
||||
|
||||
bool ok = JS_DefineProperty(cx, tmp, "name", JS::RootedValue(cx, c_string_to_jsval(cx, v->name)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
|
@ -98,7 +98,7 @@ jsval spbone_to_jsval(JSContext* cx, spBone& v)
|
|||
|
||||
// root haven't parent
|
||||
JS::RootedValue parentVal(cx);
|
||||
if (strcmp(v.data->name, "root"))
|
||||
if (strcmp(v.data->name, "root") && v.parent)
|
||||
parentVal = spbone_to_jsval(cx, *v.parent);
|
||||
|
||||
bool ok = JS_DefineProperty(cx, tmp, "data", JS::RootedValue(cx, spbonedata_to_jsval(cx, v.data)), JSPROP_ENUMERATE | JSPROP_PERMANENT) &&
|
||||
|
|
|
@ -150,7 +150,7 @@ cc.Scale9Sprite.prototype._ctor = function(file, rect, capInsets){
|
|||
this.initWithFile(file, rect, capInsets);
|
||||
}
|
||||
}else{
|
||||
this.init();
|
||||
cc.Node.prototype.init.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -246,8 +246,8 @@ 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_RIGHT = 1;
|
||||
cc.EventMouse.BUTTON_MIDDLE = 2;
|
||||
cc.EventMouse.BUTTON_4 = 3;
|
||||
cc.EventMouse.BUTTON_5 = 4;
|
||||
cc.EventMouse.BUTTON_6 = 5;
|
||||
|
|
|
@ -250,7 +250,6 @@ cc.defineGetterSetter(_proto, "texture", _proto.getTexture, _proto.setTexture);
|
|||
_proto = cc.Texture2D.prototype;
|
||||
cc.defineGetterSetter(_proto, "name", _proto.getName);
|
||||
cc.defineGetterSetter(_proto, "pixelFormat", _proto.getPixelFormat);
|
||||
cc.defineGetterSetter(_proto, "defaultPixelFormat", _proto.getDefaultAlphaPixelFormat, _proto.setDefaultAlphaPixelFormat);
|
||||
cc.defineGetterSetter(_proto, "pixelsWidth", _proto.getPixelsWide);
|
||||
cc.defineGetterSetter(_proto, "pixelsHeight", _proto.getPixelsHigh);
|
||||
cc.defineGetterSetter(_proto, "width", _proto._getWidth);
|
||||
|
@ -258,6 +257,7 @@ cc.defineGetterSetter(_proto, "height", _proto._getHeight);
|
|||
cc.defineGetterSetter(_proto, "shaderProgram", _proto.getShaderProgram, _proto.setShaderProgram);
|
||||
cc.defineGetterSetter(_proto, "maxS", _proto.getMaxS, _proto.setMaxS);
|
||||
cc.defineGetterSetter(_proto, "maxT", _proto.getMaxT, _proto.setMaxT);
|
||||
cc.defineGetterSetter(cc.Texture2D, "defaultPixelFormat", cc.Texture2D.getDefaultAlphaPixelFormat, cc.Texture2D.setDefaultAlphaPixelFormat);
|
||||
|
||||
_proto = cc.LabelAtlas.prototype;
|
||||
cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString);
|
||||
|
|
|
@ -1211,6 +1211,11 @@
|
|||
-- @field [parent=#cc] SpriteFrameCache#SpriteFrameCache SpriteFrameCache preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc ParallaxNode
|
||||
-- @field [parent=#cc] ParallaxNode#ParallaxNode ParallaxNode preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc TMXObjectGroup
|
||||
-- @field [parent=#cc] TMXObjectGroup#TMXObjectGroup TMXObjectGroup preloaded module
|
||||
|
@ -1241,11 +1246,6 @@
|
|||
-- @field [parent=#cc] TMXTiledMap#TMXTiledMap TMXTiledMap preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc ParallaxNode
|
||||
-- @field [parent=#cc] ParallaxNode#ParallaxNode ParallaxNode preloaded module
|
||||
|
||||
|
||||
--------------------------------------------------------
|
||||
-- the cc TileMapAtlas
|
||||
-- @field [parent=#cc] TileMapAtlas#TileMapAtlas TileMapAtlas preloaded module
|
||||
|
|
|
@ -1964,6 +1964,10 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -147,4 +147,16 @@ void localStorageRemoveItem( const std::string& key )
|
|||
|
||||
}
|
||||
|
||||
/** removes all items from the LS */
|
||||
void localStorageClear()
|
||||
{
|
||||
assert( _initialized );
|
||||
JniMethodInfo t;
|
||||
|
||||
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/Cocos2dxLocalStorage", "clear", "()V")) {
|
||||
t.env->CallStaticVoidMethod(t.classID, t.methodID);
|
||||
t.env->DeleteLocalRef(t.classID);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
|
|
|
@ -42,6 +42,7 @@ static sqlite3 *_db;
|
|||
static sqlite3_stmt *_stmt_select;
|
||||
static sqlite3_stmt *_stmt_remove;
|
||||
static sqlite3_stmt *_stmt_update;
|
||||
static sqlite3_stmt *_stmt_clear;
|
||||
|
||||
|
||||
static void localStorageCreateTable()
|
||||
|
@ -81,6 +82,10 @@ void localStorageInit( const std::string& fullpath/* = "" */)
|
|||
const char *sql_remove = "DELETE FROM data WHERE key=?;";
|
||||
ret |= sqlite3_prepare_v2(_db, sql_remove, -1, &_stmt_remove, nullptr);
|
||||
|
||||
// Clear
|
||||
const char *sql_clear = "DELETE FROM data;";
|
||||
ret |= sqlite3_prepare_v2(_db, sql_clear, -1, &_stmt_clear, nullptr);
|
||||
|
||||
if( ret != SQLITE_OK ) {
|
||||
printf("Error initializing DB\n");
|
||||
// report error
|
||||
|
@ -130,10 +135,14 @@ bool localStorageGetItem( const std::string& key, std::string *outItem )
|
|||
ok |= sqlite3_step(_stmt_select);
|
||||
const unsigned char *text = sqlite3_column_text(_stmt_select, 0);
|
||||
|
||||
if( (ok != SQLITE_OK && ok != SQLITE_DONE && ok != SQLITE_ROW) || !text)
|
||||
if ( ok != SQLITE_OK && ok != SQLITE_DONE && ok != SQLITE_ROW )
|
||||
{
|
||||
printf("Error in localStorage.getItem()\n");
|
||||
return false;
|
||||
}
|
||||
else if (!text)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -157,4 +166,15 @@ void localStorageRemoveItem( const std::string& key )
|
|||
printf("Error in localStorage.removeItem()\n");
|
||||
}
|
||||
|
||||
/** removes all items from the LS */
|
||||
void localStorageClear()
|
||||
{
|
||||
assert( _initialized );
|
||||
|
||||
int ok = sqlite3_step(_stmt_clear);
|
||||
|
||||
if( ok != SQLITE_OK && ok != SQLITE_DONE)
|
||||
printf("Error in localStorage.clear()\n");
|
||||
}
|
||||
|
||||
#endif // #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
|
||||
|
|
|
@ -51,6 +51,9 @@ bool CC_DLL localStorageGetItem( const std::string& key, std::string *outItem );
|
|||
/** Removes an item from the JS. */
|
||||
void CC_DLL localStorageRemoveItem( const std::string& key );
|
||||
|
||||
/** Removes all items from the JS. */
|
||||
void CC_DLL localStorageClear();
|
||||
|
||||
// end group
|
||||
/// @}
|
||||
|
||||
|
|
|
@ -4925,6 +4925,94 @@
|
|||
"tools/gen-prebuilt/module_organize.py",
|
||||
"tools/missing-tools.txt",
|
||||
"tools/particle/convert_YCoordFlipped.py",
|
||||
"tools/simulator/.cocos-project.json",
|
||||
"tools/simulator/.project",
|
||||
"tools/simulator/config.json",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/AppDelegate.h",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/CodeIDESupport.h",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeJsImpl.h",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/RuntimeLuaImpl.h",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/lang",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/lua_debugger.c",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/ide-support/lua_debugger.h",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/js_module_register.h",
|
||||
"tools/simulator/frameworks/runtime-src/Classes/lua_module_register.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/.classpath",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/.project",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/.settings/org.eclipse.jdt.core.prefs",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/AndroidManifest.xml",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/ant.properties",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/build-cfg.json",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/build.xml",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/jni/Android.mk",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/jni/Application.mk",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/jni/hellolua/main.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/proguard-project.txt",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/project.properties",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/res/drawable-hdpi/icon.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/res/drawable-ldpi/icon.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/res/drawable-mdpi/icon.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/res/values/strings.xml",
|
||||
"tools/simulator/frameworks/runtime-src/proj.android/src/org/cocos2dx/lua/AppActivity.java",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/AppController.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/AppController.mm",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Default-568h@2x.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Default-667h@2x.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Default-736h@3x.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Default.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Default@2x.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-100.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-114.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-120.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-144.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-152.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-29.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-40.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-50.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-57.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-58.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-72.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-76.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Icon-80.png",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Info.plist",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/Prefix.pch",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/build-cfg.json",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/ios/main.m",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Base.lproj/ConsoleWindow.xib",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Base.lproj/MainMenu.xib",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/ConsoleWindowController.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/ConsoleWindowController.m",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Icon.icns",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Info.plist",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/Prefix.pch",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/build-cfg.json",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/en.lproj/MainMenu.xib",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/main.m",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/zh-Hans.lproj/ConsoleWindow.strings",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/mac/zh-Hans.lproj/MainMenu.xib",
|
||||
"tools/simulator/frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj/project.pbxproj",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/SimulatorWin.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/build-cfg.json",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/game.rc",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/main.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/main.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/res/game.ico",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/resource.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/simulator.sln",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj.filters",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/simulator.vcxproj.user",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/stdafx.cpp",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/stdafx.h",
|
||||
"tools/simulator/frameworks/runtime-src/proj.win32/targetver.h",
|
||||
"tools/simulator/libsimulator/lib/AppEvent.cpp",
|
||||
"tools/simulator/libsimulator/lib/AppEvent.h",
|
||||
"tools/simulator/libsimulator/lib/AppLang.cpp",
|
||||
|
|
|
@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\cocos2d
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d", "..\..\cocos2d-x\cocos\scripting\js-bindings\proj.win32\libjscocos2d.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet", "..\..\cocos2d-x\external\bullet\proj.win32\libbullet.vcxproj", "{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -43,6 +45,10 @@ Global
|
|||
{39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32
|
||||
{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -50,5 +56,6 @@ Global
|
|||
GlobalSection(NestedProjects) = preSolution
|
||||
{B7C2A162-DEC9-4418-972E-240AB3CBFCAE} = {8C6B0381-B325-4D7F-B1BB-474ABACE46AC}
|
||||
{929480E7-23C0-4DF6-8456-096D71547116} = {8C6B0381-B325-4D7F-B1BB-474ABACE46AC}
|
||||
{012DFF48-A13F-4F52-B07B-F8B9D21CE95B} = {8C6B0381-B325-4D7F-B1BB-474ABACE46AC}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -6,7 +6,13 @@
|
|||
"Portrait": "竖屏",
|
||||
"Landscape": "横屏",
|
||||
"Refresh": "刷新(重启)",
|
||||
"Zoom Out": "缩放"
|
||||
"Zoom Out": "缩放",
|
||||
"Simulator": "模拟器",
|
||||
"Open File": "打开文件",
|
||||
"Open Project": "打开工程",
|
||||
"Error": "错误",
|
||||
"Help": "帮助(&H)",
|
||||
"About": "关于(&A)"
|
||||
},
|
||||
"zh-Hans": {
|
||||
"View": "视图",
|
||||
|
@ -15,6 +21,9 @@
|
|||
"Portrait": "竖屏",
|
||||
"Landscape": "横屏",
|
||||
"Refresh": "刷新(重启)",
|
||||
"Zoom Out": "缩放"
|
||||
"Zoom Out": "缩放",
|
||||
"Simulator": "模拟器",
|
||||
"Help": "帮助(&H)",
|
||||
"About": "关于(&A)"
|
||||
}
|
||||
}
|
|
@ -18,6 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\..\cocos2d-x
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsimulator", "..\..\cocos2d-x\tools\simulator\libsimulator\proj.win32\libsimulator.vcxproj", "{001B324A-BB91-4E83-875C-C92F75C40857}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbullet", "..\..\cocos2d-x\external\bullet\proj.win32\libbullet.vcxproj", "{012DFF48-A13F-4F52-B07B-F8B9D21CE95B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
|
|
@ -31,6 +31,14 @@
|
|||
#include "platform/win32/PlayerWin.h"
|
||||
#include "platform/win32/PlayerMenuServiceWin.h"
|
||||
|
||||
// define 1 to open console ui and setup windows system menu, 0 to disable
|
||||
#include "ide-support/CodeIDESupport.h"
|
||||
#if (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
#define SIMULATOR_WITH_CONSOLE_AND_MENU 1
|
||||
#else
|
||||
#define SIMULATOR_WITH_CONSOLE_AND_MENU 0
|
||||
#endif
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
static WNDPROC g_oldWindowProc = NULL;
|
||||
|
@ -243,6 +251,7 @@ int SimulatorWin::run()
|
|||
_app = new AppDelegate();
|
||||
RuntimeEngine::getInstance()->setProjectConfig(_project);
|
||||
|
||||
#if (SIMULATOR_WITH_CONSOLE_AND_MENU > 0)
|
||||
// create console window
|
||||
if (_project.isShowConsole())
|
||||
{
|
||||
|
@ -262,6 +271,7 @@ int SimulatorWin::run()
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// log file
|
||||
if (_project.isWriteDebugLogToFile())
|
||||
|
@ -356,9 +366,11 @@ int SimulatorWin::run()
|
|||
// path for looking Lang file, Studio Default images
|
||||
FileUtils::getInstance()->addSearchPath(getApplicationPath().c_str());
|
||||
|
||||
#if SIMULATOR_WITH_CONSOLE_AND_MENU > 0
|
||||
// init player services
|
||||
setupUI();
|
||||
DrawMenuBar(_hwnd);
|
||||
#endif
|
||||
|
||||
// prepare
|
||||
FileUtils::getInstance()->setPopupNotify(false);
|
||||
|
@ -367,11 +379,6 @@ int SimulatorWin::run()
|
|||
|
||||
g_oldWindowProc = (WNDPROC)SetWindowLong(_hwnd, GWL_WNDPROC, (LONG)SimulatorWin::windowProc);
|
||||
|
||||
// update window size
|
||||
RECT rect;
|
||||
GetWindowRect(_hwnd, &rect);
|
||||
MoveWindow(_hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top + GetSystemMetrics(SM_CYMENU), FALSE);
|
||||
|
||||
// startup message loop
|
||||
return app->run();
|
||||
}
|
||||
|
@ -442,6 +449,10 @@ void SimulatorWin::setupUI()
|
|||
scaleMenuVector.push_back(scale50Menu);
|
||||
scaleMenuVector.push_back(scale25Menu);
|
||||
|
||||
// About
|
||||
menuBar->addItem("HELP_MENU", tr("Help"));
|
||||
menuBar->addItem("ABOUT_MENUITEM", tr("About"), "HELP_MENU");
|
||||
|
||||
menuBar->addItem("REFRESH_MENU_SEP", "-", "VIEW_MENU");
|
||||
menuBar->addItem("REFRESH_MENU", tr("Refresh"), "VIEW_MENU");
|
||||
|
||||
|
@ -527,6 +538,11 @@ void SimulatorWin::setupUI()
|
|||
project.changeFrameOrientationToLandscape();
|
||||
_instance->openProjectWithProjectConfig(project);
|
||||
}
|
||||
else if (data == "ABOUT_MENUITEM")
|
||||
{
|
||||
onHelpAbout();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -725,6 +741,7 @@ LRESULT CALLBACK SimulatorWin::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
|
|||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_SYSCOMMAND:
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if (HIWORD(wParam) == 0)
|
||||
|
@ -754,10 +771,12 @@ LRESULT CALLBACK SimulatorWin::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
|
|||
}
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
#if (SIMULATOR_WITH_CONSOLE_AND_MENU > 0)
|
||||
if (wParam == VK_F5)
|
||||
{
|
||||
_instance->relaunch();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
// Used by game.rc
|
||||
//
|
||||
#define IDS_PROJNAME 100
|
||||
#define IDR_TESTLUA 100
|
||||
#define IDR_MENU_COCOS 201
|
||||
#define IDR_MENU_COCOS 200
|
||||
#define IDD_DIALOG1 202
|
||||
#define IDD_DIALOG_ABOUT 202
|
||||
#define IDD_DIALOG_ABOUT 203
|
||||
#define IDC_EDIT2 1001
|
||||
#define ID_VIEW_SIZE 30001
|
||||
#define ID_FILE_NEW_WINDOW 32771
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "MaterialSystemTest.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "../testResource.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
|
@ -42,6 +45,7 @@ MaterialSystemTest::MaterialSystemTest()
|
|||
ADD_TEST_CASE(Material_clone);
|
||||
ADD_TEST_CASE(Material_MultipleSprite3D);
|
||||
ADD_TEST_CASE(Material_Sprite3DTest);
|
||||
ADD_TEST_CASE(Material_parsePerformance);
|
||||
}
|
||||
|
||||
std::string MaterialSystemBaseTest::title() const
|
||||
|
@ -107,7 +111,7 @@ void Material_2DEffects::onEnter()
|
|||
{
|
||||
MaterialSystemBaseTest::onEnter();
|
||||
|
||||
auto properties = Properties::create("Materials/2d_effects.material#sample");
|
||||
auto properties = Properties::createWithoutAutorelease("Materials/2d_effects.material#sample");
|
||||
|
||||
// Print the properties of every namespace within this one.
|
||||
printProperties(properties, 0);
|
||||
|
@ -133,6 +137,9 @@ void Material_2DEffects::onEnter()
|
|||
spriteEdgeDetect->setNormalizedPosition(Vec2(0.8, 0.5));
|
||||
this->addChild(spriteEdgeDetect);
|
||||
spriteEdgeDetect->setGLProgramState(mat1->getTechniqueByName("edge_detect")->getPassByIndex(0)->getGLProgramState());
|
||||
|
||||
// properties is not a "Ref" object
|
||||
CC_SAFE_DELETE(properties);
|
||||
}
|
||||
|
||||
std::string Material_2DEffects::subtitle() const
|
||||
|
@ -250,6 +257,32 @@ std::string Material_clone::subtitle() const
|
|||
return "Testing material->clone()";
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
void Material_parsePerformance::onEnter()
|
||||
{
|
||||
MaterialSystemBaseTest::onEnter();
|
||||
|
||||
std::clock_t begin = std::clock();
|
||||
|
||||
for(int i=0;i<5000;i++)
|
||||
{
|
||||
Material::createWithFilename("Materials/2d_effects.material");
|
||||
Material::createWithFilename("Materials/3d_effects.material");
|
||||
}
|
||||
|
||||
std::clock_t end = std::clock();
|
||||
double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
|
||||
|
||||
log("Parsing took: %f", elapsed_secs);
|
||||
}
|
||||
|
||||
std::string Material_parsePerformance::subtitle() const
|
||||
{
|
||||
return "Testing parsing performance";
|
||||
}
|
||||
|
||||
// MARK: Helper functions
|
||||
|
||||
static void printProperties(Properties* properties, int indent)
|
||||
|
@ -263,7 +296,7 @@ static void printProperties(Properties* properties, int indent)
|
|||
chindent[i] = ' ';
|
||||
chindent[i] = '\0';
|
||||
|
||||
CCLOG("%sNamespace: %s ID: %s\n%s{", chindent, spacename, id, chindent);
|
||||
log("%sNamespace: %s ID: %s\n%s{", chindent, spacename, id, chindent);
|
||||
|
||||
// Print all properties in this namespace.
|
||||
const char* name = properties->getNextProperty();
|
||||
|
@ -271,7 +304,7 @@ static void printProperties(Properties* properties, int indent)
|
|||
while (name != NULL)
|
||||
{
|
||||
value = properties->getString(name);
|
||||
CCLOG("%s%s = %s", chindent, name, value);
|
||||
log("%s%s = %s", chindent, name, value);
|
||||
name = properties->getNextProperty();
|
||||
}
|
||||
|
||||
|
@ -282,5 +315,5 @@ static void printProperties(Properties* properties, int indent)
|
|||
space = properties->getNextNamespace();
|
||||
}
|
||||
|
||||
CCLOG("%s}\n",chindent);
|
||||
log("%s}\n",chindent);
|
||||
}
|
||||
|
|
|
@ -86,4 +86,13 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class Material_parsePerformance : public MaterialSystemBaseTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(Material_parsePerformance);
|
||||
|
||||
virtual void onEnter() override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -626,20 +626,7 @@ bool Physics3DTerrainDemo::init()
|
|||
}
|
||||
|
||||
//create mesh
|
||||
std::vector<Vec3> trianglesList;
|
||||
auto bundle = Bundle3D::createBundle();
|
||||
bundle->load("Sprite3DTest/boss.c3b");
|
||||
MeshDatas meshs;
|
||||
bundle->loadMeshDatas(meshs);
|
||||
Bundle3D::destroyBundle(bundle);
|
||||
for (auto iter : meshs.meshDatas){
|
||||
int preVertexSize = iter->getPerVertexSize() / sizeof(float);
|
||||
for (auto indexArray : iter->subMeshIndices){
|
||||
for (auto i : indexArray){
|
||||
trianglesList.push_back(Vec3(iter->vertex[i * preVertexSize], iter->vertex[i * preVertexSize + 1], iter->vertex[i * preVertexSize + 2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<Vec3> trianglesList = Bundle3D::getTrianglesList("Sprite3DTest/boss.c3b");
|
||||
|
||||
rbDes.mass = 0.0f;
|
||||
rbDes.shape = Physics3DShape::createMesh(&trianglesList[0], (int)trianglesList.size() / 3);
|
||||
|
@ -707,19 +694,9 @@ bool Physics3DCollisionCallbackDemo::init()
|
|||
Physics3DRigidBodyDes rbDes;
|
||||
|
||||
float scale = 2.0f;
|
||||
std::vector<Vec3> trianglesList;
|
||||
auto bundle = Bundle3D::createBundle();
|
||||
bundle->load("Sprite3DTest/boss.c3b");
|
||||
MeshDatas meshs;
|
||||
bundle->loadMeshDatas(meshs);
|
||||
Bundle3D::destroyBundle(bundle);
|
||||
for (auto iter : meshs.meshDatas){
|
||||
int preVertexSize = iter->getPerVertexSize() / sizeof(float);
|
||||
for (auto indexArray : iter->subMeshIndices){
|
||||
for (auto i : indexArray){
|
||||
trianglesList.push_back(Vec3(iter->vertex[i * preVertexSize], iter->vertex[i * preVertexSize + 1], iter->vertex[i * preVertexSize + 2]) * scale);
|
||||
}
|
||||
}
|
||||
std::vector<Vec3> trianglesList = Bundle3D::getTrianglesList("Sprite3DTest/boss.c3b");
|
||||
for (auto& it : trianglesList) {
|
||||
it *= scale;
|
||||
}
|
||||
|
||||
rbDes.mass = 0.0f;
|
||||
|
|
|
@ -41,7 +41,7 @@ bool UIButtonTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIButton/crossplatform_UIButton_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIButton/res.csb");
|
||||
Node* child = node->getChildByTag(4);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -36,7 +36,7 @@ bool UICheckBoxTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UICheckBox/crossplatform_UICheckBox_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UICheckBox/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -13,7 +13,7 @@ bool UIImageViewTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIImageView/crossplatform_UIImageView_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIImageView/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -34,7 +34,7 @@ bool UILayoutTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Layout/crossplatform_UILayout_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Layout/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -65,7 +65,7 @@ bool UILayoutTest_Color_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Color/crossplatform_UILayout_Color_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Color/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -96,7 +96,7 @@ bool UILayoutTest_Gradient_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Gradient_Color/crossplatform_Gradient_Color.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Gradient_Color/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -127,7 +127,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/BackgroundImage/crossplatform_BackgroundImage.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/BackgroundImage/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -158,7 +158,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/crossplatform_Scale9_BackgroundImage.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -196,7 +196,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/windows_ui_linear_vertical_layout.json"));
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Vertical_Layout/res.json"));
|
||||
|
||||
_touchGroup->addChild(_layout);
|
||||
|
||||
|
@ -225,7 +225,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/windows_ui_linear_horizontal_layout.json"));
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Linear_Horizontal_Layout/res.json"));
|
||||
_touchGroup->addChild(_layout);
|
||||
|
||||
this->configureGUIScene();
|
||||
|
@ -253,7 +253,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/windows_ui_relative_align_parent.json"));
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Parent/res.json"));
|
||||
_touchGroup->addChild(_layout);
|
||||
this->configureGUIScene();
|
||||
|
||||
|
@ -280,7 +280,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Location/windows_ui_relative_align_location.json"));
|
||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout/Relative_Align_Location/res.json"));
|
||||
_touchGroup->addChild(_layout);
|
||||
this->configureGUIScene();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ bool UIListViewTest_Vertical_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIListView/New/crossplatform_UIListView_Editor_Vertical.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIListView/New/resV.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = dynamic_cast<Layout*>(child);
|
||||
|
@ -117,7 +117,7 @@ bool UIListViewTest_Horizontal_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIListView/New/crossplatform_UIListView_Editor_Horizontal.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIListView/New/resH.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = dynamic_cast<Layout*>(child);
|
||||
|
|
|
@ -39,7 +39,7 @@ bool UILoadingBarTest_Editor::init()
|
|||
{
|
||||
scheduleUpdate();
|
||||
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILoadingBar/crossplatform_UILoadingBar_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILoadingBar/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -26,7 +26,7 @@ bool UIPageViewTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIPageView/crossplatform_UIPageView_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIPageView/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -29,7 +29,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Vertical/crossplatform_UIScrollView_Vertical_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Vertical/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -60,7 +60,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Horizontal/crossplatform_UIScrollView_Horizontal_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Horizontal/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
@ -91,7 +91,7 @@ bool UIScrollViewTest_Both_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Both/crossplatform_UIScrollView_Both_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIScrollView/Both/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -35,7 +35,7 @@ bool UISliderTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UISlider/crossplatform_UISlider_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UISlider/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -12,7 +12,7 @@ bool UITextAtlasTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILabelAtlas/crossplatform_UILabelAtlas_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILabelAtlas/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -14,7 +14,7 @@ bool UITextBMFontTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILabelBMFont/crossplatform_UILabelBMFont_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILabelBMFont/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -37,7 +37,7 @@ bool UITextFieldTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UITextField/crossplatform_UITextField_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UITextField/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -14,7 +14,7 @@ bool UITextTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILabel/crossplatform_UILabel_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UILabel/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -41,7 +41,7 @@ bool UIWidgetAddNodeTest_Editor::init()
|
|||
{
|
||||
if (UIScene_Editor::init())
|
||||
{
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIWidgetAddNode/crossplatform_UIWidgetAddNode_Editor_1.csb");
|
||||
Node* node = CSLoader::createNode("cocosui/UIEditorTest/UIWidgetAddNode/res.csb");
|
||||
Node* child = node->getChildByTag(5);
|
||||
child->removeFromParent();
|
||||
_layout = static_cast<Layout*>(child);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit afa5ba56b3745b0fb94e730ea54a79e598c31ba8
|
||||
Subproject commit 0f5e0dff1a7545eef7bbe8f23d4b232d0d2d6ae3
|
|
@ -77,19 +77,37 @@ var LocalStorageTest = SysTestBase.extend({
|
|||
|
||||
var key = 'key_' + Math.random();
|
||||
var ls = cc.sys.localStorage;
|
||||
cc.log(1);
|
||||
cc.log("- Adding items");
|
||||
ls.setItem(key, "Hello world");
|
||||
var key1 = "1" + key;
|
||||
ls.setItem(key1, "Hello JavaScript");
|
||||
var key2 = "2" + key;
|
||||
ls.setItem(key2, "Hello Cocos2d-JS");
|
||||
var key3 = "3" + key;
|
||||
ls.setItem(key3, "Hello Cocos");
|
||||
|
||||
cc.log(2);
|
||||
cc.log("- Getting Hello world");
|
||||
var r = ls.getItem(key);
|
||||
cc.log(r);
|
||||
|
||||
cc.log(3);
|
||||
cc.log("- Removing Hello world");
|
||||
ls.removeItem(key);
|
||||
|
||||
cc.log(4);
|
||||
cc.log("- Getting Hello world");
|
||||
r = ls.getItem(key);
|
||||
cc.log(r);
|
||||
|
||||
cc.log("- Getting other items");
|
||||
cc.log( ls.getItem(key1) );
|
||||
cc.log( ls.getItem(key2) );
|
||||
cc.log( ls.getItem(key3) );
|
||||
|
||||
cc.log("- Clearing local storage");
|
||||
ls.clear();
|
||||
cc.log("- Getting other items");
|
||||
cc.log( ls.getItem(key1) );
|
||||
cc.log( ls.getItem(key2) );
|
||||
cc.log( ls.getItem(key3) );
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ec36c46e0a7e82d8e6c441d478f01dcd46377fbb
|
||||
Subproject commit 339f75bb11a34e5d7c7a81ef293fd2918cb44b3f
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"has_native": true,
|
||||
"project_type": "lua"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Simulator</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.ccdt.cocosproject</nature>
|
||||
<nature>org.eclipse.koneki.ldt.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"init_cfg":{
|
||||
"isLandscape": true,
|
||||
"isWindowTop": false,
|
||||
"name": "simulator",
|
||||
"width": 960,
|
||||
"height": 640,
|
||||
"entry": "",
|
||||
"consolePort": 6050,
|
||||
"uploadPort": 6060
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
#include "AppDelegate.h"
|
||||
#include "CCLuaEngine.h"
|
||||
#include "SimpleAudioEngine.h"
|
||||
#include "cocos2d.h"
|
||||
#include "ide-support/CodeIDESupport.h"
|
||||
|
||||
#include "runtime/Runtime.h"
|
||||
|
||||
// Lua
|
||||
#include "ide-support/RuntimeLuaImpl.h"
|
||||
|
||||
// Js
|
||||
#include "ide-support/RuntimeJsImpl.h"
|
||||
|
||||
|
||||
using namespace CocosDenshion;
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace std;
|
||||
|
||||
AppDelegate::AppDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
AppDelegate::~AppDelegate()
|
||||
{
|
||||
SimpleAudioEngine::end();
|
||||
|
||||
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
|
||||
RuntimeEngine::getInstance()->end();
|
||||
}
|
||||
|
||||
//if you want a different context,just modify the value of glContextAttrs
|
||||
//it will takes effect on all platforms
|
||||
void AppDelegate::initGLContextAttrs()
|
||||
{
|
||||
//set OpenGL context attributions,now can only set six attributions:
|
||||
//red,green,blue,alpha,depth,stencil
|
||||
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
|
||||
|
||||
GLView::setGLContextAttrs(glContextAttrs);
|
||||
}
|
||||
|
||||
bool AppDelegate::applicationDidFinishLaunching()
|
||||
{
|
||||
// set default FPS
|
||||
Director::getInstance()->setAnimationInterval(1.0 / 60.0f);
|
||||
|
||||
auto runtimeEngine = RuntimeEngine::getInstance();
|
||||
runtimeEngine->setEventTrackingEnable(true);
|
||||
runtimeEngine->addRuntime(RuntimeLuaImpl::create(), kRuntimeEngineLua);
|
||||
auto jsRuntime = RuntimeJsImpl::create();
|
||||
runtimeEngine->addRuntime(jsRuntime, kRuntimeEngineJs);
|
||||
runtimeEngine->start();
|
||||
|
||||
// js need special debug port
|
||||
if (runtimeEngine->getProjectConfig().getDebuggerType() != kCCRuntimeDebuggerNone)
|
||||
{
|
||||
jsRuntime->startWithDebugger();
|
||||
}
|
||||
|
||||
|
||||
// Runtime end
|
||||
cocos2d::log("iShow!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
Director::getInstance()->stopAnimation();
|
||||
|
||||
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
||||
}
|
||||
|
||||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
Director::getInstance()->startAnimation();
|
||||
|
||||
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef __APP_DELEGATE_H__
|
||||
#define __APP_DELEGATE_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
||||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
||||
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||
*/
|
||||
class AppDelegate : private cocos2d::Application
|
||||
{
|
||||
public:
|
||||
AppDelegate();
|
||||
virtual ~AppDelegate();
|
||||
|
||||
virtual void initGLContextAttrs();
|
||||
|
||||
/**
|
||||
@brief Implement Director and Scene init code here.
|
||||
@return true Initialize success, app continue.
|
||||
@return false Initialize failed, app terminate.
|
||||
*/
|
||||
virtual bool applicationDidFinishLaunching();
|
||||
|
||||
/**
|
||||
@brief The function be called when the application enter background
|
||||
@param the pointer of the application
|
||||
*/
|
||||
virtual void applicationDidEnterBackground();
|
||||
|
||||
/**
|
||||
@brief The function be called when the application enter foreground
|
||||
@param the pointer of the application
|
||||
*/
|
||||
virtual void applicationWillEnterForeground();
|
||||
};
|
||||
|
||||
#endif // __APP_DELEGATE_H__
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef __CODE_IDE_SUPPORT_H__
|
||||
#define __CODE_IDE_SUPPORT_H__
|
||||
|
||||
// define 1 to open Cocos Code IDE support, 0 to disable
|
||||
#define CC_CODE_IDE_DEBUG_SUPPORT 1
|
||||
|
||||
#endif /* __CODE_IDE_SUPPORT_H__ */
|
|
@ -0,0 +1,299 @@
|
|||
//
|
||||
// RuntimeJsImpl.cpp
|
||||
// Simulator
|
||||
//
|
||||
//
|
||||
|
||||
#include "RuntimeJsImpl.h"
|
||||
|
||||
#include "cocos2d.h" // 2dx engine
|
||||
|
||||
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
|
||||
#include "runtime/ConfigParser.h" // config
|
||||
#include "runtime/Runtime.h"
|
||||
#include "runtime/FileServer.h"
|
||||
|
||||
// js
|
||||
#include "js_module_register.h"
|
||||
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
static const char *RUNTIME_JS_BOOT_SCRIPT = "script/jsb_boot.js";
|
||||
|
||||
static bool reloadScript(const string& file)
|
||||
{
|
||||
auto director = Director::getInstance();
|
||||
FontFNT::purgeCachedData();
|
||||
if (director->getOpenGLView())
|
||||
{
|
||||
SpriteFrameCache::getInstance()->removeSpriteFrames();
|
||||
director->getTextureCache()->removeAllTextures();
|
||||
}
|
||||
FileUtils::getInstance()->purgeCachedEntries();
|
||||
|
||||
//director->getScheduler()->unscheduleAll();
|
||||
//director->getScheduler()->scheduleUpdate(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false);
|
||||
|
||||
string modulefile = file;
|
||||
if (modulefile.empty())
|
||||
{
|
||||
modulefile = ConfigParser::getInstance()->getEntryFile().c_str();
|
||||
}
|
||||
|
||||
return ScriptingCore::getInstance()->runScript(modulefile.c_str());
|
||||
}
|
||||
|
||||
bool runtime_FileUtils_addSearchPath(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "cocos2dx_FileUtils_addSearchPath : Invalid Native Object");
|
||||
if (argc == 1 || argc == 2) {
|
||||
std::string arg0;
|
||||
bool arg1 = false;
|
||||
|
||||
ok &= jsval_to_std_string(cx, args.get(0), &arg0);
|
||||
JSB_PRECONDITION2(ok, cx, false, "cocos2dx_FileUtils_addSearchPath : Error processing arguments");
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
arg1 = JS::ToBoolean(JS::RootedValue(cx, args.get(1)));
|
||||
}
|
||||
|
||||
if (! FileUtils::getInstance()->isAbsolutePath(arg0))
|
||||
{
|
||||
// add write path to search path
|
||||
if (FileServer::getShareInstance()->getIsUsingWritePath())
|
||||
{
|
||||
cobj->addSearchPath(FileServer::getShareInstance()->getWritePath() + arg0, arg1);
|
||||
} else
|
||||
{
|
||||
cobj->addSearchPath(arg0, arg1);
|
||||
}
|
||||
|
||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
// add project path to search path
|
||||
cobj->addSearchPath(RuntimeEngine::getInstance()->getRuntime()->getProjectPath() + arg0, arg1);
|
||||
#endif
|
||||
}
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "cocos2dx_FileUtils_addSearchPath : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool runtime_FileUtils_setSearchPaths(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
bool ok = true;
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::FileUtils* cobj = (cocos2d::FileUtils *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Invalid Native Object");
|
||||
if (argc == 1) {
|
||||
std::vector<std::string> vecPaths, writePaths;
|
||||
ok &= jsval_to_std_vector_string(cx, args.get(0), &vecPaths);
|
||||
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_FileUtils_setSearchPaths : Error processing arguments");
|
||||
|
||||
std::vector<std::string> originPath; // for IOS platform.
|
||||
std::vector<std::string> projPath; // for Desktop platform.
|
||||
for (int i = 0; i < vecPaths.size(); i++)
|
||||
{
|
||||
if (!FileUtils::getInstance()->isAbsolutePath(vecPaths[i]))
|
||||
{
|
||||
originPath.push_back(vecPaths[i]); // for IOS platform.
|
||||
projPath.push_back(RuntimeEngine::getInstance()->getRuntime()->getProjectPath()+vecPaths[i]); //for Desktop platform.
|
||||
writePaths.push_back(FileServer::getShareInstance()->getWritePath() + vecPaths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
vecPaths.insert(vecPaths.end(), projPath.begin(), projPath.end());
|
||||
#endif
|
||||
if (FileServer::getShareInstance()->getIsUsingWritePath())
|
||||
{
|
||||
vecPaths.insert(vecPaths.end(), writePaths.begin(), writePaths.end());
|
||||
} else
|
||||
{
|
||||
vecPaths.insert(vecPaths.end(), originPath.begin(), originPath.end());
|
||||
}
|
||||
|
||||
cobj->setSearchPaths(vecPaths);
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_FileUtils_setSearchPaths : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
void register_FileUtils(JSContext *cx, JS::HandleObject global)
|
||||
{
|
||||
JS::RootedValue nsval(cx);
|
||||
JS::RootedObject ns(cx);
|
||||
JS_GetProperty(cx, global, "cc", &nsval);
|
||||
if (nsval == JSVAL_VOID) {
|
||||
return;
|
||||
} else {
|
||||
ns.set(nsval.toObjectOrNull());
|
||||
}
|
||||
|
||||
JS::RootedObject proto(cx, jsb_cocos2d_FileUtils_prototype);
|
||||
JS_DefineFunction(cx, proto, "addSearchPath", runtime_FileUtils_addSearchPath, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
||||
JS_DefineFunction(cx, proto, "setSearchPaths", runtime_FileUtils_setSearchPaths, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
RuntimeJsImpl* RuntimeJsImpl::create()
|
||||
{
|
||||
RuntimeJsImpl *instance = new RuntimeJsImpl();
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool RuntimeJsImpl::initJsEnv()
|
||||
{
|
||||
if (_hasStarted)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
js_module_register();
|
||||
ScriptingCore::getInstance()->addRegisterCallback(register_FileUtils);
|
||||
ScriptingCore::getInstance()->start();
|
||||
_hasStarted = true;
|
||||
|
||||
ScriptEngineProtocol *engine = ScriptingCore::getInstance();
|
||||
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RuntimeJsImpl::startWithDebugger()
|
||||
{
|
||||
initJsEnv();
|
||||
|
||||
int debugPort = 5086;
|
||||
#if(CC_PLATFORM_MAC == CC_TARGET_PLATFORM || CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM)
|
||||
debugPort = ConfigParser::getInstance()->getDebugPort();
|
||||
#endif
|
||||
ScriptingCore::getInstance()->enableDebugger(debugPort);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::startScript(const std::string& path)
|
||||
{
|
||||
loadScriptFile(path);
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse)
|
||||
{
|
||||
if (loadScriptFile(ConfigParser::getInstance()->getEntryFile()))
|
||||
{
|
||||
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());
|
||||
}
|
||||
else
|
||||
{
|
||||
dReplyParse.AddMember("code",1,dReplyParse.GetAllocator());
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::onClearCompile(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse)
|
||||
{
|
||||
if (dArgParse.HasMember("modulefiles") && dArgParse["modulefiles"].Size() != 0)
|
||||
{
|
||||
const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
|
||||
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++)
|
||||
{
|
||||
ScriptingCore::getInstance()->cleanScript(objectfiles[i].GetString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unordered_map<std::string, JSScript*> filenameScript = ScriptingCore::getInstance()->getFileScript();
|
||||
filenameScript.clear();
|
||||
}
|
||||
|
||||
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::onPrecompile(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse)
|
||||
{
|
||||
const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
|
||||
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++)
|
||||
{
|
||||
ScriptingCore::getInstance()->compileScript(objectfiles[i].GetString());
|
||||
}
|
||||
|
||||
dReplyParse.AddMember("code",0,dReplyParse.GetAllocator());
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::onReload(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse)
|
||||
{
|
||||
if (dArgParse.HasMember("modulefiles")){
|
||||
rapidjson::Value bodyvalue(rapidjson::kObjectType);
|
||||
const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
|
||||
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++){
|
||||
if (!reloadScript(objectfiles[i].GetString())) {
|
||||
bodyvalue.AddMember(objectfiles[i].GetString(),1,dReplyParse.GetAllocator());
|
||||
}
|
||||
}
|
||||
if (0 == objectfiles.Size())
|
||||
{
|
||||
reloadScript("");
|
||||
}
|
||||
dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator());
|
||||
}else
|
||||
{
|
||||
reloadScript("");
|
||||
}
|
||||
|
||||
dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator());
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::onRemove(const std::string &filename)
|
||||
{
|
||||
ScriptingCore::getInstance()->cleanScript(filename.c_str());
|
||||
}
|
||||
|
||||
void RuntimeJsImpl::end()
|
||||
{
|
||||
ScriptEngineManager::destroyInstance();
|
||||
RuntimeProtocol::end();
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
RuntimeJsImpl::RuntimeJsImpl()
|
||||
: _hasStarted(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool RuntimeJsImpl::loadScriptFile(const std::string& path)
|
||||
{
|
||||
std::string filepath = path;
|
||||
if (filepath.empty())
|
||||
{
|
||||
filepath = ConfigParser::getInstance()->getEntryFile();
|
||||
}
|
||||
CCLOG("------------------------------------------------");
|
||||
CCLOG("LOAD Js FILE: %s", filepath.c_str());
|
||||
CCLOG("------------------------------------------------");
|
||||
|
||||
initJsEnv();
|
||||
auto engine = ScriptingCore::getInstance();
|
||||
engine->runScript(RUNTIME_JS_BOOT_SCRIPT);
|
||||
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
||||
return ScriptingCore::getInstance()->runScript(filepath.c_str());
|
||||
}
|
||||
|
||||
|
||||
#endif // (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// RuntimeJsImpl.h
|
||||
// Simulator
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __Simulator__RuntimeJsImpl__
|
||||
#define __Simulator__RuntimeJsImpl__
|
||||
|
||||
#include "CodeIDESupport.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
#include "runtime/RuntimeProtocol.h"
|
||||
|
||||
class RuntimeJsImpl : public RuntimeProtocol
|
||||
{
|
||||
public:
|
||||
static RuntimeJsImpl* create();
|
||||
|
||||
void startScript(const std::string& file);
|
||||
void onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse);
|
||||
void onClearCompile(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse);
|
||||
void onPrecompile(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse);
|
||||
void onReload(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse);
|
||||
void onRemove(const std::string &filename);
|
||||
void end();
|
||||
|
||||
bool startWithDebugger();
|
||||
private:
|
||||
RuntimeJsImpl();
|
||||
bool initJsEnv();
|
||||
bool loadScriptFile(const std::string& file);
|
||||
bool _hasStarted;
|
||||
};
|
||||
|
||||
#endif // (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
|
||||
#endif /* defined(__Simulator__RuntimeLua__) */
|
|
@ -0,0 +1,341 @@
|
|||
//
|
||||
// RuntimeLuaImpl.cpp
|
||||
// Simulator
|
||||
//
|
||||
//
|
||||
|
||||
#include "RuntimeLuaImpl.h"
|
||||
|
||||
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "lua_debugger.h"
|
||||
#include "CCLuaEngine.h"
|
||||
#include "LuaBasicConversions.h"
|
||||
#include "lua_module_register.h"
|
||||
|
||||
#include "runtime/Runtime.h"
|
||||
#include "runtime/ConfigParser.h"
|
||||
#include "runtime/FileServer.h"
|
||||
|
||||
extern std::string g_projectPath; // Runtime.cpp
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace std;
|
||||
|
||||
static void resetLuaModule(const string& fileName)
|
||||
{
|
||||
if (fileName.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto engine = LuaEngine::getInstance();
|
||||
LuaStack* luaStack = engine->getLuaStack();
|
||||
lua_State* stack = luaStack->getLuaState();
|
||||
lua_getglobal(stack, "package"); /* L: package */
|
||||
lua_getfield(stack, -1, "loaded"); /* L: package loaded */
|
||||
lua_pushnil(stack); /* L: lotable ?-.. nil */
|
||||
while (0 != lua_next(stack, -2)) /* L: lotable ?-.. key value */
|
||||
{
|
||||
//CCLOG("%s - %s \n", tolua_tostring(stack, -2, ""), lua_typename(stack, lua_type(stack, -1)));
|
||||
std::string key = tolua_tostring(stack, -2, "");
|
||||
std::string tableKey = key;
|
||||
size_t found = tableKey.rfind(".lua");
|
||||
if (found != std::string::npos)
|
||||
tableKey = tableKey.substr(0, found);
|
||||
tableKey = replaceAll(tableKey, ".", "/");
|
||||
tableKey = replaceAll(tableKey, "\\", "/");
|
||||
tableKey.append(".lua");
|
||||
found = fileName.rfind(tableKey);
|
||||
if (0 == found || (found != std::string::npos && fileName.at(found - 1) == '/'))
|
||||
{
|
||||
lua_pushstring(stack, key.c_str());
|
||||
lua_pushnil(stack);
|
||||
if (lua_istable(stack, -5))
|
||||
{
|
||||
lua_settable(stack, -5);
|
||||
}
|
||||
}
|
||||
lua_pop(stack, 1);
|
||||
}
|
||||
lua_pop(stack, 2);
|
||||
}
|
||||
|
||||
bool reloadScript(const string& file)
|
||||
{
|
||||
auto director = Director::getInstance();
|
||||
FontFNT::purgeCachedData();
|
||||
if (director->getOpenGLView())
|
||||
{
|
||||
SpriteFrameCache::getInstance()->removeSpriteFrames();
|
||||
director->getTextureCache()->removeAllTextures();
|
||||
}
|
||||
FileUtils::getInstance()->purgeCachedEntries();
|
||||
string modulefile = file;
|
||||
|
||||
if (! modulefile.empty())
|
||||
{
|
||||
resetLuaModule(modulefile);
|
||||
}
|
||||
else
|
||||
{
|
||||
modulefile = ConfigParser::getInstance()->getEntryFile().c_str();
|
||||
}
|
||||
|
||||
auto engine = LuaEngine::getInstance();
|
||||
LuaStack* luaStack = engine->getLuaStack();
|
||||
std::string require = "require \'" + modulefile + "\'";
|
||||
return luaStack->executeString(require.c_str());
|
||||
}
|
||||
|
||||
int lua_cocos2dx_runtime_addSearchPath(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FileUtils* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_addSearchPath'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1 || argc == 2)
|
||||
{
|
||||
std::string arg0;
|
||||
bool arg1 = false;
|
||||
|
||||
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
ok &= luaval_to_boolean(tolua_S, 3, &arg1);
|
||||
}
|
||||
|
||||
if(!ok)
|
||||
return 0;
|
||||
|
||||
if (! FileUtils::getInstance()->isAbsolutePath(arg0))
|
||||
{
|
||||
// add write path to search path
|
||||
if (FileServer::getShareInstance()->getIsUsingWritePath())
|
||||
{
|
||||
cobj->addSearchPath(FileServer::getShareInstance()->getWritePath() + arg0, arg1);
|
||||
} else
|
||||
{
|
||||
cobj->addSearchPath(arg0, arg1);
|
||||
}
|
||||
|
||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
// add project path to search path
|
||||
cobj->addSearchPath(g_projectPath + arg0, arg1);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addSearchPath",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_addSearchPath'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_cocos2dx_runtime_setSearchPaths(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FileUtils* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_runtime_setSearchPaths'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
std::vector<std::string> vecPaths, writePaths;
|
||||
|
||||
ok &= luaval_to_std_vector_string(tolua_S, 2, &vecPaths);
|
||||
if(!ok)
|
||||
return 0;
|
||||
std::vector<std::string> originPath; // for IOS platform.
|
||||
std::vector<std::string> projPath; // for Desktop platform.
|
||||
for (size_t i = 0; i < vecPaths.size(); i++)
|
||||
{
|
||||
if (!FileUtils::getInstance()->isAbsolutePath(vecPaths[i]))
|
||||
{
|
||||
originPath.push_back(vecPaths[i]); // for IOS platform.
|
||||
projPath.push_back(g_projectPath + vecPaths[i]); //for Desktop platform.
|
||||
writePaths.push_back(FileServer::getShareInstance()->getWritePath() + vecPaths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
vecPaths.insert(vecPaths.end(), projPath.begin(), projPath.end());
|
||||
#endif
|
||||
if (FileServer::getShareInstance()->getIsUsingWritePath())
|
||||
{
|
||||
vecPaths.insert(vecPaths.end(), writePaths.begin(), writePaths.end());
|
||||
} else
|
||||
{
|
||||
vecPaths.insert(vecPaths.end(), originPath.begin(), originPath.end());
|
||||
}
|
||||
|
||||
cobj->setSearchPaths(vecPaths);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSearchPaths",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_runtime_setSearchPaths'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void register_runtime_override_function(lua_State* tolua_S)
|
||||
{
|
||||
lua_pushstring(tolua_S, "cc.FileUtils");
|
||||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1)){
|
||||
tolua_function(tolua_S,"addSearchPath",lua_cocos2dx_runtime_addSearchPath);
|
||||
tolua_function(tolua_S,"setSearchPaths",lua_cocos2dx_runtime_setSearchPaths);
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
static void luaScriptLoader(std::string strDebugArg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
RuntimeLuaImpl *RuntimeLuaImpl::create()
|
||||
{
|
||||
auto instance = new RuntimeLuaImpl();
|
||||
return instance;
|
||||
}
|
||||
|
||||
void RuntimeLuaImpl::onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse)
|
||||
{
|
||||
// Lua
|
||||
char szDebugArg[1024] = {0};
|
||||
sprintf(szDebugArg, "require('debugger')(%s,'%s')",dArgParse["debugcfg"].GetString(), "");
|
||||
startScript(szDebugArg);
|
||||
dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator());
|
||||
}
|
||||
|
||||
void RuntimeLuaImpl::onReload(const rapidjson::Document &dArgParse, rapidjson::Document &dReplyParse)
|
||||
{
|
||||
// lua
|
||||
if (dArgParse.HasMember("modulefiles"))
|
||||
{
|
||||
rapidjson::Value bodyvalue(rapidjson::kObjectType);
|
||||
const rapidjson::Value& objectfiles = dArgParse["modulefiles"];
|
||||
for (rapidjson::SizeType i = 0; i < objectfiles.Size(); i++)
|
||||
{
|
||||
if (!reloadScript(objectfiles[i].GetString()))
|
||||
{
|
||||
bodyvalue.AddMember(objectfiles[i].GetString(), 1, dReplyParse.GetAllocator());
|
||||
}
|
||||
}
|
||||
if (0 == objectfiles.Size())
|
||||
{
|
||||
reloadScript("");
|
||||
}
|
||||
dReplyParse.AddMember("body", bodyvalue, dReplyParse.GetAllocator());
|
||||
}
|
||||
|
||||
dReplyParse.AddMember("code", 0, dReplyParse.GetAllocator());
|
||||
}
|
||||
|
||||
void RuntimeLuaImpl::startScript(const std::string& strDebugArg)
|
||||
{
|
||||
init();
|
||||
auto engine = LuaEngine::getInstance();
|
||||
auto stack = engine->getLuaStack();
|
||||
|
||||
const ProjectConfig &project = RuntimeEngine::getInstance()->getProjectConfig();
|
||||
|
||||
// set search path
|
||||
string path = FileUtils::getInstance()->fullPathForFilename(project.getScriptFileRealPath().c_str());
|
||||
size_t pos;
|
||||
while ((pos = path.find_first_of("\\")) != std::string::npos)
|
||||
{
|
||||
path.replace(pos, 1, "/");
|
||||
}
|
||||
size_t p = path.find_last_of("/");
|
||||
string workdir;
|
||||
if (p != path.npos)
|
||||
{
|
||||
workdir = path.substr(0, p);
|
||||
stack->addSearchPath(workdir.c_str());
|
||||
FileUtils::getInstance()->addSearchPath(workdir);
|
||||
}
|
||||
|
||||
// register lua engine
|
||||
if (!strDebugArg.empty())
|
||||
{
|
||||
// open debugger.lua module
|
||||
cocos2d::log("debug args = %s", strDebugArg.c_str());
|
||||
luaopen_lua_debugger(engine->getLuaStack()->getLuaState());
|
||||
engine->executeString(strDebugArg.c_str());
|
||||
}
|
||||
std::string code("require \"");
|
||||
code.append(ConfigParser::getInstance()->getEntryFile().c_str());
|
||||
code.append("\"");
|
||||
engine->executeString(code.c_str());
|
||||
}
|
||||
|
||||
//
|
||||
// private
|
||||
//
|
||||
|
||||
void RuntimeLuaImpl::init()
|
||||
{
|
||||
auto engine = LuaEngine::getInstance();
|
||||
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
||||
lua_module_register(engine->getLuaStack()->getLuaState());
|
||||
register_runtime_override_function(engine->getLuaStack()->getLuaState());
|
||||
engine->getLuaStack()->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA"));
|
||||
}
|
||||
|
||||
#endif // (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// RuntimeLuaImpl.h
|
||||
// Simulator
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __Simulator__RuntimeLuaImpl__
|
||||
#define __Simulator__RuntimeLuaImpl__
|
||||
|
||||
#include "CodeIDESupport.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
|
||||
#include "runtime/RuntimeProtocol.h"
|
||||
|
||||
class RuntimeLuaImpl : public RuntimeProtocol
|
||||
{
|
||||
public:
|
||||
static RuntimeLuaImpl *create();
|
||||
|
||||
void onStartDebuger(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse);
|
||||
void onReload(const rapidjson::Document& dArgParse, rapidjson::Document& dReplyParse);
|
||||
void startScript(const std::string& strDebugArg);
|
||||
|
||||
private:
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif // (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
|
||||
#endif /* defined(__Simulator__RuntimeLua__) */
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"zh-CN": {
|
||||
"View": "视图(&V)",
|
||||
"Exit": "退出(&X)",
|
||||
"File": "文件(&F)",
|
||||
"Portrait": "竖屏",
|
||||
"Landscape": "横屏",
|
||||
"Refresh": "刷新(重启)",
|
||||
"Zoom Out": "缩放",
|
||||
"Simulator": "模拟器",
|
||||
"Open File": "打开文件",
|
||||
"Open Project": "打开工程",
|
||||
"Error": "错误",
|
||||
"Help": "帮助(&H)",
|
||||
"About": "关于(&A)"
|
||||
},
|
||||
"zh-Hans": {
|
||||
"View": "视图",
|
||||
"Exit": "退出",
|
||||
"File": "文件",
|
||||
"Portrait": "竖屏",
|
||||
"Landscape": "横屏",
|
||||
"Refresh": "刷新(重启)",
|
||||
"Zoom Out": "缩放",
|
||||
"Simulator": "模拟器",
|
||||
"Help": "帮助(&H)",
|
||||
"About": "关于(&A)"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
/* lua_debugger.h.h */
|
||||
|
||||
#ifndef __LUA_MODULES_049C000C96FE547176CCBB7690BA01B6_H_
|
||||
#define __LUA_MODULES_049C000C96FE547176CCBB7690BA01B6_H_
|
||||
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
void luaopen_lua_debugger(lua_State* L);
|
||||
|
||||
/*
|
||||
int luaopen_lua_m_debugger(lua_State* L);
|
||||
*/
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LUA_MODULES_049C000C96FE547176CCBB7690BA01B6_H_ */
|
|
@ -0,0 +1,79 @@
|
|||
#ifndef __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
|
||||
#define __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
|
||||
|
||||
#include "scripting/js-bindings/manual/ScriptingCore.h"
|
||||
#include "jsb_cocos2dx_auto.hpp"
|
||||
#include "jsb_cocos2dx_ui_auto.hpp"
|
||||
#include "jsb_cocos2dx_studio_auto.hpp"
|
||||
#include "jsb_cocos2dx_builder_auto.hpp"
|
||||
#include "jsb_cocos2dx_spine_auto.hpp"
|
||||
#include "jsb_cocos2dx_extension_auto.hpp"
|
||||
#include "ui/jsb_cocos2dx_ui_manual.h"
|
||||
#include "cocostudio/jsb_cocos2dx_studio_manual.h"
|
||||
#include "cocosbuilder/js_bindings_ccbreader.h"
|
||||
#include "spine/jsb_cocos2dx_spine_manual.h"
|
||||
#include "extension/jsb_cocos2dx_extension_manual.h"
|
||||
#include "localstorage/js_bindings_system_registration.h"
|
||||
#include "chipmunk/js_bindings_chipmunk_registration.h"
|
||||
#include "jsb_opengl_registration.h"
|
||||
#include "network/XMLHTTPRequest.h"
|
||||
#include "network/jsb_websocket.h"
|
||||
#include "network/jsb_socketio.h"
|
||||
#include "cocos2d_specifics.hpp"
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#include "platform/android/CCJavascriptJavaBridge.h"
|
||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
#include "platform/ios/JavaScriptObjCBridge.h"
|
||||
#endif
|
||||
|
||||
USING_NS_CC;
|
||||
int js_module_register()
|
||||
{
|
||||
ScriptingCore* sc = ScriptingCore::getInstance();
|
||||
sc->addRegisterCallback(register_all_cocos2dx);
|
||||
sc->addRegisterCallback(register_cocos2dx_js_core);
|
||||
sc->addRegisterCallback(jsb_register_system);
|
||||
|
||||
// extension can be commented out to reduce the package
|
||||
sc->addRegisterCallback(register_all_cocos2dx_extension);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
|
||||
|
||||
// chipmunk can be commented out to reduce the package
|
||||
sc->addRegisterCallback(jsb_register_chipmunk);
|
||||
// opengl can be commented out to reduce the package
|
||||
sc->addRegisterCallback(JSB_register_opengl);
|
||||
|
||||
// builder can be commented out to reduce the package
|
||||
sc->addRegisterCallback(register_all_cocos2dx_builder);
|
||||
sc->addRegisterCallback(register_CCBuilderReader);
|
||||
|
||||
// ui can be commented out to reduce the package, attension studio need ui module
|
||||
sc->addRegisterCallback(register_all_cocos2dx_ui);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_ui_manual);
|
||||
|
||||
// studio can be commented out to reduce the package,
|
||||
sc->addRegisterCallback(register_all_cocos2dx_studio);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_studio_manual);
|
||||
|
||||
// spine can be commented out to reduce the package
|
||||
sc->addRegisterCallback(register_all_cocos2dx_spine);
|
||||
sc->addRegisterCallback(register_all_cocos2dx_spine_manual);
|
||||
|
||||
// XmlHttpRequest can be commented out to reduce the package
|
||||
sc->addRegisterCallback(MinXmlHttpRequest::_js_register);
|
||||
// websocket can be commented out to reduce the package
|
||||
sc->addRegisterCallback(register_jsb_websocket);
|
||||
// sokcet io can be commented out to reduce the package
|
||||
sc->addRegisterCallback(register_jsb_socketio);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
sc->addRegisterCallback(JavascriptJavaBridge::_js_register);
|
||||
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS|| CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
sc->addRegisterCallback(JavaScriptObjCBridge::_js_register);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // __JS_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_JS_MODULE_REGISTER_H__
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
||||
#define __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
||||
|
||||
#include "cocosdenshion/lua_cocos2dx_cocosdenshion_manual.h"
|
||||
#include "network/lua_cocos2dx_network_manual.h"
|
||||
#include "cocosbuilder/lua_cocos2dx_cocosbuilder_manual.h"
|
||||
#include "cocostudio/lua_cocos2dx_coco_studio_manual.hpp"
|
||||
#include "extension/lua_cocos2dx_extension_manual.h"
|
||||
#include "ui/lua_cocos2dx_ui_manual.hpp"
|
||||
#include "spine/lua_cocos2dx_spine_manual.hpp"
|
||||
#include "3d/lua_cocos2dx_3d_manual.h"
|
||||
#include "audioengine/lua_cocos2dx_audioengine_manual.h"
|
||||
#include "lua/quick/lua_cocos2dx_quick_manual.hpp"
|
||||
|
||||
int lua_module_register(lua_State* L)
|
||||
{
|
||||
//Dont' change the module register order unless you know what your are doing
|
||||
register_cocosdenshion_module(L);
|
||||
register_network_module(L);
|
||||
register_cocosbuilder_module(L);
|
||||
register_cocostudio_module(L);
|
||||
register_ui_moudle(L);
|
||||
register_extension_module(L);
|
||||
register_spine_module(L);
|
||||
register_cocos3d_module(L);
|
||||
register_audioengine_module(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // __LUA_TEMPLATE_RUNTIME_FRAMEWORKS_RUNTIME_SRC_CLASSES_LUA_MODULE_REGISTER_H__
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>simulator</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cocos.apps.simulator"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-sdk android:minSdkVersion="9"/>
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/icon">
|
||||
|
||||
<!-- Tell Cocos2dxActivity the name of our .so -->
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="cocos2dlua" />
|
||||
|
||||
<activity android:name="org.cocos2dx.lua.AppActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:configChanges="orientation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<supports-screens android:anyDensity="true"
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:xlargeScreens="true"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
</manifest>
|
|
@ -0,0 +1,21 @@
|
|||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
||||
key.alias.password=android
|
||||
key.store.password=android
|
||||
key.store=/Users/jryin/.android/debug.keystore
|
||||
key.alias=androiddebugkey
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"ndk_module_path" :[
|
||||
"../../../../../",
|
||||
"../../../../../cocos/",
|
||||
"../../../../../external",
|
||||
"../../../../../cocos/scripting"
|
||||
],
|
||||
"copy_resources": [
|
||||
],
|
||||
"must_copy_resources": [
|
||||
{
|
||||
"from": "../../../config.json",
|
||||
"to": ""
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="simulator" default="debug">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := cocos2dlua_shared
|
||||
|
||||
LOCAL_MODULE_FILENAME := libcocos2dlua
|
||||
|
||||
ifeq ($(COCOS_SIMULATOR_BUILD),1)
|
||||
LOCAL_ARM_MODE := arm
|
||||
endif
|
||||
|
||||
FILE_LIST := hellolua/main.cpp
|
||||
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
|
||||
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/ide-support/*.cpp)
|
||||
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/ide-support/*.c)
|
||||
|
||||
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/../../Classes/protobuf-lite \
|
||||
$(LOCAL_PATH)/../../Classes/runtime \
|
||||
$(LOCAL_PATH)/../../Classes \
|
||||
$(LOCAL_PATH)/../../../../../../external \
|
||||
$(LOCAL_PATH)/../../../../../../tools/simulator/libsimulator/lib \
|
||||
$(LOCAL_PATH)/../../../../../../tools/simulator/libsimulator/lib/protobuf-lite
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := cocos2d_lua_static
|
||||
LOCAL_STATIC_LIBRARIES += cocos2d_simulator_static
|
||||
LOCAL_STATIC_LIBRARIES += cocos2d_js_static
|
||||
|
||||
LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,scripting/lua-bindings/proj.android)
|
||||
$(call import-module,scripting/js-bindings/proj.android)
|
||||
$(call import-module,tools/simulator/libsimulator/proj.android)
|
|
@ -0,0 +1,16 @@
|
|||
APP_STL := gnustl_static
|
||||
|
||||
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||
APP_LDFLAGS := -latomic
|
||||
|
||||
|
||||
ifeq ($(NDK_DEBUG),1)
|
||||
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
|
||||
APP_OPTIM := debug
|
||||
else
|
||||
APP_CPPFLAGS += -DNDEBUG
|
||||
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
|
||||
APP_OPTIM := release
|
||||
endif
|
||||
|
||||
COCOS_SIMULATOR_BUILD := 1
|
|
@ -0,0 +1,35 @@
|
|||
#include "AppDelegate.h"
|
||||
#include "cocos2d.h"
|
||||
#include "platform/android/jni/JniHelper.h"
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
#include "runtime/ConfigParser.h"
|
||||
#include "ide-support/CodeIDESupport.h"
|
||||
|
||||
#define LOG_TAG "main"
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
|
||||
LOGD("cocos_android_app_init");
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
bool Java_org_cocos2dx_lua_AppActivity_nativeIsLandScape(JNIEnv *env, jobject thisz)
|
||||
{
|
||||
return ConfigParser::getInstance()->isLanscape();
|
||||
}
|
||||
|
||||
bool Java_org_cocos2dx_lua_AppActivity_nativeIsDebug(JNIEnv *env, jobject thisz)
|
||||
{
|
||||
#if (COCOS2D_DEBUG > 0) && (CC_CODE_IDE_DEBUG_SUPPORT > 0)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -0,0 +1,13 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-10
|
||||
|
||||
android.library.reference.1=../../../../../cocos/platform/android/java
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 7.4 KiB |
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">simulator</string>
|
||||
</resources>
|
|
@ -0,0 +1,130 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2008-2010 Ricardo Quesada
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2011 Zynga Inc.
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lua;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
public class AppActivity extends Cocos2dxActivity{
|
||||
|
||||
static String hostIPAdress = "0.0.0.0";
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if(nativeIsLandScape()) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||
}
|
||||
|
||||
//2.Set the format of window
|
||||
|
||||
// Check the wifi is opened when the native is debug.
|
||||
if(nativeIsDebug())
|
||||
{
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
if(!isNetworkConnected())
|
||||
{
|
||||
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
||||
builder.setTitle("Warning");
|
||||
builder.setMessage("Please open WIFI for debuging...");
|
||||
builder.setPositiveButton("OK",new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||
finish();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
builder.setNegativeButton("Cancel", null);
|
||||
builder.setCancelable(true);
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
hostIPAdress = getHostIpAddress();
|
||||
}
|
||||
private boolean isNetworkConnected() {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (cm != null) {
|
||||
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
|
||||
ArrayList networkTypes = new ArrayList();
|
||||
networkTypes.add(ConnectivityManager.TYPE_WIFI);
|
||||
try {
|
||||
networkTypes.add(ConnectivityManager.class.getDeclaredField("TYPE_ETHERNET").getInt(null));
|
||||
} catch (NoSuchFieldException nsfe) {
|
||||
}
|
||||
catch (IllegalAccessException iae) {
|
||||
throw new RuntimeException(iae);
|
||||
}
|
||||
if (networkInfo != null && networkTypes.contains(networkInfo.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getHostIpAddress() {
|
||||
WifiManager wifiMgr = (WifiManager) getSystemService(WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
|
||||
int ip = wifiInfo.getIpAddress();
|
||||
return ((ip & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF) + "." + ((ip >>>= 8) & 0xFF));
|
||||
}
|
||||
|
||||
public static String getLocalIpAddress() {
|
||||
return hostIPAdress;
|
||||
}
|
||||
|
||||
private static native boolean nativeIsLandScape();
|
||||
private static native boolean nativeIsDebug();
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2013 cocos2d-x.org
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
@class RootViewController;
|
||||
|
||||
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate>
|
||||
{
|
||||
UIWindow *window;
|
||||
RootViewController *viewController;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2013 cocos2d-x.org
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "cocos2d.h"
|
||||
|
||||
#import "AppController.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "RootViewController.h"
|
||||
#import "platform/ios/CCEAGLView-ios.h"
|
||||
|
||||
@implementation AppController
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Application lifecycle
|
||||
|
||||
// cocos2d application instance
|
||||
static AppDelegate s_sharedApplication;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
|
||||
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||
app->initGLContextAttrs();
|
||||
cocos2d::GLViewImpl::convertAttrs();
|
||||
|
||||
// Override point for customization after application launch.
|
||||
|
||||
// Add the view controller's view to the window and display.
|
||||
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
||||
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
|
||||
depthFormat: cocos2d::GLViewImpl::_depthFormat
|
||||
preserveBackbuffer: NO
|
||||
sharegroup: nil
|
||||
multiSampling: NO
|
||||
numberOfSamples: 0 ];
|
||||
|
||||
[eaglView setMultipleTouchEnabled:YES];
|
||||
|
||||
// Use RootViewController manage CCEAGLView
|
||||
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
|
||||
viewController.wantsFullScreenLayout = YES;
|
||||
viewController.view = eaglView;
|
||||
|
||||
// Set RootViewController to window
|
||||
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
|
||||
{
|
||||
// warning: addSubView doesn't work on iOS6
|
||||
[window addSubview: viewController.view];
|
||||
}
|
||||
else
|
||||
{
|
||||
// use this method on ios6
|
||||
[window setRootViewController:viewController];
|
||||
}
|
||||
|
||||
[window makeKeyAndVisible];
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
||||
|
||||
// IMPORTANT: Setting the GLView should be done after creating the RootViewController
|
||||
cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView);
|
||||
cocos2d::Director::getInstance()->setOpenGLView(glview);
|
||||
|
||||
app->run();
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
/*
|
||||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
cocos2d::Director::getInstance()->pause();
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
cocos2d::Director::getInstance()->resume();
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
/*
|
||||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
cocos2d::Application::getInstance()->applicationDidEnterBackground();
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
/*
|
||||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
cocos2d::Application::getInstance()->applicationWillEnterForeground();
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
/*
|
||||
Called when the application is about to terminate.
|
||||
See also applicationDidEnterBackground:.
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Memory management
|
||||
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
||||
/*
|
||||
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
|
||||
*/
|
||||
cocos2d::Director::getInstance()->purgeCachedData();
|
||||
}
|
||||
|
||||
|
||||
- (void)dealloc {
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 747 KiB |
After Width: | Height: | Size: 574 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 567 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 8.2 KiB |