diff --git a/install-templates-xcode.sh b/install-templates-xcode.sh index c7ed4afb85..675b44ab69 100755 --- a/install-templates-xcode.sh +++ b/install-templates-xcode.sh @@ -2,7 +2,7 @@ echo 'cocos2d-x template installer' -COCOS2D_VER='cocos2d-1.0.0-x-0.9.0' +COCOS2D_VER='cocos2d-1.0.1-x-0.9.1' BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode" BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode" diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp index cdb2f51b64..8f9c665406 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp @@ -83,7 +83,7 @@ HelloWorld::HelloWorld() //Set up sprite - CCSpriteBatchNode *mgr = CCSpriteBatchNode::spriteSheetWithFile("blocks.png", 150); + CCSpriteBatchNode *mgr = CCSpriteBatchNode::batchNodeWithFile("blocks.png", 150); addChild(mgr, 0, kTagSpriteManager); addNewSpriteWithCoords( CCPointMake(screenSize.width/2, screenSize.height/2) ); @@ -130,7 +130,8 @@ void HelloWorld::addNewSpriteWithCoords(CCPoint p) //just randomly picking one of the images int idx = (CCRANDOM_0_1() > .5 ? 0:1); int idy = (CCRANDOM_0_1() > .5 ? 0:1); - CCSprite *sprite = sheet->createSpriteWithRect( CCRectMake(32 * idx,32 * idy,32,32)); + + CCSprite *sprite = CCSprite::spriteWithBatchNode(sheet, CCRectMake(32 * idx,32 * idy,32,32)); sheet->addChild(sprite); sprite->setPosition( CCPointMake( p.x, p.y) ); diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/background.mp3.REMOVED.git-id b/template/xcode4/cocos2dx_lua.xctemplate/Resources/background.mp3.REMOVED.git-id new file mode 100644 index 0000000000..cfc16a8a4e --- /dev/null +++ b/template/xcode4/cocos2dx_lua.xctemplate/Resources/background.mp3.REMOVED.git-id @@ -0,0 +1 @@ +aec1c0a8c8068377fddca5ddd32084d8c3c3c419 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua index b0544b7a65..d14d205327 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua +++ b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua @@ -24,17 +24,17 @@ function btnTouchMove(e) local v = e[1] local pointMove = v:locationInView(v:view()) pointMove = cocos2d.CCDirector:sharedDirector():convertToGL(pointMove) - local positionCurrent = layerFarm.__CCNode__:getPosition() - layerFarm.__CCNode__:setPosition(cocos2d.CCPoint(positionCurrent.x + pointMove.x - pointBegin.x, positionCurrent.y + pointMove.y - pointBegin.y)) + local positionCurrent = layerFarm:getPosition() + layerFarm:setPosition(cocos2d.CCPoint(positionCurrent.x + pointMove.x - pointBegin.x, positionCurrent.y + pointMove.y - pointBegin.y)) pointBegin = pointMove end end function btnTouchBegin(e) + cocos2d.CCLuaLog("btnTouchBegin") for k,v in ipairs(e) do pointBegin = v:locationInView(v:view()) pointBegin = cocos2d.CCDirector:sharedDirector():convertToGL(pointBegin) - cocos2d.CCLuaLog("btnTouchBegin, x= %d, y = %d", pointBegin.x, pointBegin.y) end end @@ -91,7 +91,7 @@ animFrames = cocos2d.CCMutableArray_CCSpriteFrame__:new(2) animFrames:addObject(frame0) animFrames:addObject(frame1) -animation = cocos2d.CCAnimation:animationWithName("wait", 0.5, animFrames) +animation = cocos2d.CCAnimation:animationWithFrames(animFrames, 0.5) animate = cocos2d.CCAnimate:actionWithAnimation(animation, false); spriteDog:runAction(cocos2d.CCRepeatForever:actionWithAction(animate)) @@ -100,6 +100,8 @@ spriteDog:runAction(cocos2d.CCRepeatForever:actionWithAction(animate)) -- add a popup menu function menuCallbackClosePopup() +-- stop test sound effect +CocosDenshion.SimpleAudioEngine:sharedEngine():stopEffect(effectID) menuPopup:setIsVisible(false) end @@ -114,6 +116,9 @@ layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup function menuCallbackOpenPopup() +-- loop test sound effect +-- NOTE: effectID is global, so it can be used to stop +effectID = CocosDenshion.SimpleAudioEngine:sharedEngine():playEffect("effect1.wav") menuPopup:setIsVisible(true) end @@ -142,5 +147,7 @@ end cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc("tick", 0.01, false) -- run +-- play background music +CocosDenshion.SimpleAudioEngine:sharedEngine():playBackgroundMusic("background.mp3", true); cocos2d.CCDirector:sharedDirector():runWithScene(sceneGame)