forked from cocos2d/cocos2d-x
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ios] issue cocos2d#538, add xcode4 template for lua project
- Loading branch information
Walzer
committed
Jun 23, 2011
1 parent
c1d985c
commit 0b134e9
Showing
12 changed files
with
1,218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#endif |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions
127
template/xcode4/cocos2d_lua.xctemplate/Resources/hello.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
g_Scene = cocos2d.CCScene:node() | ||
pSprite = cocos2d.CCSprite:spriteWithFile("90001.jpg") | ||
pSprite:setPosition(cocos2d.CCPoint(300, 400)) | ||
|
||
pLayer = cocos2d.CCLayer:node() | ||
pLayer:setIsTouchEnabled(true) | ||
pLayer:setAnchorPoint(cocos2d.CCPoint(0,0)) | ||
pLayer:setPosition( cocos2d.CCPoint(0, -300) ) | ||
pLayer:addChild(pSprite) | ||
g_Scene:addChild(pLayer) | ||
|
||
function btnTouchMove(e) | ||
cocos2d.CCLuaLog("mousemove") | ||
end | ||
|
||
function btnTouchBegin(e) | ||
cocos2d.CCLuaLog("btnTouchBegin") | ||
end | ||
|
||
function btnTouchEnd(e) | ||
cocos2d.CCLuaLog("btnTouchEnd") | ||
end | ||
|
||
-- regiester touch handler | ||
pLayer.__CCTouchDelegate__:registerScriptTouchHandler(cocos2d.CCTOUCHBEGAN, "btnTouchBegin") | ||
pLayer.__CCTouchDelegate__:registerScriptTouchHandler(cocos2d.CCTOUCHMOVED, "btnTouchMove") | ||
pLayer.__CCTouchDelegate__:registerScriptTouchHandler(cocos2d.CCTOUCHENDED, "btnTouchEnd") | ||
|
||
-- add a menu | ||
menuItem = cocos2d.CCMenuItemImage:itemFromNormalImage("menu2.png", "menu2.png") | ||
menuItem:setAnchorPoint(cocos2d.CCPoint(0,0)) | ||
menuItem:setPosition( cocos2d.CCPoint(100, 200) ) | ||
menuItem:registerScriptHandler("CloseMenu") | ||
pMenu = cocos2d.CCMenu:menuWithItem(menuItem) | ||
pMenu:setPosition( cocos2d.CCPoint(1000, 200) ) | ||
g_Scene:addChild(pMenu) | ||
|
||
function CloseMenu() | ||
pMenu:setPosition(cocos2d.CCPoint(1000, 200) ) | ||
end | ||
|
||
function PopMenu() | ||
pMenu:setPosition( cocos2d.CCPoint(0, -100) ) | ||
end | ||
|
||
pCloseItem = cocos2d.CCMenuItemImage:itemFromNormalImage("menu1.png","menu1.png") | ||
pCloseItem:setPosition( cocos2d.CCPoint(30, 40) ) | ||
pCloseItem:registerScriptHandler("PopMenu") | ||
pcloseMenu = cocos2d.CCMenu:menuWithItem(pCloseItem) | ||
pcloseMenu:setPosition( cocos2d.CCPoint(30, 40) ) | ||
g_Scene:addChild(pcloseMenu) | ||
|
||
for i=0,3,1 do | ||
for j=0,1,1 do | ||
|
||
landSprite = cocos2d.CCSprite:spriteWithFile("land1.png") | ||
pLayer:addChild(landSprite) | ||
|
||
landSprite:setAnchorPoint(cocos2d.CCPoint(0,0)) | ||
landSprite:setPosition(cocos2d.CCPoint(90+j*180 - i%2*90, 200+i*95/2)) | ||
|
||
end | ||
end | ||
|
||
|
||
|
||
--crop | ||
|
||
for i=0,3,1 do | ||
for j=0,1,1 do | ||
|
||
texturecrop = cocos2d.CCTextureCache:sharedTextureCache():addImage("crop1.png") | ||
framecrop = cocos2d.CCSpriteFrame:frameWithTexture(texturecrop, cocos2d.CCRectMake(0, 0, 105, 95)) | ||
spritecrop = cocos2d.CCSprite:spriteWithSpriteFrame(framecrop); | ||
|
||
pLayer:addChild(spritecrop) | ||
|
||
spritecrop:setAnchorPoint(cocos2d.CCPoint(0,0)) | ||
spritecrop:setPosition(cocos2d.CCPoint(45+90+j*180 - i%2*90, 25+200+i*95/2)) | ||
|
||
end | ||
end | ||
|
||
|
||
|
||
|
||
nFrameWidth = 105 | ||
nFrameHeight = 95 | ||
|
||
texture = cocos2d.CCTextureCache:sharedTextureCache():addImage("dog1.png") | ||
frame0 = cocos2d.CCSpriteFrame:frameWithTexture(texture, cocos2d.CCRectMake(0, 0, nFrameWidth, nFrameHeight)) | ||
frame1 = cocos2d.CCSpriteFrame:frameWithTexture(texture, cocos2d.CCRectMake(nFrameWidth*1, 0, nFrameWidth, nFrameHeight)) | ||
|
||
spritedog = cocos2d.CCSprite:spriteWithSpriteFrame(frame0) | ||
spritedog:setPosition(cocos2d.CCPoint(300, 500)) | ||
pLayer:addChild(spritedog) | ||
|
||
|
||
animFrames = cocos2d.CCMutableArray_CCSpriteFrame__:new(2) | ||
|
||
animFrames:addObject(frame0) | ||
animFrames:addObject(frame1) | ||
|
||
animation = cocos2d.CCAnimation:animationWithName("wait", 0.5, animFrames) | ||
|
||
animate = cocos2d.CCAnimate:actionWithAnimation(animation, false); | ||
spritedog:runAction(cocos2d.CCRepeatForever:actionWithAction(animate)) | ||
|
||
cocos2d.CCDirector:sharedDirector():runWithScene(g_Scene) | ||
|
||
function tick() | ||
|
||
point = cocos2d.CCPoint(300, 500); | ||
point = spritedog:getPosition(); | ||
|
||
if point.x > 600 then | ||
point.x = 0 | ||
spritedog:setPosition(point) | ||
else | ||
point.x = point.x + 1 | ||
spritedog:setPosition(point) | ||
end | ||
|
||
end | ||
|
||
cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc("tick", 0.01, false) | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
159 changes: 159 additions & 0 deletions
159
template/xcode4/cocos2d_lua.xctemplate/TemplateInfo.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>Ancestors</key> | ||
<array> | ||
<string>org.cocos2d-x.bundlebase</string> | ||
<string>org.cocos2d-x.iosbase</string> | ||
<string>org.cocos2d-x.libcocos2dx</string> | ||
<string>org.cocos2d-x.libcocosdenshion</string> | ||
<string>org.cocos2d-x.liblua</string> | ||
</array> | ||
<key>Concrete</key> | ||
<true/> | ||
<key>Definitions</key> | ||
<dict> | ||
<key>Classes/AppDelegate.cpp</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Classes</string> | ||
<key>Path</key> | ||
<string>Classes/AppDelegate.cpp</string> | ||
</dict> | ||
<key>Classes/AppDelegate.h</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Classes</string> | ||
<key>Path</key> | ||
<string>Classes/AppDelegate.h</string> | ||
<key>TargetIndices</key> | ||
<array/> | ||
</dict> | ||
<key>ios/AppController.h</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>ios</string> | ||
<key>Path</key> | ||
<string>ios/AppController.h</string> | ||
<key>TargetIndices</key> | ||
<array/> | ||
</dict> | ||
<key>ios/AppController.mm</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>ios</string> | ||
<key>Path</key> | ||
<string>ios/AppController.mm</string> | ||
</dict> | ||
<key>ios/main.m</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>ios</string> | ||
<key>Path</key> | ||
<string>ios/main.m</string> | ||
</dict> | ||
<key>Prefix.pch</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Supporting Files</string> | ||
<key>Path</key> | ||
<string>Prefix.pch</string> | ||
<key>TargetIndices</key> | ||
<array/> | ||
</dict> | ||
|
||
<key>Resources/90001.jpg</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/90001.jpg</string> | ||
</dict> | ||
<key>Resources/crop1.png</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/crop1.png</string> | ||
</dict> | ||
<key>Resources/dog1.png</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/dog1.png</string> | ||
</dict> | ||
<key>Resources/hello.lua</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/hello.lua</string> | ||
</dict> | ||
<key>Resources/land1.png</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/land1.png</string> | ||
</dict> | ||
<key>Resources/menu1.png</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/menu1.png</string> | ||
</dict> | ||
<key>Resources/menu2.png</key> | ||
<dict> | ||
<key>Group</key> | ||
<string>Resources</string> | ||
<key>Path</key> | ||
<string>Resources/menu2.png</string> | ||
</dict> | ||
</dict> | ||
<key>Description</key> | ||
<string>This template provides a starting point for an application that uses cocos2d-x for iOS, including CocosDenshion </string> | ||
<key>Identifier</key> | ||
<string>org.cocos2d-x.cocos2dxOnlyIOSTemplate</string> | ||
<key>Kind</key> | ||
<string>Xcode.Xcode3.ProjectTemplateUnitKind</string> | ||
<key>Nodes</key> | ||
<array> | ||
<string>Prefix.pch</string> | ||
<string>ios/main.m</string> | ||
<string>ios/AppController.h</string> | ||
<string>ios/AppController.mm</string> | ||
<string>Classes/AppDelegate.h</string> | ||
<string>Classes/AppDelegate.cpp</string> | ||
<string>Resources/90001.jpg</string> | ||
<string>Resources/crop1.png</string> | ||
<string>Resources/dog1.png</string> | ||
<string>Resources/hello.lua</string> | ||
<string>Resources/land1.png</string> | ||
<string>Resources/menu1.png</string> | ||
<string>Resources/menu2.png</string> | ||
</array> | ||
<key>Options</key> | ||
<array> | ||
<dict> | ||
<key>Identifier</key> | ||
<string>deviceFamily</string> | ||
<key>Units</key> | ||
<dict> | ||
<key>iPad</key> | ||
<dict> | ||
<key>Definitions</key> | ||
<dict/> | ||
</dict> | ||
<key>iPhone</key> | ||
<dict> | ||
<key>Definitions</key> | ||
<dict/> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</array> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// main.m | ||
// HelloLua | ||
// | ||
// Copyright __MyCompanyName__ 2011. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
int main(int argc, char *argv[]) { | ||
NSAutoreleasePool *pool = [NSAutoreleasePool new]; | ||
int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); | ||
[pool release]; | ||
return retVal; | ||
} |
Oops, something went wrong.