Merge pull request #934 from dumganhar/gles20

fixed #1176: Changed linebreak symbol to UNIX format ('\n'),replaced 'tab' with four spaces.
This commit is contained in:
James Chen 2012-05-29 02:15:58 -07:00
commit 1075b05fa6
46 changed files with 2040 additions and 2040 deletions

View File

@ -51,7 +51,7 @@ private:
static CCNode* ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps,
const char* assetsDir, CCNode* owner, CCNode* root);
// read different types of values from dict
// read different types of values from dict
static int intValFromDict(CCDictionary* dict, const std::string key);
@ -73,7 +73,7 @@ private:
const std::string key);
private:
// set properties
// set properties
static void setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict);

View File

@ -33,30 +33,30 @@ USING_NS_CC_EXT;
int CCBReader::intValFromDict(CCDictionary* dict, const std::string key)
{
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString->intValue();
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString->intValue();
}
float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key)
{
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString->floatValue();
}
bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key)
{
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return (bool) valueString->intValue();
}
CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*)dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*)dict->objectForKey(key.c_str());
if (!arr)
{
return ccp(0,0);
}
{
return ccp(0,0);
}
float x = ((CCString*)arr->objectAtIndex(0))->floatValue();
float y = ((CCString*)arr->objectAtIndex(1))->floatValue();
@ -65,12 +65,12 @@ CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key)
CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
if (!arr)
{
return CCSize(0, 0);
}
{
return CCSize(0, 0);
}
float w = ((CCString*)arr->objectAtIndex(0))->floatValue();
float h = ((CCString*)arr->objectAtIndex(1))->floatValue();
@ -79,7 +79,7 @@ CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key)
ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
int r = ((CCString*)arr->objectAtIndex(0))->intValue();
int g = ((CCString*)arr->objectAtIndex(1))->intValue();
@ -90,7 +90,7 @@ ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string k
ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
ccColor4F color;
color.r = ((CCString*)arr->objectAtIndex(0))->floatValue();
@ -103,7 +103,7 @@ ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string
ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
int src = ((CCString*)arr->objectAtIndex(0))->intValue();
int dst = ((CCString*)arr->objectAtIndex(1))->intValue();
@ -119,8 +119,8 @@ ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::strin
void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict)
{
std::string tagString;
tagString += tag;
std::string tagString;
tagString += tag;
CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str());
if (!props)
@ -301,15 +301,15 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction
void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps)
{
CCPoint position = pointValFromDict(props, "position");
node->setPosition(position);
CCPoint position = pointValFromDict(props, "position");
node->setPosition(position);
if (dynamic_cast<CCSprite*>(node) == NULL &&
dynamic_cast<CCMenuItemImage*>(node) == NULL &&
dynamic_cast<CCLabelBMFont*>(node) == NULL)
{
CCSize size = sizeValFromDict(props, "contentSize");
//node->setContentSize(size);
CCSize size = sizeValFromDict(props, "contentSize");
//node->setContentSize(size);
}
node->setScaleX(floatValFromDict(props, "scaleX"));
@ -330,7 +330,7 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps);
// Expanded nodes
@ -338,12 +338,12 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded");
if (isExpandedObj) {
isExpanded = !isExpandedObj->m_sString.empty();
} else {
isExpanded = true;
}
isExpanded = !isExpandedObj->m_sString.empty();
} else {
isExpanded = true;
}
setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps);
setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps);
}
else
{
@ -355,7 +355,7 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps,
const char* assetsDir, CCNode* owner, CCNode* root)
{
CCString* className = (CCString*) dict->objectForKey("class");
CCString* className = (CCString*) dict->objectForKey("class");
CCDictionary* props = (CCDictionary*) dict->objectForKey("properties");
CCArray* children = (CCArray*) dict->objectForKey("children");
@ -365,15 +365,15 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
CCNode* node = NULL;
if (className->m_sString.compare("CCParticleSystem") == 0)
if (className->m_sString.compare("CCParticleSystem") == 0)
{
CCString* spriteFile = new CCString(assetsDir);
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
CCParticleSystem* sys = new CCParticleSystemQuad();
sys->initWithTotalParticles(2048);
sys->initWithTotalParticles(2048);
sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str()));
delete spriteFile;
delete spriteFile;
node = (CCNode*)sys;
setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps);
@ -382,11 +382,11 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
else if (className->m_sString.compare("CCMenuItemImage") == 0)
{
CCString* spriteFileNormal = new CCString(assetsDir);
spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString();
spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString();
CCString* spriteFileSelected = new CCString(assetsDir);
spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString();
spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString();
CCString* spriteFileDisabled = new CCString(assetsDir);
spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString();
spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString();
CCSprite* spriteNormal = NULL;
CCSprite* spriteSelected = NULL;
@ -394,12 +394,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile");
if (spriteSheetFile && !spriteSheetFile->length()) {
spriteSheetFile->m_sString.insert(0, assetsDir);
}
spriteSheetFile->m_sString.insert(0, assetsDir);
}
if (spriteSheetFile && !spriteSheetFile->length())
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str());
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str());
spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString());
spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString());
@ -413,14 +413,14 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str());
}
//deallocate
//deallocate
CC_SAFE_DELETE(spriteFileNormal);
CC_SAFE_DELETE(spriteFileSelected);
CC_SAFE_DELETE(spriteFileDisabled);
if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png");
if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png");
if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png");
if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png");
CCNode *target = NULL ;
if ( extraProps == NULL )
@ -446,7 +446,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
target = NULL ;
}
node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel);
node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel);
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps);
@ -455,38 +455,38 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
else if (className->m_sString.compare("CCMenu") == 0)
{
node = (CCNode*)CCMenu::menuWithItems(NULL);
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps);
setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps);
}
else if (className->m_sString.compare("CCLabelBMFont") == 0)
else if (className->m_sString.compare("CCLabelBMFont") == 0)
{
CCString* fontFile = new CCString(assetsDir);
fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString;
fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString;
CCString* stringText = ((CCString*)props->objectForKey("string"));
node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(),
fontFile->m_sString.c_str() );
delete fontFile;
fontFile = 0;
delete fontFile;
fontFile = 0;
if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt");
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps);
setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps);
}
else if (className->m_sString.compare("CCSprite") == 0)
else if (className->m_sString.compare("CCSprite") == 0)
{
CCString* spriteFile = new CCString(assetsDir);
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile");
if (spriteSheetFile && !spriteSheetFile->length())
{
spriteSheetFile->m_sString.insert(0, assetsDir);
}
{
spriteSheetFile->m_sString.insert(0, assetsDir);
}
if (spriteSheetFile && !spriteSheetFile->length())
{
@ -515,7 +515,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCLayerGradient*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -538,7 +538,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCLayerColor*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -558,7 +558,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCLayer*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -579,7 +579,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCNode*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -592,7 +592,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
}
else
{
CCLOG("WARNING! Class of type %@ couldn't be found", className);
CCLOG("WARNING! Class of type %@ couldn't be found", className);
return NULL;
}
@ -611,7 +611,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
}
else
{
CCLOG("WARNING! Failed to add child to node");
CCLOG("WARNING! Failed to add child to node");
}
}
@ -660,7 +660,7 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict,
const char* assetsDir,
CCNode* owner)
{
if (!dict)
if (!dict)
{
CCLOG("WARNING! Trying to load invalid file type");
return NULL;
@ -686,8 +686,8 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict,
CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner)
{
CCLOG("CCBReader path is: %s", file);
std::string ccbFilePath(file);
CCLOG("CCBReader path is: %s", file);
std::string ccbFilePath(file);
std::string ccbFileDir;
// find ccbFileDir before "/" or "\"
@ -700,8 +700,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner)
}
CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str());
CCAssert(dict != NULL, "CCBReader: file not found");
CCAssert(dict != NULL, "CCBReader: file not found");
return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner);
return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner);
}

View File

@ -33,30 +33,30 @@ USING_NS_CC_EXT;
int CCBReader::intValFromDict(CCDictionary* dict, const std::string key)
{
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString? valueString->intValue() : 0;
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString? valueString->intValue() : 0;
}
float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key)
{
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString? valueString->floatValue() : 0;
}
bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key)
{
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
CCString* valueString = (CCString*) dict->objectForKey(key.c_str());
return valueString? ((bool)(valueString->intValue())) : false;
}
CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*)dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*)dict->objectForKey(key.c_str());
if (!arr)
{
return ccp(0,0);
}
{
return ccp(0,0);
}
float x = ((CCString*)arr->objectAtIndex(0))->floatValue();
float y = ((CCString*)arr->objectAtIndex(1))->floatValue();
@ -65,12 +65,12 @@ CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key)
CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
if (!arr)
{
return CCSize(0, 0);
}
{
return CCSize(0, 0);
}
float w = ((CCString*)arr->objectAtIndex(0))->floatValue();
float h = ((CCString*)arr->objectAtIndex(1))->floatValue();
@ -79,7 +79,7 @@ CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key)
ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
int r = ((CCString*)arr->objectAtIndex(0))->intValue();
int g = ((CCString*)arr->objectAtIndex(1))->intValue();
@ -90,7 +90,7 @@ ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string k
ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
ccColor4F color;
color.r = ((CCString*)arr->objectAtIndex(0))->floatValue();
@ -103,7 +103,7 @@ ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string
ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key)
{
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
CCArray* arr = (CCArray*) dict->objectForKey(key.c_str());
int src = ((CCString*)arr->objectAtIndex(0))->intValue();
int dst = ((CCString*)arr->objectAtIndex(1))->intValue();
@ -119,8 +119,8 @@ ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::strin
void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict)
{
std::string tagString;
tagString += tag;
std::string tagString;
tagString += tag;
CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str());
if (!props)
@ -301,7 +301,7 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction
void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps)
{
CCPoint position = pointValFromDict(props, "position");
CCPoint position = pointValFromDict(props, "position");
int refPointType = intValFromDict(props, "refPointType");
if (refPointType == kInvalidRelativePosition)
@ -369,8 +369,8 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
dynamic_cast<CCMenuItemImage*>(node) == NULL &&
dynamic_cast<CCLabelBMFont*>(node) == NULL)
{
CCSize size = sizeValFromDict(props, "contentSize");
//node->setContentSize(size);
CCSize size = sizeValFromDict(props, "contentSize");
//node->setContentSize(size);
}
node->setScaleX(floatValFromDict(props, "scaleX"));
@ -391,7 +391,7 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps);
setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps);
// Expanded nodes
@ -399,12 +399,12 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded");
if (isExpandedObj) {
isExpanded = !isExpandedObj->m_sString.empty();
} else {
isExpanded = true;
}
isExpanded = !isExpandedObj->m_sString.empty();
} else {
isExpanded = true;
}
setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps);
setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps);
}
else
{
@ -416,7 +416,7 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary*
CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps,
const char* assetsDir, CCNode* owner, CCNode* root)
{
CCString* className = (CCString*) dict->objectForKey("class");
CCString* className = (CCString*) dict->objectForKey("class");
CCDictionary* props = (CCDictionary*) dict->objectForKey("properties");
CCArray* children = (CCArray*) dict->objectForKey("children");
@ -426,15 +426,15 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
CCNode* node = NULL;
if (className->m_sString.compare("CCParticleSystem") == 0)
if (className->m_sString.compare("CCParticleSystem") == 0)
{
CCString* spriteFile = new CCString(assetsDir);
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
CCParticleSystem* sys = new CCParticleSystemQuad();
sys->initWithTotalParticles(2048);
sys->initWithTotalParticles(2048);
sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str()));
delete spriteFile;
delete spriteFile;
node = (CCNode*)sys;
setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps);
@ -443,11 +443,11 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
else if (className->m_sString.compare("CCMenuItemImage") == 0)
{
CCString* spriteFileNormal = new CCString(assetsDir);
spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString();
spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString();
CCString* spriteFileSelected = new CCString(assetsDir);
spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString();
spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString();
CCString* spriteFileDisabled = new CCString(assetsDir);
spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString();
spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString();
CCSprite* spriteNormal = NULL;
CCSprite* spriteSelected = NULL;
@ -455,12 +455,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile");
if (spriteSheetFile && !spriteSheetFile->length()) {
spriteSheetFile->m_sString.insert(0, assetsDir);
}
spriteSheetFile->m_sString.insert(0, assetsDir);
}
if (spriteSheetFile && !spriteSheetFile->length())
{
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str());
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str());
spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString());
spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString());
@ -474,14 +474,14 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str());
}
//deallocate
//deallocate
CC_SAFE_DELETE(spriteFileNormal);
CC_SAFE_DELETE(spriteFileSelected);
CC_SAFE_DELETE(spriteFileDisabled);
if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png");
if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png");
if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png");
if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png");
CCNode *target = NULL ;
if ( extraProps == NULL )
@ -507,7 +507,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
target = NULL ;
}
node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel);
node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel);
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps);
@ -516,38 +516,38 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
else if (className->m_sString.compare("CCMenu") == 0)
{
node = (CCNode*)CCMenu::menuWithItems(NULL);
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps);
setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps);
}
else if (className->m_sString.compare("CCLabelBMFont") == 0)
else if (className->m_sString.compare("CCLabelBMFont") == 0)
{
CCString* fontFile = new CCString(assetsDir);
fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString;
fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString;
CCString* stringText = ((CCString*)props->objectForKey("string"));
node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(),
fontFile->m_sString.c_str() );
delete fontFile;
fontFile = 0;
delete fontFile;
fontFile = 0;
if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt");
setPropsForNode(node, (CCDictionary*) props, extraProps);
setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps);
setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps);
}
else if (className->m_sString.compare("CCSprite") == 0)
else if (className->m_sString.compare("CCSprite") == 0)
{
CCString* spriteFile = new CCString(assetsDir);
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString;
CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile");
if (spriteSheetFile && !spriteSheetFile->length())
{
spriteSheetFile->m_sString.insert(0, assetsDir);
}
{
spriteSheetFile->m_sString.insert(0, assetsDir);
}
if (spriteSheetFile && !spriteSheetFile->length())
{
@ -576,7 +576,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCLayerGradient*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -599,7 +599,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCLayerColor*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -619,7 +619,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCLayer*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -640,7 +640,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
if (dynamic_cast<CCNode*>(node) == NULL)
{
CCLOG("WARNING! %s is not subclass of CCNode", customClass);
delete node;
delete node;
node = NULL;
}
}
@ -653,7 +653,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
}
else
{
CCLOG("WARNING! Class of type %@ couldn't be found", className);
CCLOG("WARNING! Class of type %@ couldn't be found", className);
return NULL;
}
@ -672,7 +672,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr
}
else
{
CCLOG("WARNING! Failed to add child to node");
CCLOG("WARNING! Failed to add child to node");
}
}
@ -721,7 +721,7 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict,
const char* assetsDir,
CCNode* owner)
{
if (!dict)
if (!dict)
{
CCLOG("WARNING! Trying to load invalid file type");
return NULL;
@ -747,8 +747,8 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict,
CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner)
{
CCLOG("CCBReader path is: %s", file);
std::string ccbFilePath(file);
CCLOG("CCBReader path is: %s", file);
std::string ccbFilePath(file);
std::string ccbFileDir;
// find ccbFileDir before "/" or "\"
@ -761,8 +761,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner)
}
CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str());
CCAssert(dict != NULL, "CCBReader: file not found");
CCAssert(dict != NULL, "CCBReader: file not found");
return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner);
return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner);
}

View File

@ -392,19 +392,19 @@ out:
static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
{
tImageSource* isource = (tImageSource*)fd;
uint8* ma;
uint64 mb;
unsigned long n;
unsigned long o;
tmsize_t p;
ma=(uint8*)buf;
mb=size;
p=0;
while (mb>0)
{
n=0x80000000UL;
if ((uint64)n>mb)
n=(unsigned long)mb;
uint8* ma;
uint64 mb;
unsigned long n;
unsigned long o;
tmsize_t p;
ma=(uint8*)buf;
mb=size;
p=0;
while (mb>0)
{
n=0x80000000UL;
if ((uint64)n>mb)
n=(unsigned long)mb;
if((int)(isource->offset + n) <= isource->size)
@ -418,15 +418,15 @@ static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
return 0;
}
ma+=o;
mb-=o;
p+=o;
if (o!=n)
ma+=o;
mb-=o;
p+=o;
if (o!=n)
{
break;
break;
}
}
return p;
}
return p;
}
static tmsize_t _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size)
@ -434,7 +434,7 @@ static tmsize_t _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size)
CC_UNUSED_PARAM(fd);
CC_UNUSED_PARAM(buf);
CC_UNUSED_PARAM(size);
return 0;
return 0;
}
@ -444,7 +444,7 @@ static uint64 _tiffSeekProc(thandle_t fd, uint64 off, int whence)
uint64 ret = -1;
do
{
if (whence == SEEK_SET)
if (whence == SEEK_SET)
{
CC_BREAK_IF(off > isource->size-1);
ret = isource->offset = (uint32)off;

View File

@ -16,254 +16,254 @@ using namespace cocos2d;
static JSClass global_class = {
"global", JSCLASS_GLOBAL_FLAGS,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
"global", JSCLASS_GLOBAL_FLAGS,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
};
ScriptingCore::ScriptingCore()
{
this->rt = JS_NewRuntime(8 * 1024 * 1024);
this->cx = JS_NewContext(rt, 8192);
JS_SetOptions(this->cx, JSOPTION_VAROBJFIX);
JS_SetVersion(this->cx, JSVERSION_LATEST);
JS_SetErrorReporter(this->cx, ScriptingCore::reportError);
global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
if (!JS_InitStandardClasses(cx, global)) {
CCLog("js error");
}
// create the cocos namespace
JSObject *cocos = JS_NewObject(cx, NULL, NULL, NULL);
jsval cocosVal = OBJECT_TO_JSVAL(cocos);
JS_SetProperty(cx, global, "cocos", &cocosVal);
this->rt = JS_NewRuntime(8 * 1024 * 1024);
this->cx = JS_NewContext(rt, 8192);
JS_SetOptions(this->cx, JSOPTION_VAROBJFIX);
JS_SetVersion(this->cx, JSVERSION_LATEST);
JS_SetErrorReporter(this->cx, ScriptingCore::reportError);
global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
if (!JS_InitStandardClasses(cx, global)) {
CCLog("js error");
}
// create the cocos namespace
JSObject *cocos = JS_NewObject(cx, NULL, NULL, NULL);
jsval cocosVal = OBJECT_TO_JSVAL(cocos);
JS_SetProperty(cx, global, "cocos", &cocosVal);
// register the internal classes
S_CCPoint::jsCreateClass(this->cx, cocos, "Point");
S_CCSize::jsCreateClass(this->cx, cocos, "Size");
S_CCRect::jsCreateClass(this->cx, cocos, "Rect");
S__ccGridSize::jsCreateClass(this->cx, cocos, "GridSize");
S_CCSet::jsCreateClass(this->cx, cocos, "Set");
S_CCTouch::jsCreateClass(this->cx, cocos, "Touch");
S_CCDirector::jsCreateClass(this->cx, cocos, "Director");
S_CCNode::jsCreateClass(this->cx, cocos, "Node");
S_CCTextureAtlas::jsCreateClass(this->cx, cocos, "TextureAtlas");
S_CCSpriteBatchNode::jsCreateClass(this->cx, cocos, "SpriteBatchNode");
S_CCScene::jsCreateClass(this->cx, cocos, "Scene");
S_CCLayer::jsCreateClass(this->cx, cocos, "Layer");
S_CCSprite::jsCreateClass(this->cx, cocos, "Sprite");
S_CCRenderTexture::jsCreateClass(this->cx, cocos, "RenderTexture");
S_CCMenu::jsCreateClass(this->cx, cocos, "Menu");
S_CCMenuItem::jsCreateClass(this->cx, cocos, "MenuItem");
S_CCMenuItemLabel::jsCreateClass(this->cx, cocos, "MenuItemLabel");
S_CCMenuItemSprite::jsCreateClass(this->cx, cocos, "MenuItemSprite");
S_CCMenuItemImage::jsCreateClass(this->cx, cocos, "MenuItemImage");
S_CCSpriteFrame::jsCreateClass(this->cx, cocos, "SpriteFrame");
S_CCSpriteFrameCache::jsCreateClass(this->cx, cocos, "SpriteFrameCache");
S_CCAnimation::jsCreateClass(this->cx, cocos, "Animation");
S_CCAction::jsCreateClass(this->cx, cocos, "Action");
S_CCActionInterval::jsCreateClass(this->cx, cocos, "ActionInterval");
S_CCFiniteTimeAction::jsCreateClass(this->cx, cocos, "FiniteTimeAction");
S_CCActionInstant::jsCreateClass(this->cx, cocos, "ActionInstant");
S_CCDelayTime::jsCreateClass(this->cx, cocos, "DelayTime");
S_CCAnimate::jsCreateClass(this->cx, cocos, "Animate");
S_CCMoveTo::jsCreateClass(this->cx, cocos, "MoveTo");
S_CCMoveBy::jsCreateClass(this->cx, cocos, "MoveBy");
S_CCRotateBy::jsCreateClass(this->cx, cocos, "RotateBy");
S_CCRotateTo::jsCreateClass(this->cx, cocos, "RotateTo");
S_CCActionEase::jsCreateClass(this->cx, cocos, "ActionEase");
S_CCEaseRateAction::jsCreateClass(this->cx, cocos, "EaseRateAction");
S_CCEaseIn::jsCreateClass(this->cx, cocos, "EaseIn");
S_CCEaseOut::jsCreateClass(this->cx, cocos, "EaseOut");
S_CCEaseInOut::jsCreateClass(this->cx, cocos, "EaseInOut");
S_CCEaseBackInOut::jsCreateClass(this->cx, cocos, "EaseBackInOut");
S_CCEaseBackOut::jsCreateClass(this->cx, cocos, "EaseBackOut");
S_CCEaseElasticIn::jsCreateClass(this->cx, cocos, "EaseElasticIn");
S_CCEaseElastic::jsCreateClass(this->cx, cocos, "EaseElastic");
S_CCEaseElasticOut::jsCreateClass(this->cx, cocos, "EaseElasticOut");
S_CCEaseElasticInOut::jsCreateClass(this->cx, cocos, "EaseElasticInOut");
S_CCEaseBounce::jsCreateClass(this->cx, cocos, "EaseBounce");
S_CCEaseBounceIn::jsCreateClass(this->cx, cocos, "EaseBounceIn");
S_CCEaseBounceInOut::jsCreateClass(this->cx, cocos, "EaseBounceInOut");
S_CCEaseBackIn::jsCreateClass(this->cx, cocos, "EaseBackIn");
S_CCEaseBounceOut::jsCreateClass(this->cx, cocos, "EaseBounceOut");
S_CCEaseExponentialIn::jsCreateClass(this->cx, cocos, "EaseExponentialIn");
S_CCEaseExponentialOut::jsCreateClass(this->cx, cocos, "EaseExponentialOut");
S_CCEaseExponentialInOut::jsCreateClass(this->cx, cocos, "EaseExponentialInOut");
S_CCEaseSineIn::jsCreateClass(this->cx, cocos, "EaseSineIn");
S_CCEaseSineOut::jsCreateClass(this->cx, cocos, "EaseSineOut");
S_CCEaseSineInOut::jsCreateClass(this->cx, cocos, "EaseSineInOut");
S_CCRepeatForever::jsCreateClass(this->cx, cocos, "RepeatForever");
S_CCSequence::jsCreateClass(this->cx, cocos, "Sequence");
S_CCLabelTTF::jsCreateClass(this->cx, cocos, "LabelTTF");
S_CCParticleSystem::jsCreateClass(this->cx, cocos, "ParticleSystem");
S_CCFileUtils::jsCreateClass(this->cx, cocos, "FileUtils");
S_CCTexture2D::jsCreateClass(this->cx, cocos, "Texture2D");
S_CCTextureCache::jsCreateClass(this->cx, cocos, "TextureCache");
S_CCParallaxNode::jsCreateClass(this->cx, cocos, "ParallaxNode");
S_CCTintBy::jsCreateClass(this->cx, cocos, "TintBy");
S_CCTintTo::jsCreateClass(this->cx, cocos, "TintTo");
S_CCLayerColor::jsCreateClass(this->cx, cocos, "LayerColor");
S_CCBlink::jsCreateClass(this->cx, cocos, "Blink");
S_CCSpeed::jsCreateClass(this->cx, cocos, "Speed");
S_CCGridAction::jsCreateClass(this->cx, cocos, "GridAction");
S_CCGrid3DAction::jsCreateClass(this->cx, cocos, "Grid3DAction");
S_CCWaves3D::jsCreateClass(this->cx, cocos, "Waves3D");
S_CCTransitionScene::jsCreateClass(this->cx, cocos, "TransitionScene");
S_CCTransitionSceneOriented::jsCreateClass(this->cx, cocos, "TransitionSceneOriented");
S_CCTransitionRotoZoom::jsCreateClass(this->cx, cocos, "TransitionRotoZoom");
S_CCTransitionFadeDown::jsCreateClass(this->cx, cocos, "TransitionFadeDown");
S_CCTransitionJumpZoom::jsCreateClass(this->cx, cocos, "TransitionJumpZoom");
S_CCTransitionMoveInL::jsCreateClass(this->cx, cocos, "TransitionMoveInL");
S_CCTransitionMoveInR::jsCreateClass(this->cx, cocos, "TransitionMoveInR");
S_CCTransitionMoveInT::jsCreateClass(this->cx, cocos, "TransitionMoveInT");
S_CCTransitionMoveInB::jsCreateClass(this->cx, cocos, "TransitionMoveInB");
S_CCTransitionSlideInL::jsCreateClass(this->cx, cocos, "TransitionSlideInL");
S_CCTransitionSlideInR::jsCreateClass(this->cx, cocos, "TransitionSlideInR");
S_CCTransitionSlideInB::jsCreateClass(this->cx, cocos, "TransitionSlideInB");
S_CCTransitionSlideInT::jsCreateClass(this->cx, cocos, "TransitionSlideInT");
S_CCTransitionShrinkGrow::jsCreateClass(this->cx, cocos, "TransitionShrinkGrow");
S_CCTransitionFlipX::jsCreateClass(this->cx, cocos, "TransitionFlipX");
S_CCTransitionFlipY::jsCreateClass(this->cx, cocos, "TransitionFlipY");
S_CCTransitionFlipAngular::jsCreateClass(this->cx, cocos, "TransitionFlipAngular");
S_CCTransitionZoomFlipX::jsCreateClass(this->cx, cocos, "TransitionZoomFlipX");
S_CCTransitionZoomFlipY::jsCreateClass(this->cx, cocos, "TransitionZoomFlipY");
S_CCTransitionZoomFlipAngular::jsCreateClass(this->cx, cocos, "TransitionZoomFlipAngular");
S_CCTransitionFade::jsCreateClass(this->cx, cocos, "TransitionFade");
S_CCTransitionCrossFade::jsCreateClass(this->cx, cocos, "TransitionCrossFade");
S_CCTransitionTurnOffTiles::jsCreateClass(this->cx, cocos, "TransitionTurnOffTiles");
S_CCTransitionSplitCols::jsCreateClass(this->cx, cocos, "TransitionSplitCols");
S_CCTransitionSplitRows::jsCreateClass(this->cx, cocos, "TransitionSplitRows");
S_CCTransitionFadeTR::jsCreateClass(this->cx, cocos, "TransitionFadeTR");
S_CCTransitionFadeBL::jsCreateClass(this->cx, cocos, "TransitionFadeBL");
S_CCTransitionFadeUp::jsCreateClass(this->cx, cocos, "TransitionFadeUp");
S_CCFadeOutBLTiles::jsCreateClass(this->cx, cocos, "FadeOutBLTiles");
S_CCProgressFromTo::jsCreateClass(this->cx, cocos, "ProgressFromTo");
S_CCFadeOutUpTiles::jsCreateClass(this->cx, cocos, "FadeOutUpTiles");
S_CCAnimationCache::jsCreateClass(this->cx, cocos, "AnimationCache");
S_CCPlace::jsCreateClass(this->cx, cocos, "Place");
S_CCLabelBMFont::jsCreateClass(this->cx, cocos, "LabelBMFont");
S_CCReverseTime::jsCreateClass(this->cx, cocos, "ReverseTime");
S_CCFadeOutTRTiles::jsCreateClass(this->cx, cocos, "FadeOutTRTiles");
S_CCCamera::jsCreateClass(this->cx, cocos, "Camera");
S_CCProgressTo::jsCreateClass(this->cx, cocos, "ProgressTo");
S_CCWavesTiles3D::jsCreateClass(this->cx, cocos, "WavesTiles3D");
S_CCMotionStreak::jsCreateClass(this->cx, cocos, "MotionStreak");
S_CCTransitionProgressRadialCCW::jsCreateClass(this->cx, cocos, "TransitionRadialProgressCCW");
S_CCFadeOutDownTiles::jsCreateClass(this->cx, cocos, "FadeOutDownTiles");
S_CCTurnOffTiles::jsCreateClass(this->cx, cocos, "TurnOffTiles");
S_CCDeccelAmplitude::jsCreateClass(this->cx, cocos, "DeccelAmplitude");
S_CCProgressTimer::jsCreateClass(this->cx, cocos, "ProgressTimer");
S_CCReuseGrid::jsCreateClass(this->cx, cocos, "ReuseGrid");
S_CCStopGrid::jsCreateClass(this->cx, cocos, "StopGrid");
S_CCTwirl::jsCreateClass(this->cx, cocos, "Twirl");
S_CCShakyTiles3D::jsCreateClass(this->cx, cocos, "ShakyTiles3D");
S_CCTransitionProgressRadialCW::jsCreateClass(this->cx, cocos, "TransitionProgressRadialCW");
S_CCAtlasNode::jsCreateClass(this->cx, cocos, "AtlasNode");
S_CCWaves::jsCreateClass(this->cx, cocos, "Waves");
S_CCShow::jsCreateClass(this->cx, cocos, "Show");
S_CCOrbitCamera::jsCreateClass(this->cx, cocos, "OrbitCamera");
S_CCShatteredTiles3D::jsCreateClass(this->cx, cocos, "ShatteredTiles3D");
S_CCHide::jsCreateClass(this->cx, cocos, "Hide");
S_CCToggleVisibility::jsCreateClass(this->cx, cocos, "ToggleVisibility");
S_CCActionCamera::jsCreateClass(this->cx, cocos, "ActionCamera");
S_CCShuffleTiles::jsCreateClass(this->cx, cocos, "ShuffleTiles");
S_CCLayerGradient::jsCreateClass(this->cx, cocos, "LayerGradient");
S_CCFlipX::jsCreateClass(this->cx, cocos, "FlipX");
S_CCRepeat::jsCreateClass(this->cx, cocos, "Repeat");
S_CCFlipY::jsCreateClass(this->cx, cocos, "FlipY");
S_CCBezierBy::jsCreateClass(this->cx, cocos, "BezierBy");
S_CCPageTurn3D::jsCreateClass(this->cx, cocos, "PageTurn3D");
S_CCLens3D::jsCreateClass(this->cx, cocos, "Lens3D");
S_CCRipple3D::jsCreateClass(this->cx, cocos, "Ripple3D");
S_CCApplication::jsCreateClass(this->cx, cocos, "Application");
S_CCFlipX3D::jsCreateClass(this->cx, cocos, "FlipX3D");
S_CCJumpTo::jsCreateClass(this->cx, cocos, "JumpTo");
S_CCTransitionPageTurn::jsCreateClass(this->cx, cocos, "TransitionPageTurn");
S_CCFlipY3D::jsCreateClass(this->cx, cocos, "FlipY3D");
S_CCLiquid::jsCreateClass(this->cx, cocos, "Liquid");
S_CCTiledGrid3DAction::jsCreateClass(this->cx, cocos, "TiledGrid3DAction");
S_CCJumpBy::jsCreateClass(this->cx, cocos, "JumpBy");
S_CCFollow::jsCreateClass(this->cx, cocos, "Follow");
S_CCSkewBy::jsCreateClass(this->cx, cocos, "SkewBy");
S_CCAccelDeccelAmplitude::jsCreateClass(this->cx, cocos, "AccelDeccelAmplitude");
S_CCLabelAtlas::jsCreateClass(this->cx, cocos, "LabelAtlas");
S_CCAccelAmplitude::jsCreateClass(this->cx, cocos, "AccelAmplitude");
S_CCSkewTo::jsCreateClass(this->cx, cocos, "SkewTo");
S_CCShaky3D::jsCreateClass(this->cx, cocos, "Shaky3D");
S_CCSplitCols::jsCreateClass(this->cx, cocos, "SplitCols");
S_CCFadeOut::jsCreateClass(this->cx, cocos, "FadeOut");
S_CCTileMapAtlas::jsCreateClass(this->cx, cocos, "TileMapAtlas");
S_CCFadeTo::jsCreateClass(this->cx, cocos, "FadeTo");
S_CCJumpTiles3D::jsCreateClass(this->cx, cocos, "JumpTiles3D");
S_CCFadeIn::jsCreateClass(this->cx, cocos, "FadeIn");
S_CCSplitRows::jsCreateClass(this->cx, cocos, "SplitRows");
S_CCScaleBy::jsCreateClass(this->cx, cocos, "ScaleBy");
S_CCScaleTo::jsCreateClass(this->cx, cocos, "ScaleTo");
S_CCBezierTo::jsCreateClass(this->cx, cocos, "BezierTo");
S_CCTMXTiledMap::jsCreateClass(this->cx, cocos, "TMXTiledMap");
S_CCTMXLayer::jsCreateClass(this->cx, cocos, "TMXLayer");
// register the internal classes
S_CCPoint::jsCreateClass(this->cx, cocos, "Point");
S_CCSize::jsCreateClass(this->cx, cocos, "Size");
S_CCRect::jsCreateClass(this->cx, cocos, "Rect");
S__ccGridSize::jsCreateClass(this->cx, cocos, "GridSize");
S_CCSet::jsCreateClass(this->cx, cocos, "Set");
S_CCTouch::jsCreateClass(this->cx, cocos, "Touch");
S_CCDirector::jsCreateClass(this->cx, cocos, "Director");
S_CCNode::jsCreateClass(this->cx, cocos, "Node");
S_CCTextureAtlas::jsCreateClass(this->cx, cocos, "TextureAtlas");
S_CCSpriteBatchNode::jsCreateClass(this->cx, cocos, "SpriteBatchNode");
S_CCScene::jsCreateClass(this->cx, cocos, "Scene");
S_CCLayer::jsCreateClass(this->cx, cocos, "Layer");
S_CCSprite::jsCreateClass(this->cx, cocos, "Sprite");
S_CCRenderTexture::jsCreateClass(this->cx, cocos, "RenderTexture");
S_CCMenu::jsCreateClass(this->cx, cocos, "Menu");
S_CCMenuItem::jsCreateClass(this->cx, cocos, "MenuItem");
S_CCMenuItemLabel::jsCreateClass(this->cx, cocos, "MenuItemLabel");
S_CCMenuItemSprite::jsCreateClass(this->cx, cocos, "MenuItemSprite");
S_CCMenuItemImage::jsCreateClass(this->cx, cocos, "MenuItemImage");
S_CCSpriteFrame::jsCreateClass(this->cx, cocos, "SpriteFrame");
S_CCSpriteFrameCache::jsCreateClass(this->cx, cocos, "SpriteFrameCache");
S_CCAnimation::jsCreateClass(this->cx, cocos, "Animation");
S_CCAction::jsCreateClass(this->cx, cocos, "Action");
S_CCActionInterval::jsCreateClass(this->cx, cocos, "ActionInterval");
S_CCFiniteTimeAction::jsCreateClass(this->cx, cocos, "FiniteTimeAction");
S_CCActionInstant::jsCreateClass(this->cx, cocos, "ActionInstant");
S_CCDelayTime::jsCreateClass(this->cx, cocos, "DelayTime");
S_CCAnimate::jsCreateClass(this->cx, cocos, "Animate");
S_CCMoveTo::jsCreateClass(this->cx, cocos, "MoveTo");
S_CCMoveBy::jsCreateClass(this->cx, cocos, "MoveBy");
S_CCRotateBy::jsCreateClass(this->cx, cocos, "RotateBy");
S_CCRotateTo::jsCreateClass(this->cx, cocos, "RotateTo");
S_CCActionEase::jsCreateClass(this->cx, cocos, "ActionEase");
S_CCEaseRateAction::jsCreateClass(this->cx, cocos, "EaseRateAction");
S_CCEaseIn::jsCreateClass(this->cx, cocos, "EaseIn");
S_CCEaseOut::jsCreateClass(this->cx, cocos, "EaseOut");
S_CCEaseInOut::jsCreateClass(this->cx, cocos, "EaseInOut");
S_CCEaseBackInOut::jsCreateClass(this->cx, cocos, "EaseBackInOut");
S_CCEaseBackOut::jsCreateClass(this->cx, cocos, "EaseBackOut");
S_CCEaseElasticIn::jsCreateClass(this->cx, cocos, "EaseElasticIn");
S_CCEaseElastic::jsCreateClass(this->cx, cocos, "EaseElastic");
S_CCEaseElasticOut::jsCreateClass(this->cx, cocos, "EaseElasticOut");
S_CCEaseElasticInOut::jsCreateClass(this->cx, cocos, "EaseElasticInOut");
S_CCEaseBounce::jsCreateClass(this->cx, cocos, "EaseBounce");
S_CCEaseBounceIn::jsCreateClass(this->cx, cocos, "EaseBounceIn");
S_CCEaseBounceInOut::jsCreateClass(this->cx, cocos, "EaseBounceInOut");
S_CCEaseBackIn::jsCreateClass(this->cx, cocos, "EaseBackIn");
S_CCEaseBounceOut::jsCreateClass(this->cx, cocos, "EaseBounceOut");
S_CCEaseExponentialIn::jsCreateClass(this->cx, cocos, "EaseExponentialIn");
S_CCEaseExponentialOut::jsCreateClass(this->cx, cocos, "EaseExponentialOut");
S_CCEaseExponentialInOut::jsCreateClass(this->cx, cocos, "EaseExponentialInOut");
S_CCEaseSineIn::jsCreateClass(this->cx, cocos, "EaseSineIn");
S_CCEaseSineOut::jsCreateClass(this->cx, cocos, "EaseSineOut");
S_CCEaseSineInOut::jsCreateClass(this->cx, cocos, "EaseSineInOut");
S_CCRepeatForever::jsCreateClass(this->cx, cocos, "RepeatForever");
S_CCSequence::jsCreateClass(this->cx, cocos, "Sequence");
S_CCLabelTTF::jsCreateClass(this->cx, cocos, "LabelTTF");
S_CCParticleSystem::jsCreateClass(this->cx, cocos, "ParticleSystem");
S_CCFileUtils::jsCreateClass(this->cx, cocos, "FileUtils");
S_CCTexture2D::jsCreateClass(this->cx, cocos, "Texture2D");
S_CCTextureCache::jsCreateClass(this->cx, cocos, "TextureCache");
S_CCParallaxNode::jsCreateClass(this->cx, cocos, "ParallaxNode");
S_CCTintBy::jsCreateClass(this->cx, cocos, "TintBy");
S_CCTintTo::jsCreateClass(this->cx, cocos, "TintTo");
S_CCLayerColor::jsCreateClass(this->cx, cocos, "LayerColor");
S_CCBlink::jsCreateClass(this->cx, cocos, "Blink");
S_CCSpeed::jsCreateClass(this->cx, cocos, "Speed");
S_CCGridAction::jsCreateClass(this->cx, cocos, "GridAction");
S_CCGrid3DAction::jsCreateClass(this->cx, cocos, "Grid3DAction");
S_CCWaves3D::jsCreateClass(this->cx, cocos, "Waves3D");
S_CCTransitionScene::jsCreateClass(this->cx, cocos, "TransitionScene");
S_CCTransitionSceneOriented::jsCreateClass(this->cx, cocos, "TransitionSceneOriented");
S_CCTransitionRotoZoom::jsCreateClass(this->cx, cocos, "TransitionRotoZoom");
S_CCTransitionFadeDown::jsCreateClass(this->cx, cocos, "TransitionFadeDown");
S_CCTransitionJumpZoom::jsCreateClass(this->cx, cocos, "TransitionJumpZoom");
S_CCTransitionMoveInL::jsCreateClass(this->cx, cocos, "TransitionMoveInL");
S_CCTransitionMoveInR::jsCreateClass(this->cx, cocos, "TransitionMoveInR");
S_CCTransitionMoveInT::jsCreateClass(this->cx, cocos, "TransitionMoveInT");
S_CCTransitionMoveInB::jsCreateClass(this->cx, cocos, "TransitionMoveInB");
S_CCTransitionSlideInL::jsCreateClass(this->cx, cocos, "TransitionSlideInL");
S_CCTransitionSlideInR::jsCreateClass(this->cx, cocos, "TransitionSlideInR");
S_CCTransitionSlideInB::jsCreateClass(this->cx, cocos, "TransitionSlideInB");
S_CCTransitionSlideInT::jsCreateClass(this->cx, cocos, "TransitionSlideInT");
S_CCTransitionShrinkGrow::jsCreateClass(this->cx, cocos, "TransitionShrinkGrow");
S_CCTransitionFlipX::jsCreateClass(this->cx, cocos, "TransitionFlipX");
S_CCTransitionFlipY::jsCreateClass(this->cx, cocos, "TransitionFlipY");
S_CCTransitionFlipAngular::jsCreateClass(this->cx, cocos, "TransitionFlipAngular");
S_CCTransitionZoomFlipX::jsCreateClass(this->cx, cocos, "TransitionZoomFlipX");
S_CCTransitionZoomFlipY::jsCreateClass(this->cx, cocos, "TransitionZoomFlipY");
S_CCTransitionZoomFlipAngular::jsCreateClass(this->cx, cocos, "TransitionZoomFlipAngular");
S_CCTransitionFade::jsCreateClass(this->cx, cocos, "TransitionFade");
S_CCTransitionCrossFade::jsCreateClass(this->cx, cocos, "TransitionCrossFade");
S_CCTransitionTurnOffTiles::jsCreateClass(this->cx, cocos, "TransitionTurnOffTiles");
S_CCTransitionSplitCols::jsCreateClass(this->cx, cocos, "TransitionSplitCols");
S_CCTransitionSplitRows::jsCreateClass(this->cx, cocos, "TransitionSplitRows");
S_CCTransitionFadeTR::jsCreateClass(this->cx, cocos, "TransitionFadeTR");
S_CCTransitionFadeBL::jsCreateClass(this->cx, cocos, "TransitionFadeBL");
S_CCTransitionFadeUp::jsCreateClass(this->cx, cocos, "TransitionFadeUp");
S_CCFadeOutBLTiles::jsCreateClass(this->cx, cocos, "FadeOutBLTiles");
S_CCProgressFromTo::jsCreateClass(this->cx, cocos, "ProgressFromTo");
S_CCFadeOutUpTiles::jsCreateClass(this->cx, cocos, "FadeOutUpTiles");
S_CCAnimationCache::jsCreateClass(this->cx, cocos, "AnimationCache");
S_CCPlace::jsCreateClass(this->cx, cocos, "Place");
S_CCLabelBMFont::jsCreateClass(this->cx, cocos, "LabelBMFont");
S_CCReverseTime::jsCreateClass(this->cx, cocos, "ReverseTime");
S_CCFadeOutTRTiles::jsCreateClass(this->cx, cocos, "FadeOutTRTiles");
S_CCCamera::jsCreateClass(this->cx, cocos, "Camera");
S_CCProgressTo::jsCreateClass(this->cx, cocos, "ProgressTo");
S_CCWavesTiles3D::jsCreateClass(this->cx, cocos, "WavesTiles3D");
S_CCMotionStreak::jsCreateClass(this->cx, cocos, "MotionStreak");
S_CCTransitionProgressRadialCCW::jsCreateClass(this->cx, cocos, "TransitionRadialProgressCCW");
S_CCFadeOutDownTiles::jsCreateClass(this->cx, cocos, "FadeOutDownTiles");
S_CCTurnOffTiles::jsCreateClass(this->cx, cocos, "TurnOffTiles");
S_CCDeccelAmplitude::jsCreateClass(this->cx, cocos, "DeccelAmplitude");
S_CCProgressTimer::jsCreateClass(this->cx, cocos, "ProgressTimer");
S_CCReuseGrid::jsCreateClass(this->cx, cocos, "ReuseGrid");
S_CCStopGrid::jsCreateClass(this->cx, cocos, "StopGrid");
S_CCTwirl::jsCreateClass(this->cx, cocos, "Twirl");
S_CCShakyTiles3D::jsCreateClass(this->cx, cocos, "ShakyTiles3D");
S_CCTransitionProgressRadialCW::jsCreateClass(this->cx, cocos, "TransitionProgressRadialCW");
S_CCAtlasNode::jsCreateClass(this->cx, cocos, "AtlasNode");
S_CCWaves::jsCreateClass(this->cx, cocos, "Waves");
S_CCShow::jsCreateClass(this->cx, cocos, "Show");
S_CCOrbitCamera::jsCreateClass(this->cx, cocos, "OrbitCamera");
S_CCShatteredTiles3D::jsCreateClass(this->cx, cocos, "ShatteredTiles3D");
S_CCHide::jsCreateClass(this->cx, cocos, "Hide");
S_CCToggleVisibility::jsCreateClass(this->cx, cocos, "ToggleVisibility");
S_CCActionCamera::jsCreateClass(this->cx, cocos, "ActionCamera");
S_CCShuffleTiles::jsCreateClass(this->cx, cocos, "ShuffleTiles");
S_CCLayerGradient::jsCreateClass(this->cx, cocos, "LayerGradient");
S_CCFlipX::jsCreateClass(this->cx, cocos, "FlipX");
S_CCRepeat::jsCreateClass(this->cx, cocos, "Repeat");
S_CCFlipY::jsCreateClass(this->cx, cocos, "FlipY");
S_CCBezierBy::jsCreateClass(this->cx, cocos, "BezierBy");
S_CCPageTurn3D::jsCreateClass(this->cx, cocos, "PageTurn3D");
S_CCLens3D::jsCreateClass(this->cx, cocos, "Lens3D");
S_CCRipple3D::jsCreateClass(this->cx, cocos, "Ripple3D");
S_CCApplication::jsCreateClass(this->cx, cocos, "Application");
S_CCFlipX3D::jsCreateClass(this->cx, cocos, "FlipX3D");
S_CCJumpTo::jsCreateClass(this->cx, cocos, "JumpTo");
S_CCTransitionPageTurn::jsCreateClass(this->cx, cocos, "TransitionPageTurn");
S_CCFlipY3D::jsCreateClass(this->cx, cocos, "FlipY3D");
S_CCLiquid::jsCreateClass(this->cx, cocos, "Liquid");
S_CCTiledGrid3DAction::jsCreateClass(this->cx, cocos, "TiledGrid3DAction");
S_CCJumpBy::jsCreateClass(this->cx, cocos, "JumpBy");
S_CCFollow::jsCreateClass(this->cx, cocos, "Follow");
S_CCSkewBy::jsCreateClass(this->cx, cocos, "SkewBy");
S_CCAccelDeccelAmplitude::jsCreateClass(this->cx, cocos, "AccelDeccelAmplitude");
S_CCLabelAtlas::jsCreateClass(this->cx, cocos, "LabelAtlas");
S_CCAccelAmplitude::jsCreateClass(this->cx, cocos, "AccelAmplitude");
S_CCSkewTo::jsCreateClass(this->cx, cocos, "SkewTo");
S_CCShaky3D::jsCreateClass(this->cx, cocos, "Shaky3D");
S_CCSplitCols::jsCreateClass(this->cx, cocos, "SplitCols");
S_CCFadeOut::jsCreateClass(this->cx, cocos, "FadeOut");
S_CCTileMapAtlas::jsCreateClass(this->cx, cocos, "TileMapAtlas");
S_CCFadeTo::jsCreateClass(this->cx, cocos, "FadeTo");
S_CCJumpTiles3D::jsCreateClass(this->cx, cocos, "JumpTiles3D");
S_CCFadeIn::jsCreateClass(this->cx, cocos, "FadeIn");
S_CCSplitRows::jsCreateClass(this->cx, cocos, "SplitRows");
S_CCScaleBy::jsCreateClass(this->cx, cocos, "ScaleBy");
S_CCScaleTo::jsCreateClass(this->cx, cocos, "ScaleTo");
S_CCBezierTo::jsCreateClass(this->cx, cocos, "BezierTo");
S_CCTMXTiledMap::jsCreateClass(this->cx, cocos, "TMXTiledMap");
S_CCTMXLayer::jsCreateClass(this->cx, cocos, "TMXLayer");
S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine");
S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine");
// register some global functions
JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT);
// register some global functions
JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(this->cx, cocos, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT);
}
bool ScriptingCore::evalString(const char *string, jsval *outVal)
{
jsval rval;
JSString *str;
JSBool ok;
const char *filename = "noname";
uint32_t lineno = 0;
if (outVal == NULL) {
outVal = &rval;
}
ok = JS_EvaluateScript(cx, global, string, strlen(string), filename, lineno, outVal);
if (ok == JS_FALSE) {
CCLog("error evaluating script:\n%s", string);
}
str = JS_ValueToString(cx, rval);
return ok;
jsval rval;
JSString *str;
JSBool ok;
const char *filename = "noname";
uint32_t lineno = 0;
if (outVal == NULL) {
outVal = &rval;
}
ok = JS_EvaluateScript(cx, global, string, strlen(string), filename, lineno, outVal);
if (ok == JS_FALSE) {
CCLog("error evaluating script:\n%s", string);
}
str = JS_ValueToString(cx, rval);
return ok;
}
void ScriptingCore::runScript(const char *path)
{
#ifdef DEBUG
/**
* dpath should point to the parent directory of the "JS" folder. If this is
* set to "" (as it is now) then it will take the scripts from the app bundle.
* By setting the absolute path you can iterate the development only by
* modifying those scripts and reloading from the simulator (no recompiling/
* relaunching)
*/
// std::string dpath("/Users/rabarca/Desktop/testjs/testjs/");
std::string dpath("");
dpath += path;
const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str());
/**
* dpath should point to the parent directory of the "JS" folder. If this is
* set to "" (as it is now) then it will take the scripts from the app bundle.
* By setting the absolute path you can iterate the development only by
* modifying those scripts and reloading from the simulator (no recompiling/
* relaunching)
*/
// std::string dpath("/Users/rabarca/Desktop/testjs/testjs/");
std::string dpath("");
dpath += path;
const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str());
#else
const char *realPath = CCFileUtils::fullPathFromRelativePath(path);
const char *realPath = CCFileUtils::fullPathFromRelativePath(path);
#endif
const char* content = CCString::stringWithContentsOfFile(realPath)->getCString();
if (content && strlen(content) > 0) {
JSBool ok;
jsval rval;
ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval);
if (ok == JS_FALSE) {
CCLog("error evaluating script:\n%s", content);
}
}
const char* content = CCString::stringWithContentsOfFile(realPath)->getCString();
if (content && strlen(content) > 0) {
JSBool ok;
jsval rval;
ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval);
if (ok == JS_FALSE) {
CCLog("error evaluating script:\n%s", content);
}
}
}
ScriptingCore::~ScriptingCore()
{
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
JS_ShutDown();
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
JS_ShutDown();
}

View File

@ -14,129 +14,129 @@
class ScriptingCore
{
JSRuntime *rt;
JSContext *cx;
JSObject *global;
JSRuntime *rt;
JSContext *cx;
JSObject *global;
ScriptingCore();
ScriptingCore();
public:
~ScriptingCore();
~ScriptingCore();
static ScriptingCore & getInstance() {
static ScriptingCore instance;
return instance;
};
static ScriptingCore & getInstance() {
static ScriptingCore instance;
return instance;
};
/**
* will eval the specified string
* @param string The string with the javascript code to be evaluated
* @param outVal The jsval that will hold the return value of the evaluation.
* Can be NULL.
*/
bool evalString(const char *string, jsval *outVal);
/**
* will eval the specified string
* @param string The string with the javascript code to be evaluated
* @param outVal The jsval that will hold the return value of the evaluation.
* Can be NULL.
*/
bool evalString(const char *string, jsval *outVal);
/**
* will run the specified string
* @param string The path of the script to be run
*/
void runScript(const char *path);
/**
* will run the specified string
* @param string The path of the script to be run
*/
void runScript(const char *path);
/**
* @return the global context
*/
JSContext* getGlobalContext() {
return cx;
};
/**
* @return the global context
*/
JSContext* getGlobalContext() {
return cx;
};
/**
* @param cx
* @param message
* @param report
*/
static void reportError(JSContext *cx, const char *message, JSErrorReport *report)
{
fprintf(stderr, "%s:%u:%s\n",
report->filename ? report->filename : "<no filename=\"filename\">",
(unsigned int) report->lineno,
message);
};
/**
* @param cx
* @param message
* @param report
*/
static void reportError(JSContext *cx, const char *message, JSErrorReport *report)
{
fprintf(stderr, "%s:%u:%s\n",
report->filename ? report->filename : "<no filename=\"filename\">",
(unsigned int) report->lineno,
message);
};
/**
* Log something using CCLog
* @param cx
* @param argc
* @param vp
*/
static JSBool log(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc > 0) {
JSString *string = NULL;
JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string);
if (string) {
char *cstr = JS_EncodeString(cx, string);
cocos2d::CCLog(cstr);
}
}
return JS_TRUE;
};
/**
* Log something using CCLog
* @param cx
* @param argc
* @param vp
*/
static JSBool log(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc > 0) {
JSString *string = NULL;
JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string);
if (string) {
char *cstr = JS_EncodeString(cx, string);
cocos2d::CCLog(cstr);
}
}
return JS_TRUE;
};
/**
* run a script from script :)
*/
static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc == 1) {
JSString *string;
if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string) == JS_TRUE) {
ScriptingCore::getInstance().runScript(JS_EncodeString(cx, string));
}
}
return JS_TRUE;
};
/**
* run a script from script :)
*/
static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc == 1) {
JSString *string;
if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string) == JS_TRUE) {
ScriptingCore::getInstance().runScript(JS_EncodeString(cx, string));
}
}
return JS_TRUE;
};
/**
* Register an object as a member of the GC's root set, preventing
* them from being GC'ed
*/
static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc == 1) {
JSObject *o = NULL;
if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) {
if (JS_AddObjectRoot(cx, &o) == JS_FALSE) {
cocos2d::CCLog("something went wrong when setting an object to the root");
}
}
}
return JS_TRUE;
};
/**
* Register an object as a member of the GC's root set, preventing
* them from being GC'ed
*/
static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc == 1) {
JSObject *o = NULL;
if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) {
if (JS_AddObjectRoot(cx, &o) == JS_FALSE) {
cocos2d::CCLog("something went wrong when setting an object to the root");
}
}
}
return JS_TRUE;
};
/**
* removes an object from the GC's root, allowing them to be GC'ed if no
* longer referenced.
*/
static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc == 1) {
JSObject *o = NULL;
if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) {
JS_RemoveObjectRoot(cx, &o);
}
}
return JS_TRUE;
};
/**
* removes an object from the GC's root, allowing them to be GC'ed if no
* longer referenced.
*/
static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp)
{
if (argc == 1) {
JSObject *o = NULL;
if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) {
JS_RemoveObjectRoot(cx, &o);
}
}
return JS_TRUE;
};
/**
* Force a cycle of GC
* @param cx
* @param argc
* @param vp
*/
static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp)
{
JS_GC(cx);
return JS_TRUE;
};
/**
* Force a cycle of GC
* @param cx
* @param argc
* @param vp
*/
static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp)
{
JS_GC(cx);
return JS_TRUE;
};
};
#endif

View File

@ -1,379 +1,379 @@
#include "cocos2d_generated.hpp"
JSBool S_CCNode::jsaddChild(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCNode* self = NULL; JSGET_PTRSHELL(S_CCNode, self, obj);
if (self == NULL) return JS_FALSE;
if (argc >= 1) {
JSObject *arg0;
int zorder = 0;
int tag = 0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o/ii", &arg0, &zorder, &tag);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
// call the proper method
if (argc == 1) {
self->addChild(narg0);
} else if (argc == 2) {
self->addChild(narg0, zorder);
} else {
self->addChild(narg0, zorder, tag);
}
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCNode* self = NULL; JSGET_PTRSHELL(S_CCNode, self, obj);
if (self == NULL) return JS_FALSE;
if (argc >= 1) {
JSObject *arg0;
int zorder = 0;
int tag = 0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o/ii", &arg0, &zorder, &tag);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
// call the proper method
if (argc == 1) {
self->addChild(narg0);
} else if (argc == 2) {
self->addChild(narg0, zorder);
} else {
self->addChild(narg0, zorder, tag);
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCMenuItemSprite::jsinitWithNormalSprite(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItemSprite* self = NULL; JSGET_PTRSHELL(S_CCMenuItemSprite, self, obj);
if (self == NULL) return JS_FALSE;
if (argc >= 2) {
JSObject *arg0;
JSObject *arg1;
JSObject *arg2 = NULL;
JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "oo/o", &arg0, &arg1, &arg2);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
CCNode* narg1; JSGET_PTRSHELL(CCNode, narg1, arg1);
CCNode* narg2 = NULL; if (argc == 3) JSGET_PTRSHELL(CCNode, narg2, arg2);
bool ret = self->initWithNormalSprite(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemSprite::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItemSprite* self = NULL; JSGET_PTRSHELL(S_CCMenuItemSprite, self, obj);
if (self == NULL) return JS_FALSE;
if (argc >= 2) {
JSObject *arg0;
JSObject *arg1;
JSObject *arg2 = NULL;
JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "oo/o", &arg0, &arg1, &arg2);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
CCNode* narg1; JSGET_PTRSHELL(CCNode, narg1, arg1);
CCNode* narg2 = NULL; if (argc == 3) JSGET_PTRSHELL(CCNode, narg2, arg2);
bool ret = self->initWithNormalSprite(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemSprite::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCMenuItemImage::jsinitWithNormalImage(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItemImage* self = NULL; JSGET_PTRSHELL(S_CCMenuItemImage, self, obj);
if (self == NULL) return JS_FALSE;
if (argc >= 2) {
JSString *arg0;
JSString *arg1;
JSString *arg2 = NULL;
JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "SS/S", &arg0, &arg1, &arg2);
char *narg0 = JS_EncodeString(cx, arg0);
char *narg1 = JS_EncodeString(cx, arg1);
char *narg2 = (arg2) ? JS_EncodeString(cx, arg2) : NULL;
bool ret = self->initWithNormalImage(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemImage::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItemImage* self = NULL; JSGET_PTRSHELL(S_CCMenuItemImage, self, obj);
if (self == NULL) return JS_FALSE;
if (argc >= 2) {
JSString *arg0;
JSString *arg1;
JSString *arg2 = NULL;
JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "SS/S", &arg0, &arg1, &arg2);
char *narg0 = JS_EncodeString(cx, arg0);
char *narg1 = JS_EncodeString(cx, arg1);
char *narg2 = (arg2) ? JS_EncodeString(cx, arg2) : NULL;
bool ret = self->initWithNormalImage(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemImage::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCSequence::jsactions(JSContext *cx, uint32_t argc, jsval *vp) {
// just like CCSequence::actions
if (argc > 0) {
jsval* argv = JS_ARGV(cx, vp);
// get first element
S_CCSequence* prev;
JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0]));
for (int i=1; i < argc; i++) {
CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i]));
prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next);
}
// wrap prev in an action
// temporary because it's just a wrapper for an autoreleased object
// or worst case, it's an already binded object (if it's just one item in the array)
pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = prev;
JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL);
prev->jsObject = out;
JS_SetPrivate(out, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out));
return JS_TRUE;
}
JS_ReportError(cx, "must call with at least one element");
return JS_FALSE;
// just like CCSequence::actions
if (argc > 0) {
jsval* argv = JS_ARGV(cx, vp);
// get first element
S_CCSequence* prev;
JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0]));
for (int i=1; i < argc; i++) {
CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i]));
prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next);
}
// wrap prev in an action
// temporary because it's just a wrapper for an autoreleased object
// or worst case, it's an already binded object (if it's just one item in the array)
pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = prev;
JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL);
prev->jsObject = out;
JS_SetPrivate(out, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out));
return JS_TRUE;
}
JS_ReportError(cx, "must call with at least one element");
return JS_FALSE;
}
JSBool S_CCParticleSystem::jsparticleWithFile(JSContext *cx, uint32_t argc, jsval *vp) {
if (argc == 1) {
JSString *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0);
char *narg0 = JS_EncodeString(cx, arg0);
CCParticleSystem* ret = CCParticleSystemQuad::particleWithFile(narg0);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
do {
JSObject *tmp = JS_NewObject(cx, S_CCParticleSystem::jsClass, S_CCParticleSystem::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while (0);
if (argc == 1) {
JSString *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0);
char *narg0 = JS_EncodeString(cx, arg0);
CCParticleSystem* ret = CCParticleSystemQuad::particleWithFile(narg0);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
do {
JSObject *tmp = JS_NewObject(cx, S_CCParticleSystem::jsClass, S_CCParticleSystem::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while (0);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCFileUtils::jsgetFileData(JSContext *cx, uint32_t argc, jsval *vp) {
if (argc == 2) {
JSString *arg0;
JSString *arg1;
unsigned long len;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
char *narg1 = JS_EncodeString(cx, arg1);
unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
JSString *str = JS_NewStringCopyN(cx, (const char *)ret, len);
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
if (argc == 2) {
JSString *arg0;
JSString *arg1;
unsigned long len;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
char *narg1 = JS_EncodeString(cx, arg1);
unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
JSString *str = JS_NewStringCopyN(cx, (const char *)ret, len);
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCFileUtils::jsfullPathFromRelativePath(JSContext *cx, uint32_t argc, jsval *vp) {
if (argc == 1) {
JSString *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0);
char *narg0 = JS_EncodeString(cx, arg0);
const char *ret = CCFileUtils::fullPathFromRelativePath(narg0);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret));
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
if (argc == 1) {
JSString *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0);
char *narg0 = JS_EncodeString(cx, arg0);
const char *ret = CCFileUtils::fullPathFromRelativePath(narg0);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret));
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCFileUtils::jsfullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp) {
if (argc == 2) {
JSString *arg0;
JSString *arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
char *narg1 = JS_EncodeString(cx, arg1);
const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret));
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));
return JS_TRUE;
if (argc == 2) {
JSString *arg0;
JSString *arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
char *narg1 = JS_EncodeString(cx, arg1);
const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret));
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str));
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCLabelTTF::jslabelWithString(JSContext *cx, uint32_t argc, jsval *vp) {
if (argc == 5) {
JSString *arg0;
JSObject *arg1;
int arg2;
JSString *arg3;
double arg4;
JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4);
char *narg0 = JS_EncodeString(cx, arg0);
CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1);
char *narg3 = JS_EncodeString(cx, arg3);
CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
do {
JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while (0);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
if (argc == 5) {
JSString *arg0;
JSObject *arg1;
int arg2;
JSString *arg3;
double arg4;
JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4);
char *narg0 = JS_EncodeString(cx, arg0);
CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1);
char *narg3 = JS_EncodeString(cx, arg3);
CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4);
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
do {
JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while (0);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCLabelTTF::jsinitWithString(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCLabelTTF* self = NULL; JSGET_PTRSHELL(S_CCLabelTTF, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 5) {
JSString *arg0;
JSObject *arg1;
int arg2;
JSString *arg3;
double arg4;
JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4);
char *narg0 = JS_EncodeString(cx, arg0);
CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1);
char *narg3 = JS_EncodeString(cx, arg3);
bool ret = self->initWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4);
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCLabelTTF* self = NULL; JSGET_PTRSHELL(S_CCLabelTTF, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 5) {
JSString *arg0;
JSObject *arg1;
int arg2;
JSString *arg3;
double arg4;
JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4);
char *narg0 = JS_EncodeString(cx, arg0);
CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1);
char *narg3 = JS_EncodeString(cx, arg3);
bool ret = self->initWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4);
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCMenuItem::jsinit(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItem* self = NULL; JSGET_PTRSHELL(S_CCMenuItem, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 0) {
bool ret = self->initWithTarget(self, menu_selector(S_CCMenuItem::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItem* self = NULL; JSGET_PTRSHELL(S_CCMenuItem, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 0) {
bool ret = self->initWithTarget(self, menu_selector(S_CCMenuItem::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCRenderTexture::jsrenderTextureWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) {
if (argc == 2) {
int arg0;
int arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1);
CCRenderTexture* ret = CCRenderTexture::renderTextureWithWidthAndHeight(arg0, arg1);
do {
JSObject *tmp = JS_NewObject(cx, S_CCRenderTexture::jsClass, S_CCRenderTexture::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while (0);
if (argc == 2) {
int arg0;
int arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1);
CCRenderTexture* ret = CCRenderTexture::renderTextureWithWidthAndHeight(arg0, arg1);
do {
JSObject *tmp = JS_NewObject(cx, S_CCRenderTexture::jsClass, S_CCRenderTexture::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while (0);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCRenderTexture::jsinitWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 2) {
int arg0;
int arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1);
bool ret = self->initWithWidthAndHeight(arg0, arg1, kCCTexture2DPixelFormat_RGBA8888);
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 2) {
int arg0;
int arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1);
bool ret = self->initWithWidthAndHeight(arg0, arg1, kCCTexture2DPixelFormat_RGBA8888);
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCMenuItemLabel::jsitemWithLabel(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 1) {
JSObject *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction));
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
do {
JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while(0);
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 1) {
JSObject *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction));
if (ret == NULL) {
JS_SET_RVAL(cx, vp, JSVAL_NULL);
return JS_TRUE;
}
do {
JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL);
pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t));
pt->flags = kPointerTemporary;
pt->data = (void *)ret;
JS_SetPrivate(tmp, pt);
JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp));
} while(0);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCMenuItemLabel::jsinitWithLabel(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItemLabel* self = NULL; JSGET_PTRSHELL(S_CCMenuItemLabel, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 1) {
JSObject *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
bool ret = self->initWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCMenuItemLabel* self = NULL; JSGET_PTRSHELL(S_CCMenuItemLabel, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 1) {
JSObject *arg0;
JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0);
CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0);
bool ret = self->initWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction));
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCApplication::jsgetCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
CCApplication* self = NULL; JSGET_PTRSHELL(CCApplication, self, obj);
if (self == NULL) return JS_FALSE;
jsval result; JS_NewNumberValue(cx, self->getCurrentLanguage(), &result);
JS_SET_RVAL(cx, vp, result);
return JS_TRUE;
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
CCApplication* self = NULL; JSGET_PTRSHELL(CCApplication, self, obj);
if (self == NULL) return JS_FALSE;
jsval result; JS_NewNumberValue(cx, self->getCurrentLanguage(), &result);
JS_SET_RVAL(cx, vp, result);
return JS_TRUE;
}
JSBool S_CCUserDefault::jsgetStringForKey(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 2) {
JSString *arg0;
JSString *arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
std::string narg1(JS_EncodeString(cx, arg1));
std::string ret = self->getStringForKey(narg0, narg1);
JSString *jsret = JS_NewStringCopyZ(cx, ret.c_str());
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(jsret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 2) {
JSString *arg0;
JSString *arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
std::string narg1(JS_EncodeString(cx, arg1));
std::string ret = self->getStringForKey(narg0, narg1);
JSString *jsret = JS_NewStringCopyZ(cx, ret.c_str());
JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(jsret));
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JSBool S_CCUserDefault::jssetStringForKey(JSContext *cx, uint32_t argc, jsval *vp) {
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 2) {
JSString *arg0;
JSString *arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
std::string narg1(JS_EncodeString(cx, arg1));
self->setStringForKey(narg0, narg1);
JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp);
S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj);
if (self == NULL) return JS_FALSE;
if (argc == 2) {
JSString *arg0;
JSString *arg1;
JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1);
char *narg0 = JS_EncodeString(cx, arg0);
std::string narg1(JS_EncodeString(cx, arg1));
self->setStringForKey(narg0, narg1);
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}
JS_SET_RVAL(cx, vp, JSVAL_TRUE);
return JS_TRUE;
}

View File

@ -1 +1 @@
215941887bb3ecde65ca64e6e1b5ddaacded6a7c
5a1155c9dcd8585864efa8080d8fd42059f9ea52

View File

@ -7,40 +7,40 @@ LOCAL_MODULE_FILENAME := liblua
LOCAL_SRC_FILES :=../../lua/lapi.c \
../../lua/lauxlib.c \
../../lua/lbaselib.c \
../../lua/lcode.c \
../../lua/ldblib.c \
../../lua/ldebug.c \
../../lua/ldo.c \
../../lua/ldump.c \
../../lua/lfunc.c \
../../lua/lgc.c \
../../lua/linit.c \
../../lua/liolib.c \
../../lua/llex.c \
../../lua/lmathlib.c \
../../lua/lmem.c \
../../lua/loadlib.c \
../../lua/lobject.c \
../../lua/lopcodes.c \
../../lua/loslib.c \
../../lua/lparser.c \
../../lua/lstate.c \
../../lua/lstring.c \
../../lua/lstrlib.c \
../../lua/ltable.c \
../../lua/ltablib.c \
../../lua/ltm.c \
../../lua/lua.c \
../../lua/lundump.c \
../../lua/lvm.c \
../../lua/lzio.c \
../../lua/print.c \
../../tolua/tolua_event.c \
../../tolua/tolua_is.c \
../../tolua/tolua_map.c \
../../tolua/tolua_push.c \
../../tolua/tolua_to.c
../../lua/lbaselib.c \
../../lua/lcode.c \
../../lua/ldblib.c \
../../lua/ldebug.c \
../../lua/ldo.c \
../../lua/ldump.c \
../../lua/lfunc.c \
../../lua/lgc.c \
../../lua/linit.c \
../../lua/liolib.c \
../../lua/llex.c \
../../lua/lmathlib.c \
../../lua/lmem.c \
../../lua/loadlib.c \
../../lua/lobject.c \
../../lua/lopcodes.c \
../../lua/loslib.c \
../../lua/lparser.c \
../../lua/lstate.c \
../../lua/lstring.c \
../../lua/lstrlib.c \
../../lua/ltable.c \
../../lua/ltablib.c \
../../lua/ltm.c \
../../lua/lua.c \
../../lua/lundump.c \
../../lua/lvm.c \
../../lua/lzio.c \
../../lua/print.c \
../../tolua/tolua_event.c \
../../tolua/tolua_is.c \
../../tolua/tolua_map.c \
../../tolua/tolua_push.c \
../../tolua/tolua_to.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../lua \
$(LOCAL_PATH)/../../tolua \

View File

@ -31,7 +31,7 @@ bool AppDelegate::applicationDidFinishLaunching()
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// turn on display FPS
@ -52,7 +52,7 @@ bool AppDelegate::applicationDidFinishLaunching()
pEngine->executeString(pstrFileContent->getCString());
}
#else
std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
pEngine->executeScriptFile(path.c_str());
#endif

View File

@ -4,7 +4,7 @@
#include "CCApplication.h"
/**
@brief The cocos2d Application.
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
@ -15,7 +15,7 @@ public:
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement CCDirector and CCScene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -8,12 +8,12 @@ USING_NS_CC;
// #define USE_WIN32_CONSOLE
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
#ifdef USE_WIN32_CONSOLE
AllocConsole();
@ -22,13 +22,13 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
freopen("CONOUT$", "w", stderr);
#endif
// create the application instance
AppDelegate app;
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
eglView.setViewName("Hello World");
eglView.setFrameSize(480, 320);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// eglView.setDesignResolutionSize(480, 320);
// create the application instance
AppDelegate app;
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
eglView.setViewName("Hello World");
eglView.setFrameSize(480, 320);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// eglView.setDesignResolutionSize(480, 320);
int ret = CCApplication::sharedApplication().run();

View File

@ -10,4 +10,4 @@
// C RunTime Header Files
#include "CCStdC.h"
#endif // __WINMAIN_H__
#endif // __WINMAIN_H__

View File

@ -4,19 +4,19 @@
//
[!if WTL_COM_SERVER]
#define IDS_PROJNAME 100
#define IDR_[!output UPPERCASE_SAFE_PROJECT_NAME] 100
#define IDS_PROJNAME 100
#define IDR_[!output UPPERCASE_SAFE_PROJECT_NAME] 100
[!endif]
#define ID_FILE_NEW_WINDOW 32771
#define ID_FILE_NEW_WINDOW 32771
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 32775
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 32775
#endif
#endif

View File

@ -25,45 +25,45 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView());
// enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices.
// pDirector->enableRetinaDisplay(true);
// sets landscape mode
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// sets landscape mode
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
// turn on display FPS
pDirector->setDisplayStats(true);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// add our generated bindings
// add our generated bindings
/*
JSContext *cx = ScriptingCore::getInstance().getGlobalContext();
JSObject *obj = JS_GetGlobalObject(cx);
// since we pass the global object as the second argument, so these classes
// will also be "global" much like properties added to "window" or "document"
// in a browser
S_SimpleNativeClass::jsCreateClass(cx, obj, "SimpleNativeClass");
S_AnotherClass::jsCreateClass(cx, obj, "AnotherClass");
register_enums_simple_native_generated(obj);
JSContext *cx = ScriptingCore::getInstance().getGlobalContext();
JSObject *obj = JS_GetGlobalObject(cx);
// since we pass the global object as the second argument, so these classes
// will also be "global" much like properties added to "window" or "document"
// in a browser
S_SimpleNativeClass::jsCreateClass(cx, obj, "SimpleNativeClass");
S_AnotherClass::jsCreateClass(cx, obj, "AnotherClass");
register_enums_simple_native_generated(obj);
ScriptingCore::getInstance().runScript("Javascript/1to1/test_bindings.js");
*/
// run the main script
ScriptingCore::getInstance().runScript("JS/1to1/test_actions.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_ease_actions.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_particles.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_layer.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js");
// run the main script
ScriptingCore::getInstance().runScript("JS/1to1/test_actions.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_ease_actions.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_particles.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_layer.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js");
// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js");
return true;
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
@ -71,8 +71,8 @@ void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
@ -80,6 +80,6 @@ void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -13,18 +13,18 @@
#include "ScriptingCore.h"
/**
@brief The cocos2d Application.
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
class AppDelegate : private cocos2d::CCApplication
{
public:
AppDelegate();
virtual ~AppDelegate();
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@brief Implement CCDirector and CCScene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/

View File

@ -7,10 +7,10 @@
SimpleNativeClass::SimpleNativeClass()
{
// just set some fields
m_someField = 0;
m_someOtherField = 10;
m_anotherMoreComplexField = NULL;
// just set some fields
m_someField = 0;
m_someOtherField = 10;
m_anotherMoreComplexField = NULL;
}
// empty destructor
@ -21,25 +21,25 @@ SimpleNativeClass::~SimpleNativeClass()
// just a very simple function :)
int SimpleNativeClass::doSomeProcessing(std::string arg1, std::string arg2)
{
return arg1.length() + arg2.length();
return arg1.length() + arg2.length();
}
void SimpleNativeClass::setAnotherMoreComplexField(const char *str)
{
if (m_anotherMoreComplexField) {
free(m_anotherMoreComplexField);
}
size_t len = strlen(str);
m_anotherMoreComplexField = (char *)malloc(len);
memcpy(m_anotherMoreComplexField, str, len);
if (m_anotherMoreComplexField) {
free(m_anotherMoreComplexField);
}
size_t len = strlen(str);
m_anotherMoreComplexField = (char *)malloc(len);
memcpy(m_anotherMoreComplexField, str, len);
}
namespace SomeNamespace
{
AnotherClass::AnotherClass()
{
justOneField = 1313;
aPublicField = 1337;
justOneField = 1313;
aPublicField = 1337;
}
// empty destructor
AnotherClass::~AnotherClass()
@ -47,6 +47,6 @@ AnotherClass::~AnotherClass()
}
void AnotherClass::doSomethingSimple() {
fprintf(stderr, "just doing something simple\n");
fprintf(stderr, "just doing something simple\n");
}
};

View File

@ -6,57 +6,57 @@
class SimpleNativeClass
{
protected:
int m_someField;
int m_someOtherField;
char* m_anotherMoreComplexField;
int m_someField;
int m_someOtherField;
char* m_anotherMoreComplexField;
public:
SimpleNativeClass();
~SimpleNativeClass();
SimpleNativeClass();
~SimpleNativeClass();
// these methods are simple, can be defined inline
int getSomeField() {
return m_someField;
};
int getSomeOtherField() {
return m_someOtherField;
};
char *getAnotherMoreComplexField() {
return m_anotherMoreComplexField;
}
void setSomeField(int f) {
m_someField = f;
}
void setSomeOtherField(int f) {
m_someOtherField = f;
}
void setAnotherMoreComplexField(const char *str);
// these methods are simple, can be defined inline
int getSomeField() {
return m_someField;
};
int getSomeOtherField() {
return m_someOtherField;
};
char *getAnotherMoreComplexField() {
return m_anotherMoreComplexField;
}
void setSomeField(int f) {
m_someField = f;
}
void setSomeOtherField(int f) {
m_someOtherField = f;
}
void setAnotherMoreComplexField(const char *str);
// std::string not working yet!
int doSomeProcessing(std::string arg1, std::string arg2);
// std::string not working yet!
int doSomeProcessing(std::string arg1, std::string arg2);
};
namespace SomeNamespace {
class AnotherClass {
protected:
int justOneField;
int justOneField;
public:
int aPublicField;
int aPublicField;
AnotherClass();
~AnotherClass();
AnotherClass();
~AnotherClass();
// also simple methods, can be defined inline
int getJustOneField() {
return justOneField;
}
// wrong setter - won't work (needs ONLY one parameter in order to work)
void setJustOneField() {
justOneField = 999;
}
// also simple methods, can be defined inline
int getJustOneField() {
return justOneField;
}
// wrong setter - won't work (needs ONLY one parameter in order to work)
void setJustOneField() {
justOneField = 999;
}
void doSomethingSimple();
void doSomethingSimple();
};
};

View File

@ -10,7 +10,7 @@
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
RootViewController *viewController;
}
@end

View File

@ -56,14 +56,14 @@ static AppDelegate s_sharedApplication;
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::CCDirector::sharedDirector()->pause();
cocos2d::CCDirector::sharedDirector()->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::CCDirector::sharedDirector()->resume();
cocos2d::CCDirector::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {

View File

@ -36,10 +36,10 @@
*/
// Override to allow orientations other than the default landscape orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
// switch to this line if you want to set portrait view
// return UIInterfaceOrientationIsPortrait( interfaceOrientation );
// return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}
- (void)didReceiveMemoryWarning {

View File

@ -8,12 +8,12 @@ USING_NS_CC;
// #define USE_WIN32_CONSOLE
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
#ifdef USE_WIN32_CONSOLE
AllocConsole();
@ -22,13 +22,13 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
freopen("CONOUT$", "w", stderr);
#endif
// create the application instance
AppDelegate app;
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
eglView.setViewName("Hello World");
eglView.setFrameSize(480, 320);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// eglView.setDesignResolutionSize(480, 320);
// create the application instance
AppDelegate app;
CCEGLView& eglView = CCEGLView::sharedOpenGLView();
eglView.setViewName("Hello World");
eglView.setFrameSize(480, 320);
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
// eglView.setDesignResolutionSize(480, 320);
int ret = CCApplication::sharedApplication().run();

View File

@ -10,4 +10,4 @@
// C RunTime Header Files
#include "CCStdC.h"
#endif // __WINMAIN_H__
#endif // __WINMAIN_H__

View File

@ -3,18 +3,18 @@
// Used by testjs.RC
//
#define IDS_PROJNAME 100
#define IDR_TESTJS 100
#define IDS_PROJNAME 100
#define IDR_TESTJS 100
#define ID_FILE_NEW_WINDOW 32771
#define ID_FILE_NEW_WINDOW 32771
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 32775
#define _APS_NEXT_RESOURCE_VALUE 201
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 32775
#endif
#endif

View File

@ -36,7 +36,7 @@ void CocosBuilderTestScene::runThisTest()
HelloCocosBuilder::createInstance);
CCNode* node = CCBReader::nodeGraphFromFile("CocosBuilder_v2/example_relativeposition.ccb");
this->addChild(node) ;
this->addChild(node) ;
CCDirector::sharedDirector()->replaceScene(this);
}

View File

@ -5,7 +5,7 @@ subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \
cocos2dx \
CocosDenshion/android \
lua/proj.android/jni \
))
))
subdirs += $(LOCAL_PATH)/LuaProjectTemplate/Android.mk
include $(subdirs)

View File

@ -25,9 +25,9 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \
# because the new Windows toolchain doesn't support Cygwin's drive
# mapping (i.e /cygdrive/c/ instead of C:/)
LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \
-L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \
-lcocos2d \
-lcocosdenshion \
-llua
-L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \
-lcocos2d \
-lcocosdenshion \
-llua
include $(BUILD_SHARED_LIBRARY)