mirror of https://github.com/axmolengine/axmol.git
Merge remote-tracking branch 'parent/gles20' into gles20
This commit is contained in:
commit
5d0bcc2bc7
|
@ -32,10 +32,12 @@ _ReSharper*/
|
|||
libs/
|
||||
bin/
|
||||
obj/
|
||||
gen/
|
||||
assets/
|
||||
.classpath
|
||||
.project
|
||||
.cproject
|
||||
#.classpath
|
||||
#.project
|
||||
#.cproject
|
||||
local.properties
|
||||
|
||||
# Ignore files build by linux
|
||||
*.o
|
||||
|
|
4
AUTHORS
4
AUTHORS
|
@ -28,6 +28,7 @@ Developers:
|
|||
|
||||
Nicolas Gramlich (nicolasgramlich, Zynga)
|
||||
fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF
|
||||
added CCBReader (CCBI format)
|
||||
|
||||
Jianfeng Zhou (NetGragon Inc)
|
||||
contributes CCListView and CCTextureWatcher.
|
||||
|
@ -86,6 +87,9 @@ Developers:
|
|||
jreitman
|
||||
fix the bug of asynchronous loading resources for iOS
|
||||
|
||||
Nat Weiss
|
||||
Minor enhancements to the Cocos2D-X codebase and Android build scripts
|
||||
|
||||
Retired Core Developers:
|
||||
WenSheng Yang
|
||||
Author of windows port, CCTextField,
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -85,7 +85,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -114,11 +114,11 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
|
87
CHANGELOG
87
CHANGELOG
|
@ -1,3 +1,90 @@
|
|||
cocos2d-2.0-rc0a-x-2.0 @May.31 2012
|
||||
[all platforms]
|
||||
Bug #1094: fix a bug that nothing will be shown when using CCParticleBatchNode
|
||||
Bug #1115: fix a bug that CCFileUtils::fullPathFromRelativePath() with resolution parameter return error value with empty string
|
||||
Bug #1137: fix a memory leak in CCLabelBMFont and sync the implementation of CCLabelBMFont to gles20 branch
|
||||
Bug #1138: fix a memory leak in CCTextureCache::addPVRImage.
|
||||
Bug #1155: revert CCDirector singleton to original implementation
|
||||
Bug #1157: fix a bug that nothing is shown in TMX Orthogonal Test
|
||||
Bug #1158: fix a bug in CCParticleSystemQuad
|
||||
Bug #1159: update "CallFuncND + auto remove" test demo
|
||||
Bug #1160: rename 'CGFloat' to 'CCFloat'
|
||||
Bug #1164: add the render mode which uses VBO without VAO in CCParticleSystemQuad
|
||||
Bug #1165: merge pull request #842
|
||||
Bug #1187: fix a bug that spanish(Buen día) cannot be shown completely in CCLabelBMFont unicode test
|
||||
Bug #1189: CCLabelBMFont updateLabel() optimizations and fixes
|
||||
Bug #1212: fix a bug that TMXBug787Test crash.
|
||||
Bug #1217: fix a bug that EaseActions reverse broken
|
||||
Bug #1232: fix a bug that CCLayerGradient::updateColor() assign wrong value to m_pSquareColors
|
||||
Bug #1244: fix memory leak in CCParticleSystem::initWithDictionary()
|
||||
Bug #1273: fix a bug that app will crash after clicking closed button in TextureCacheTest
|
||||
Bug #1275: fix memory leaks in tests project
|
||||
Bug #1277: implement CCToggleVisibility::copyWithZone()
|
||||
Feature #1114: integrate CCControlExtension and implement corresponding tests
|
||||
Feature #1180: synchronize CCConfiguration
|
||||
Feature #1194: merge texturewatcher contributed by NetGragon
|
||||
Feature #1205: add ccbreader and test case for CocosBuilder
|
||||
Feature #1240: support TIFF format picture
|
||||
Feature #1258: merge Rolando's testjs into gles20 branch
|
||||
Refactor #1156: synchronize CCDirector
|
||||
Refactor #1166: improve CCString and CCArray, optimize CCDictionary
|
||||
Refactor #1176: change linebreak symbol to UNIX format ('\n'), replace 'tab' with four spaces
|
||||
Refactor #1177: refactor platform
|
||||
Refactor #1178: use macro NS_CC_BEGIN instead of "namespace cocos2d {", NS_CC_END instead of "}"
|
||||
Refactor #1188: refactor directory structure
|
||||
Refactor #1191: update templates for all platforms
|
||||
Refactor #1198: optimize CCTextureCache::removeUnusedTextures()
|
||||
Refactor #1203: remove CCFileUtils::setResource(const char* pszZipFileName) and SimpleAudioEngine::setResource
|
||||
Refactor #1204: refactor AppDelegate::initInstance()
|
||||
Refactor #1206: remove some unused files, only supports iOS, win32 and android
|
||||
Refactor #1211: translate Chinese comments to English for CCTextureWatcher and CCListView
|
||||
Refactor #1246: fix CCDirector using CCLabelBMFont instead of CCLabelTTF
|
||||
Refactor #1252: add CCEGLViewProtocol::getFrameSize() method for getting the real screen size of device
|
||||
Refactor #1253: add static method "purgeConfiguration" for CCConfiguration to avoid memory leak
|
||||
[iOS]
|
||||
Bug #1109: add parentheses to remove Xcode warnings
|
||||
Bug #1230: fix a bug that Calculation of string width may be wrong on iOS
|
||||
Bug #1266: fix a bug that CCTextureCahce::addImageAsync() don't work correctly on iOS
|
||||
Feature #1095: IOS screen resolution support
|
||||
[android]
|
||||
Bug #1139: fix a bug that screen becomes black when backing from background
|
||||
Bug #1140: fix a bug that ParticleTest crashed
|
||||
Bug #1141: fix a bug that NodeTest crashed in StressTest1 and StressTest2
|
||||
Bug #1142: fix a bug that TouchesTest crashed
|
||||
Bug #1143: fix a bug that MenuTest crashed
|
||||
Bug #1144: fix a bug that ParallaxTest crashed
|
||||
Bug #1145: fix a bug that TileMap crashed
|
||||
Bug #1146: fix a bug that IntervalTest crashed
|
||||
Bug #1147: fix a bug that ChipmunkAccelTouchTest crashed
|
||||
Bug #1148: fix a bug that LabelTest crashed
|
||||
Bug #1149: fix a bug that SpriteTest crashed when go to second test case
|
||||
Bug #1150: fix a bug that RenderTextureTest crashed at second test case
|
||||
Bug #1151: fix a bug that Box2DTest crashed
|
||||
Bug #1152: fix a bug that PerformanceTest crashed at 1, 2, 5 test cases
|
||||
Bug #1185: fix a bug that when backing to foreground, will lost texture if it uses sprite batch node
|
||||
Bug #1216: fix JNI memory leaks
|
||||
Bug #1229: fix a bug that android port can not be compiled on ndk android-8 level
|
||||
Bug #1236: fix a bug that JniHelper::jstring2string may crash when parameter is null
|
||||
Bug #1237: fix a bug that line number message printed by CCAssert is wrong
|
||||
Bug #1279: fix a bug that NodeNonOpaqueTest can't be shown correctly
|
||||
Feature #1247: add profiler support for android
|
||||
Feature #1265: build dynamic library of spidermonkey for Android, and implement testjs for android
|
||||
Refactor #1179: popup a message box when invoking CCAssert() on Android
|
||||
Refactor #1201: simplify the usage of writing Android.mk
|
||||
[windows]
|
||||
Bug #1215: fix a bug that Win32 retina cannot work
|
||||
Bug #1251: add CocosBuilderTest to the test project for VS2008
|
||||
Bug #1264: fix wrong string alignment when using utf-8 encoded text with CCLabelTTF
|
||||
Bug #1268: fix a bug that Testjs will crash after clicking the close button on win32
|
||||
Bug #1270: fix some warning on win32
|
||||
Feature #1186: add console window for Win32 application, all debug message output to this console window
|
||||
Feature #1263: build dynamic library of spidermonkey for win32, and add testjs project to solution
|
||||
Refactor #1170: remove win32 template of wophone
|
||||
[lua]
|
||||
Refactor #1190: update lua binding to 2.0
|
||||
Refactor #1220: using CCString::stringWithContentsOfFile to get string from lua script files
|
||||
|
||||
|
||||
cocos2d-1.0.1-x-0.12.0 @ Mar.5 2012
|
||||
[all platforms]
|
||||
Bug #925: rename HelloWorld/Resource to HelloWorld/Resources
|
||||
|
|
|
@ -11,10 +11,9 @@ jni/SimpleAudioEngineJni.cpp
|
|||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \
|
||||
$(LOCAL_PATH)/../../cocos2dx \
|
||||
$(LOCAL_PATH)/../../cocos2dx/include \
|
||||
$(LOCAL_PATH)/../../cocos2dx/platform \
|
||||
$(LOCAL_PATH)/../../cocos2dx/platform/android \
|
||||
$(LOCAL_PATH)/../../cocos2dx/platform/android/jni
|
||||
$(LOCAL_PATH)/../../cocos2dx/platform/android
|
||||
|
||||
LOCAL_LDLIBS := -llog
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "SimpleAudioEngineJni.h"
|
||||
#include "JniHelper.h"
|
||||
#include "platform/android/jni/JniHelper.h"
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ typedef enum {
|
|||
BOOL mute;
|
||||
BOOL enabled_;
|
||||
BOOL backgroundMusic;
|
||||
// whether background music is paused
|
||||
BOOL paused;
|
||||
@public
|
||||
BOOL systemPaused;//Used for auto resign handling
|
||||
NSTimeInterval systemPauseLocation;//Used for auto resign handling
|
||||
|
@ -111,6 +113,7 @@ typedef enum {
|
|||
@property (assign) id<CDLongAudioSourceDelegate> delegate;
|
||||
/* This long audio source functions as background music */
|
||||
@property (readwrite, nonatomic) BOOL backgroundMusic;
|
||||
@property (readonly) BOOL paused;
|
||||
|
||||
/** Loads the file into the audio source */
|
||||
-(void) load:(NSString*) filePath;
|
||||
|
|
|
@ -39,7 +39,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
|||
|
||||
@implementation CDLongAudioSource
|
||||
|
||||
@synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic;
|
||||
@synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic, paused;
|
||||
|
||||
-(id) init {
|
||||
if ((self = [super init])) {
|
||||
|
@ -47,6 +47,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
|||
volume = 1.0f;
|
||||
mute = NO;
|
||||
enabled_ = YES;
|
||||
paused = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -94,6 +95,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
|||
-(void) play {
|
||||
if (enabled_) {
|
||||
self->systemPaused = NO;
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer play];
|
||||
} else {
|
||||
CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled");
|
||||
|
@ -101,18 +103,22 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
|
|||
}
|
||||
|
||||
-(void) stop {
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer stop];
|
||||
}
|
||||
|
||||
-(void) pause {
|
||||
self->paused = YES;
|
||||
[audioSourcePlayer pause];
|
||||
}
|
||||
|
||||
-(void) rewind {
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer setCurrentTime:0];
|
||||
}
|
||||
|
||||
-(void) resume {
|
||||
self->paused = NO;
|
||||
[audioSourcePlayer play];
|
||||
}
|
||||
|
||||
|
@ -542,16 +548,17 @@ static BOOL configured = FALSE;
|
|||
{
|
||||
[self.backgroundMusic load:filePath];
|
||||
|
||||
if (!willPlayBackgroundMusic || _mute) {
|
||||
CDLOGINFO(@"Denshion::CDAudioManager - play bgm aborted because audio is not exclusive or sound is muted");
|
||||
return;
|
||||
}
|
||||
|
||||
if (loop) {
|
||||
[self.backgroundMusic setNumberOfLoops:-1];
|
||||
} else {
|
||||
[self.backgroundMusic setNumberOfLoops:0];
|
||||
}
|
||||
|
||||
if (!willPlayBackgroundMusic || _mute) {
|
||||
CDLOGINFO(@"Denshion::CDAudioManager - play bgm aborted because audio is not exclusive or sound is muted");
|
||||
return;
|
||||
}
|
||||
|
||||
[self.backgroundMusic play];
|
||||
}
|
||||
|
||||
|
@ -572,6 +579,10 @@ static BOOL configured = FALSE;
|
|||
return;
|
||||
}
|
||||
|
||||
if (![self.backgroundMusic paused]) {
|
||||
return;
|
||||
}
|
||||
|
||||
[self.backgroundMusic resume];
|
||||
}
|
||||
|
||||
|
@ -713,7 +724,7 @@ static BOOL configured = FALSE;
|
|||
[self audioSessionResumed];
|
||||
}
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
|
||||
#if __CC_PLATFORM_IOS >= 40000
|
||||
-(void) endInterruptionWithFlags:(NSUInteger)flags {
|
||||
CDLOGINFO(@"Denshion::CDAudioManager - interruption ended with flags %i",flags);
|
||||
if (flags == AVAudioSessionInterruptionFlags_ShouldResume) {
|
||||
|
|
|
@ -88,6 +88,7 @@ void* CDloadWaveAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outD
|
|||
theData = malloc(dataSize);
|
||||
if (theData)
|
||||
{
|
||||
memset(theData, 0, dataSize);
|
||||
AudioFileReadBytes(afid, false, 0, &dataSize, theData);
|
||||
if(err == noErr)
|
||||
{
|
||||
|
@ -195,6 +196,7 @@ void* CDloadCafAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDa
|
|||
theData = malloc(dataSize);
|
||||
if (theData)
|
||||
{
|
||||
memset(theData, 0, dataSize);
|
||||
AudioBufferList theDataBuffer;
|
||||
theDataBuffer.mNumberBuffers = 1;
|
||||
theDataBuffer.mBuffers[0].mDataByteSize = dataSize;
|
||||
|
|
|
@ -975,7 +975,7 @@ static BOOL _mixerRateSet = NO;
|
|||
return;
|
||||
}
|
||||
alSourcePause(sourceId);
|
||||
alGetError();//Clear error in case we stopped any sounds that couldn't be paused
|
||||
alGetError();//Clear error in case we pause any sounds that couldn't be paused
|
||||
}
|
||||
|
||||
- (void) pauseAllSounds {
|
||||
|
@ -989,6 +989,15 @@ static BOOL _mixerRateSet = NO;
|
|||
if (!functioning_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only resume a sound id that is paused
|
||||
ALint state;
|
||||
alGetSourcei(soundId, AL_SOURCE_STATE, &state);
|
||||
if (state != AL_PAUSED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
alSourcePlay(soundId);
|
||||
alGetError();//Clear error in case we stopped any sounds that couldn't be resumed
|
||||
}
|
||||
|
@ -1372,8 +1381,7 @@ static BOOL _mixerRateSet = NO;
|
|||
-(id) init:(int) theSoundId filePath:(const NSString *) theFilePath {
|
||||
if ((self = [super init])) {
|
||||
soundId = theSoundId;
|
||||
filePath = [theFilePath copy];//TODO: is retain necessary or does copy set retain count
|
||||
[filePath retain];
|
||||
filePath = [theFilePath copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ MciPlayer::MciPlayer()
|
|||
wc.lpszMenuName = NULL; // We Don't Want A Menu
|
||||
wc.lpszClassName = WIN_CLASS_NAME; // Set The Class Name
|
||||
|
||||
if (! RegisterClass(&wc) // 注册 窗口类 失败
|
||||
&& 1410 != GetLastError()) // 并且失败的原因不是窗口类已注册
|
||||
if (! RegisterClass(&wc)
|
||||
&& 1410 != GetLastError())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "cocos2d.h"
|
||||
#include "AppDelegate.h"
|
||||
#include "SimpleAudioEngine.h"
|
||||
#include "CCScriptSupport.h"
|
||||
#include "script_support/CCScriptSupport.h"
|
||||
#include "CCLuaEngine.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
@ -32,8 +32,6 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// turn on display FPS
|
||||
pDirector->setDisplayStats(true);
|
||||
|
||||
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
|
||||
// set FPS. the default value is 1.0/60 if you don't call this
|
||||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
|
@ -42,13 +40,13 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua");
|
||||
CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua");
|
||||
if (pstrFileContent)
|
||||
{
|
||||
pEngine->executeString(pstrFileContent->getCString());
|
||||
}
|
||||
#else
|
||||
std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua");
|
||||
std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua");
|
||||
pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
|
||||
pEngine->executeScriptFile(path.c_str());
|
||||
#endif
|
||||
|
@ -59,13 +57,13 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground()
|
||||
{
|
||||
CCDirector::sharedDirector()->pause();
|
||||
CCDirector::sharedDirector()->stopAnimation();
|
||||
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
}
|
||||
|
||||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground()
|
||||
{
|
||||
CCDirector::sharedDirector()->resume();
|
||||
CCDirector::sharedDirector()->startAnimation();
|
||||
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# This file is for configuration settings for your
|
||||
# application.
|
||||
#
|
||||
# The syntax is similar to windows .ini files ie
|
||||
#
|
||||
# [GroupName]
|
||||
# Setting = Value
|
||||
#
|
||||
# Which can be read by your application using
|
||||
# e.g s3eConfigGetString("GroupName", "Setting", string)
|
||||
#
|
||||
# All settings must be documented in .config.txt files.
|
||||
# New settings specific to this application should be
|
||||
# documented in app.config.txt
|
||||
#
|
||||
# Some conditional operations are also permitted, see the
|
||||
# S3E documentation for details.
|
||||
|
||||
[S3E]
|
||||
MemSize=12000000
|
|
@ -22,22 +22,22 @@ local function creatDog()
|
|||
-- create dog animate
|
||||
local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png")
|
||||
local rect = CCRectMake(0, 0, frameWidth, frameHeight)
|
||||
local frame0 = CCSpriteFrame:frameWithTexture(textureDog, rect)
|
||||
local frame0 = CCSpriteFrame:create(textureDog, rect)
|
||||
rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight)
|
||||
local frame1 = CCSpriteFrame:frameWithTexture(textureDog, rect)
|
||||
local frame1 = CCSpriteFrame:create(textureDog, rect)
|
||||
|
||||
local spriteDog = CCSprite:spriteWithSpriteFrame(frame0)
|
||||
local spriteDog = CCSprite:create(frame0)
|
||||
spriteDog.isPaused = false
|
||||
spriteDog:setPosition(0, winSize.height / 4 * 3)
|
||||
|
||||
local animFrames = CCArray:arrayWithCapacity(2)
|
||||
local animFrames = CCArray:create(2)
|
||||
|
||||
animFrames:addObject(frame0)
|
||||
animFrames:addObject(frame1)
|
||||
|
||||
local animation = CCAnimation:animationWithSpriteFrames(animFrames, 0.5)
|
||||
local animate = CCAnimate:actionWithAnimation(animation);
|
||||
spriteDog:runAction(CCRepeatForever:actionWithAction(animate))
|
||||
local animation = CCAnimation:create(animFrames, 0.5)
|
||||
local animate = CCAnimate:create(animation);
|
||||
spriteDog:runAction(CCRepeatForever:create(animate))
|
||||
|
||||
-- moving dog at every frame
|
||||
local function tick()
|
||||
|
@ -59,28 +59,27 @@ end
|
|||
|
||||
-- create farm
|
||||
local function createLayerFram()
|
||||
local layerFarm = CCLayer:node()
|
||||
local layerFarm = CCLayer:create()
|
||||
|
||||
-- add in farm background
|
||||
local bg = CCSprite:spriteWithFile("farm.jpg")
|
||||
local bg = CCSprite:create("farm.jpg")
|
||||
bg:setPosition(winSize.width / 2 + 80, winSize.height / 2)
|
||||
layerFarm:addChild(bg)
|
||||
|
||||
-- add land sprite
|
||||
for i = 0, 3 do
|
||||
for j = 0, 1 do
|
||||
local spriteLand = CCSprite:spriteWithFile("land.png")
|
||||
local spriteLand = CCSprite:create("land.png")
|
||||
spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2)
|
||||
layerFarm:addChild(spriteLand)
|
||||
end
|
||||
end
|
||||
|
||||
-- add crop
|
||||
local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png")
|
||||
local frameCrop = CCSpriteFrame:frameWithTexture(textureCrop, CCRectMake(0, 0, 105, 95))
|
||||
local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95))
|
||||
for i = 0, 3 do
|
||||
for j = 0, 1 do
|
||||
local spriteCrop = CCSprite:spriteWithSpriteFrame(frameCrop);
|
||||
local spriteCrop = CCSprite:create(frameCrop);
|
||||
spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2)
|
||||
layerFarm:addChild(spriteCrop)
|
||||
end
|
||||
|
@ -128,7 +127,7 @@ local function createLayerFram()
|
|||
end
|
||||
|
||||
layerFarm:registerScriptTouchHandler(onTouch)
|
||||
layerFarm:setIsTouchEnabled(true)
|
||||
layerFarm:setTouchEnabled(true)
|
||||
|
||||
return layerFarm
|
||||
end
|
||||
|
@ -136,36 +135,36 @@ end
|
|||
|
||||
-- create menu
|
||||
local function createLayerMenu()
|
||||
local layerMenu = CCLayer:node()
|
||||
local layerMenu = CCLayer:create()
|
||||
|
||||
local menuPopup, menuTools, effectID
|
||||
|
||||
local function menuCallbackClosePopup()
|
||||
-- stop test sound effect
|
||||
SimpleAudioEngine:sharedEngine():stopEffect(effectID)
|
||||
menuPopup:setIsVisible(false)
|
||||
menuPopup:setVisible(false)
|
||||
end
|
||||
|
||||
local function menuCallbackOpenPopup()
|
||||
-- loop test sound effect
|
||||
effectID = SimpleAudioEngine:sharedEngine():playEffect("effect1.wav")
|
||||
menuPopup:setIsVisible(true)
|
||||
menuPopup:setVisible(true)
|
||||
end
|
||||
|
||||
-- add a popup menu
|
||||
local menuPopupItem = CCMenuItemImage:itemWithNormalImage("menu2.png", "menu2.png")
|
||||
local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png")
|
||||
menuPopupItem:setPosition(0, 0)
|
||||
menuPopupItem:registerScriptHandler(menuCallbackClosePopup)
|
||||
menuPopup = CCMenu:menuWithItem(menuPopupItem)
|
||||
menuPopup = CCMenu:createWithItem(menuPopupItem)
|
||||
menuPopup:setPosition(winSize.width / 2, winSize.height / 2)
|
||||
menuPopup:setIsVisible(false)
|
||||
menuPopup:setVisible(false)
|
||||
layerMenu:addChild(menuPopup)
|
||||
|
||||
-- add the left-bottom "tools" menu to invoke menuPopup
|
||||
local menuToolsItem = CCMenuItemImage:itemWithNormalImage("menu1.png", "menu1.png")
|
||||
local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png")
|
||||
menuToolsItem:setPosition(0, 0)
|
||||
menuToolsItem:registerScriptHandler(menuCallbackOpenPopup)
|
||||
menuTools = CCMenu:menuWithItem(menuToolsItem)
|
||||
menuTools = CCMenu:createWithItem(menuToolsItem)
|
||||
menuTools:setPosition(30, 40)
|
||||
layerMenu:addChild(menuTools)
|
||||
|
||||
|
@ -177,7 +176,7 @@ SimpleAudioEngine:sharedEngine():playBackgroundMusic("background.mp3", true);
|
|||
SimpleAudioEngine:sharedEngine():preloadEffect("effect1.wav");
|
||||
|
||||
-- run
|
||||
local sceneGame = CCScene:node()
|
||||
local sceneGame = CCScene:create()
|
||||
sceneGame:addChild(createLayerFram())
|
||||
sceneGame:addChild(createLayerMenu())
|
||||
CCDirector:sharedDirector():runWithScene(sceneGame)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="src_common"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>HelloLua</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>src_common</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/cocos2dx/platform/android/java/src_common</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,17 @@
|
|||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="HelloLua" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
|
@ -62,6 +62,9 @@ cp $file $GAME_ANDROID_ROOT/assets
|
|||
fi
|
||||
done
|
||||
|
||||
# Change the authority of Resources folder.
|
||||
chmod -R 666 $GAME_ANDROID_ROOT/assets
|
||||
|
||||
# build
|
||||
if [[ $buildexternalsfromsource ]]; then
|
||||
echo "Building external dependencies from source"
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.hellolua;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int icon=0x7f020000;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int test_demo_gl_surfaceview=0x7f050001;
|
||||
public static final int textField=0x7f050000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int game_demo=0x7f030000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040000;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
view->setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -8,4 +8,6 @@
|
|||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-10
|
||||
target=android-8
|
||||
|
||||
android.library.reference.1=../../cocos2dx/platform/android/java
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.cocos2dx.lib.Cocos2dxEditText
|
||||
android:id="@+id/textField"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@null"/>
|
||||
|
||||
<org.cocos2dx.lib.Cocos2dxGLSurfaceView
|
||||
android:id="@+id/test_demo_gl_surfaceview"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -23,6 +23,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
package org.cocos2dx.hellolua;
|
||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||
import org.cocos2dx.lib.Cocos2dxEditText;
|
||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
||||
import org.cocos2dx.lib.Cocos2dxRenderer;
|
||||
|
||||
|
@ -33,6 +34,8 @@ import android.opengl.GLSurfaceView;
|
|||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.FrameLayout;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class HelloLua extends Cocos2dxActivity{
|
||||
protected void onCreate(Bundle savedInstanceState){
|
||||
|
@ -43,10 +46,35 @@ public class HelloLua extends Cocos2dxActivity{
|
|||
String packageName = getApplication().getPackageName();
|
||||
super.setPackageName(packageName);
|
||||
|
||||
// FrameLayout
|
||||
ViewGroup.LayoutParams framelayout_params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.FILL_PARENT);
|
||||
FrameLayout framelayout = new FrameLayout(this);
|
||||
framelayout.setLayoutParams(framelayout_params);
|
||||
|
||||
// Cocos2dxEditText layout
|
||||
ViewGroup.LayoutParams edittext_layout_params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
Cocos2dxEditText edittext = new Cocos2dxEditText(this);
|
||||
edittext.setLayoutParams(edittext_layout_params);
|
||||
|
||||
// ...add to FrameLayout
|
||||
framelayout.addView(edittext);
|
||||
|
||||
// LuaGLSurfaceView
|
||||
mGLView = new LuaGLSurfaceView(this);
|
||||
setContentView(mGLView);
|
||||
|
||||
// ...add to FrameLayout
|
||||
framelayout.addView(mGLView);
|
||||
|
||||
mGLView.setEGLContextClientVersion(2);
|
||||
mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
||||
mGLView.setTextField(edittext);
|
||||
|
||||
// Set framelayout as the content view
|
||||
setContentView(framelayout);
|
||||
}
|
||||
else {
|
||||
Log.d("activity", "don't support gles2.0");
|
||||
|
|
|
@ -1,381 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.FontMetricsInt;
|
||||
import android.util.Log;
|
||||
|
||||
public class Cocos2dxBitmap{
|
||||
/*
|
||||
* The values are the same as cocos2dx/platform/CCImage.h.
|
||||
* I think three alignments are OK.
|
||||
*/
|
||||
private static final int ALIGNCENTER = 0x33;
|
||||
private static final int ALIGNLEFT = 0x31;
|
||||
private static final int ALIGNRIGHT = 0x32;
|
||||
|
||||
private static Context context;
|
||||
|
||||
public static void setContext(Context context){
|
||||
Cocos2dxBitmap.context = context;
|
||||
}
|
||||
|
||||
/*
|
||||
* @width: the width to draw, it can be 0
|
||||
* @height: the height to draw, it can be 0
|
||||
*/
|
||||
public static void createTextBitmap(String content, String fontName,
|
||||
int fontSize, int alignment, int width, int height){
|
||||
|
||||
content = refactorString(content);
|
||||
Paint paint = newPaint(fontName, fontSize, alignment);
|
||||
|
||||
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
||||
|
||||
int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
|
||||
|
||||
// Draw text to bitmap
|
||||
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
||||
bitmapTotalHeight, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
|
||||
// Draw string
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int x = 0;
|
||||
int y = height == 0 ?(-fm.top):
|
||||
(-fm.top + (height - textProperty.totalHeight)/2);
|
||||
String[] lines = textProperty.lines;
|
||||
for (String line : lines){
|
||||
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
||||
canvas.drawText(line, x, y, paint);
|
||||
y += textProperty.heightPerLine;
|
||||
}
|
||||
|
||||
initNativeObject(bitmap);
|
||||
}
|
||||
|
||||
private static int computeX(Paint paint, String content, int w, int alignment){
|
||||
int ret = 0;
|
||||
|
||||
switch (alignment){
|
||||
case ALIGNCENTER:
|
||||
ret = w / 2;
|
||||
break;
|
||||
|
||||
// ret = 0
|
||||
case ALIGNLEFT:
|
||||
break;
|
||||
|
||||
case ALIGNRIGHT:
|
||||
ret = w;
|
||||
break;
|
||||
|
||||
/*
|
||||
* Default is align left.
|
||||
* Should be same as newPaint().
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static class TextProperty{
|
||||
// The max width of lines
|
||||
int maxWidth;
|
||||
// The height of all lines
|
||||
int totalHeight;
|
||||
int heightPerLine;
|
||||
String[] lines;
|
||||
|
||||
TextProperty(int w, int h, String[] lines){
|
||||
this.maxWidth = w;
|
||||
this.heightPerLine = h;
|
||||
this.totalHeight = h * lines.length;
|
||||
this.lines = lines;
|
||||
}
|
||||
}
|
||||
|
||||
private static TextProperty computeTextProperty(String content, Paint paint,
|
||||
int maxWidth, int maxHeight){
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int h = (int)Math.ceil(fm.bottom - fm.top);
|
||||
int maxContentWidth = 0;
|
||||
|
||||
String[] lines = splitString(content, maxHeight, maxWidth, paint);
|
||||
|
||||
if (maxWidth != 0){
|
||||
maxContentWidth = maxWidth;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Compute the max width
|
||||
*/
|
||||
int temp = 0;
|
||||
for (String line : lines){
|
||||
temp = (int)Math.ceil(paint.measureText(line, 0, line.length()));
|
||||
if (temp > maxContentWidth){
|
||||
maxContentWidth = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TextProperty(maxContentWidth, h, lines);
|
||||
}
|
||||
|
||||
/*
|
||||
* If maxWidth or maxHeight is not 0,
|
||||
* split the string to fix the maxWidth and maxHeight.
|
||||
*/
|
||||
private static String[] splitString(String content, int maxHeight, int maxWidth,
|
||||
Paint paint){
|
||||
String[] lines = content.split("\\n");
|
||||
String[] ret = null;
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int heightPerLine = (int)Math.ceil(fm.bottom - fm.top);
|
||||
int maxLines = maxHeight / heightPerLine;
|
||||
|
||||
if (maxWidth != 0){
|
||||
LinkedList<String> strList = new LinkedList<String>();
|
||||
for (String line : lines){
|
||||
/*
|
||||
* The width of line is exceed maxWidth, should divide it into
|
||||
* two or more lines.
|
||||
*/
|
||||
int lineWidth = (int)Math.ceil(paint.measureText(line));
|
||||
if (lineWidth > maxWidth){
|
||||
strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth));
|
||||
}
|
||||
else{
|
||||
strList.add(line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Should not exceed the max height;
|
||||
*/
|
||||
if (maxLines > 0 && strList.size() >= maxLines){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove exceeding lines
|
||||
*/
|
||||
if (maxLines > 0 && strList.size() > maxLines){
|
||||
while (strList.size() > maxLines){
|
||||
strList.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
ret = new String[strList.size()];
|
||||
strList.toArray(ret);
|
||||
} else
|
||||
if (maxHeight != 0 && lines.length > maxLines) {
|
||||
/*
|
||||
* Remove exceeding lines
|
||||
*/
|
||||
LinkedList<String> strList = new LinkedList<String>();
|
||||
for (int i = 0; i < maxLines; i++){
|
||||
strList.add(lines[i]);
|
||||
}
|
||||
ret = new String[strList.size()];
|
||||
strList.toArray(ret);
|
||||
}
|
||||
else {
|
||||
ret = lines;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static LinkedList<String> divideStringWithMaxWidth(Paint paint, String content,
|
||||
int width){
|
||||
int charLength = content.length();
|
||||
int start = 0;
|
||||
int tempWidth = 0;
|
||||
LinkedList<String> strList = new LinkedList<String>();
|
||||
|
||||
/*
|
||||
* Break a String into String[] by the width & should wrap the word
|
||||
*/
|
||||
for (int i = 1; i <= charLength; ++i){
|
||||
tempWidth = (int)Math.ceil(paint.measureText(content, start, i));
|
||||
if (tempWidth >= width){
|
||||
int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" ");
|
||||
|
||||
if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){
|
||||
/**
|
||||
* Should wrap the word
|
||||
*/
|
||||
strList.add(content.substring(start, lastIndexOfSpace));
|
||||
i = lastIndexOfSpace;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Should not exceed the width
|
||||
*/
|
||||
if (tempWidth > width){
|
||||
strList.add(content.substring(start, i - 1));
|
||||
/*
|
||||
* compute from previous char
|
||||
*/
|
||||
--i;
|
||||
}
|
||||
else {
|
||||
strList.add(content.substring(start, i));
|
||||
}
|
||||
}
|
||||
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the last chars
|
||||
*/
|
||||
if (start < charLength){
|
||||
strList.add(content.substring(start));
|
||||
}
|
||||
|
||||
return strList;
|
||||
}
|
||||
|
||||
private static Paint newPaint(String fontName, int fontSize, int alignment){
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(Color.WHITE);
|
||||
paint.setTextSize(fontSize);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
/*
|
||||
* Set type face for paint, now it support .ttf file.
|
||||
*/
|
||||
if (fontName.endsWith(".ttf")){
|
||||
try {
|
||||
//Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName);
|
||||
Typeface typeFace = Cocos2dxTypefaces.get(context, fontName);
|
||||
paint.setTypeface(typeFace);
|
||||
} catch (Exception e){
|
||||
Log.e("Cocos2dxBitmap",
|
||||
"error to create ttf type face: " + fontName);
|
||||
|
||||
/*
|
||||
* The file may not find, use system font
|
||||
*/
|
||||
paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL));
|
||||
}
|
||||
}
|
||||
else {
|
||||
paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL));
|
||||
}
|
||||
|
||||
switch (alignment){
|
||||
case ALIGNCENTER:
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
break;
|
||||
|
||||
case ALIGNLEFT:
|
||||
paint.setTextAlign(Align.LEFT);
|
||||
break;
|
||||
|
||||
case ALIGNRIGHT:
|
||||
paint.setTextAlign(Align.RIGHT);
|
||||
break;
|
||||
|
||||
default:
|
||||
paint.setTextAlign(Align.LEFT);
|
||||
break;
|
||||
}
|
||||
|
||||
return paint;
|
||||
}
|
||||
|
||||
private static String refactorString(String str){
|
||||
// Avoid error when content is ""
|
||||
if (str.compareTo("") == 0){
|
||||
return " ";
|
||||
}
|
||||
|
||||
/*
|
||||
* If the font of "\n" is "" or "\n", insert " " in front of it.
|
||||
*
|
||||
* For example:
|
||||
* "\nabc" -> " \nabc"
|
||||
* "\nabc\n\n" -> " \nabc\n \n"
|
||||
*/
|
||||
StringBuilder strBuilder = new StringBuilder(str);
|
||||
int start = 0;
|
||||
int index = strBuilder.indexOf("\n");
|
||||
while (index != -1){
|
||||
if (index == 0 || strBuilder.charAt(index -1) == '\n'){
|
||||
strBuilder.insert(start, " ");
|
||||
start = index + 2;
|
||||
} else {
|
||||
start = index + 1;
|
||||
}
|
||||
|
||||
if (start > strBuilder.length() || index == strBuilder.length()){
|
||||
break;
|
||||
}
|
||||
|
||||
index = strBuilder.indexOf("\n", start);
|
||||
}
|
||||
|
||||
return strBuilder.toString();
|
||||
}
|
||||
|
||||
private static void initNativeObject(Bitmap bitmap){
|
||||
byte[] pixels = getPixels(bitmap);
|
||||
if (pixels == null){
|
||||
return;
|
||||
}
|
||||
|
||||
nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels);
|
||||
}
|
||||
|
||||
private static byte[] getPixels(Bitmap bitmap){
|
||||
if (bitmap != null){
|
||||
byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4];
|
||||
ByteBuffer buf = ByteBuffer.wrap(pixels);
|
||||
buf.order(ByteOrder.nativeOrder());
|
||||
bitmap.copyPixelsToBuffer(buf);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static native void nativeInitBitmapDC(int width, int height, byte[] pixels);
|
||||
}
|
|
@ -0,0 +1,804 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
159A66601590486A003AEEC0 /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 159A665D159047B3003AEEC0 /* libcocos2dx.a */; };
|
||||
15DD6D83156DD1EF003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD6D81156DD1EF003E7567 /* fps_images.png */; };
|
||||
506EDB88102F4C4000A389B3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDB87102F4C4000A389B3 /* libz.dylib */; };
|
||||
506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */; };
|
||||
78947C6D14EBB9B100DBD5A6 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 78947C5E14EBB9B000DBD5A6 /* background.mp3 */; };
|
||||
78947C6E14EBB9B100DBD5A6 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C5F14EBB9B000DBD5A6 /* crop.png */; };
|
||||
78947C7014EBB9B100DBD5A6 /* dog.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6114EBB9B000DBD5A6 /* dog.png */; };
|
||||
78947C7114EBB9B100DBD5A6 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6214EBB9B000DBD5A6 /* effect1.wav */; };
|
||||
78947C7214EBB9B100DBD5A6 /* farm.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6314EBB9B000DBD5A6 /* farm.jpg */; };
|
||||
78947C7414EBB9B100DBD5A6 /* hello.lua in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6614EBB9B000DBD5A6 /* hello.lua */; };
|
||||
78947C7514EBB9B100DBD5A6 /* hello2.lua in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6714EBB9B000DBD5A6 /* hello2.lua */; };
|
||||
78947C7714EBB9B100DBD5A6 /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6914EBB9B000DBD5A6 /* land.png */; };
|
||||
78947C7814EBB9B100DBD5A6 /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6A14EBB9B000DBD5A6 /* menu1.png */; };
|
||||
78947C7914EBB9B100DBD5A6 /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6B14EBB9B000DBD5A6 /* menu2.png */; };
|
||||
78947C8B14EBBB0300DBD5A6 /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8214EBBB0300DBD5A6 /* CDAudioManager.m */; };
|
||||
78947C8C14EBBB0300DBD5A6 /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8514EBBB0300DBD5A6 /* CDOpenALSupport.m */; };
|
||||
78947C8D14EBBB0300DBD5A6 /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8714EBBB0300DBD5A6 /* CocosDenshion.m */; };
|
||||
78947C8E14EBBB0300DBD5A6 /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8814EBBB0300DBD5A6 /* SimpleAudioEngine.mm */; };
|
||||
78947C8F14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8A14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m */; };
|
||||
78DC4C9A15490B9500317402 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 78DC4C9815490B9500317402 /* Default.png */; };
|
||||
78DC4C9B15490B9500317402 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 78DC4C9915490B9500317402 /* Icon.png */; };
|
||||
BF82F41713A864D700616D55 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF82F41513A864D700616D55 /* AppDelegate.cpp */; };
|
||||
BF82F42113A8652A00616D55 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF82F41F13A8652A00616D55 /* AppController.mm */; };
|
||||
BF82F42213A8652A00616D55 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BF82F42013A8652A00616D55 /* main.m */; };
|
||||
D403B5D9135D1AF1004B518D /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D403B5D8135D1AF1004B518D /* libxml2.dylib */; };
|
||||
D4CEAD7913B4634300780515 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D4CEAD7713B4634300780515 /* RootViewController.mm */; };
|
||||
DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; };
|
||||
DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; };
|
||||
DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; };
|
||||
DCCBF1B90F6022AE0040855A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B80F6022AE0040855A /* Foundation.framework */; };
|
||||
DCCBF1BB0F6022AE0040855A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1BA0F6022AE0040855A /* OpenGLES.framework */; };
|
||||
DCCBF1BD0F6022AE0040855A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1BC0F6022AE0040855A /* QuartzCore.framework */; };
|
||||
DCCBF1BF0F6022AE0040855A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1BE0F6022AE0040855A /* UIKit.framework */; };
|
||||
F4808BF414E3CB6C0021A5F8 /* CCLuaEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F48087E114E3CB6A0021A5F8 /* CCLuaEngine.cpp */; };
|
||||
F4808BF514E3CB6C0021A5F8 /* Cocos2dxLuaLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F48087E314E3CB6A0021A5F8 /* Cocos2dxLuaLoader.cpp */; };
|
||||
F4808BF614E3CB6C0021A5F8 /* LuaCocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F48087E514E3CB6A0021A5F8 /* LuaCocos2d.cpp */; };
|
||||
F4808BF714E3CB6C0021A5F8 /* tolua_fix.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087E714E3CB6A0021A5F8 /* tolua_fix.c */; };
|
||||
F4808BF814E3CB6C0021A5F8 /* lapi.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EA14E3CB6A0021A5F8 /* lapi.c */; };
|
||||
F4808BF914E3CB6C0021A5F8 /* lauxlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EC14E3CB6A0021A5F8 /* lauxlib.c */; };
|
||||
F4808BFA14E3CB6C0021A5F8 /* lbaselib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EE14E3CB6A0021A5F8 /* lbaselib.c */; };
|
||||
F4808BFB14E3CB6C0021A5F8 /* lcode.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EF14E3CB6A0021A5F8 /* lcode.c */; };
|
||||
F4808BFC14E3CB6C0021A5F8 /* ldblib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F114E3CB6A0021A5F8 /* ldblib.c */; };
|
||||
F4808BFD14E3CB6C0021A5F8 /* ldebug.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F214E3CB6A0021A5F8 /* ldebug.c */; };
|
||||
F4808BFE14E3CB6C0021A5F8 /* ldo.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F414E3CB6A0021A5F8 /* ldo.c */; };
|
||||
F4808BFF14E3CB6C0021A5F8 /* ldump.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F614E3CB6A0021A5F8 /* ldump.c */; };
|
||||
F4808C0014E3CB6C0021A5F8 /* lfunc.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F714E3CB6A0021A5F8 /* lfunc.c */; };
|
||||
F4808C0114E3CB6C0021A5F8 /* lgc.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F914E3CB6A0021A5F8 /* lgc.c */; };
|
||||
F4808C0214E3CB6C0021A5F8 /* linit.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087FB14E3CB6A0021A5F8 /* linit.c */; };
|
||||
F4808C0314E3CB6C0021A5F8 /* liolib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087FC14E3CB6A0021A5F8 /* liolib.c */; };
|
||||
F4808C0414E3CB6C0021A5F8 /* llex.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087FD14E3CB6A0021A5F8 /* llex.c */; };
|
||||
F4808C0514E3CB6C0021A5F8 /* lmathlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880014E3CB6A0021A5F8 /* lmathlib.c */; };
|
||||
F4808C0614E3CB6C0021A5F8 /* lmem.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880114E3CB6A0021A5F8 /* lmem.c */; };
|
||||
F4808C0714E3CB6C0021A5F8 /* loadlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880314E3CB6A0021A5F8 /* loadlib.c */; };
|
||||
F4808C0814E3CB6C0021A5F8 /* lobject.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880414E3CB6A0021A5F8 /* lobject.c */; };
|
||||
F4808C0914E3CB6C0021A5F8 /* lopcodes.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880614E3CB6A0021A5F8 /* lopcodes.c */; };
|
||||
F4808C0A14E3CB6C0021A5F8 /* loslib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880814E3CB6A0021A5F8 /* loslib.c */; };
|
||||
F4808C0B14E3CB6C0021A5F8 /* lparser.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880914E3CB6A0021A5F8 /* lparser.c */; };
|
||||
F4808C0C14E3CB6C0021A5F8 /* lstate.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880B14E3CB6A0021A5F8 /* lstate.c */; };
|
||||
F4808C0D14E3CB6C0021A5F8 /* lstring.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880D14E3CB6A0021A5F8 /* lstring.c */; };
|
||||
F4808C0E14E3CB6C0021A5F8 /* lstrlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880F14E3CB6A0021A5F8 /* lstrlib.c */; };
|
||||
F4808C0F14E3CB6C0021A5F8 /* ltable.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881014E3CB6A0021A5F8 /* ltable.c */; };
|
||||
F4808C1014E3CB6C0021A5F8 /* ltablib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881214E3CB6A0021A5F8 /* ltablib.c */; };
|
||||
F4808C1114E3CB6C0021A5F8 /* ltm.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881314E3CB6A0021A5F8 /* ltm.c */; };
|
||||
F4808C1214E3CB6C0021A5F8 /* lua.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881514E3CB6A0021A5F8 /* lua.c */; };
|
||||
F4808C1314E3CB6C0021A5F8 /* lundump.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881914E3CB6A0021A5F8 /* lundump.c */; };
|
||||
F4808C1414E3CB6C0021A5F8 /* lvm.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881B14E3CB6A0021A5F8 /* lvm.c */; };
|
||||
F4808C1514E3CB6C0021A5F8 /* lzio.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881D14E3CB6A0021A5F8 /* lzio.c */; };
|
||||
F4808C1614E3CB6C0021A5F8 /* print.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881F14E3CB6A0021A5F8 /* print.c */; };
|
||||
F4808C1D14E3CB6C0021A5F8 /* tolua_event.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882B14E3CB6A0021A5F8 /* tolua_event.c */; };
|
||||
F4808C1E14E3CB6C0021A5F8 /* tolua_is.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882D14E3CB6A0021A5F8 /* tolua_is.c */; };
|
||||
F4808C1F14E3CB6C0021A5F8 /* tolua_map.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882E14E3CB6A0021A5F8 /* tolua_map.c */; };
|
||||
F4808C2014E3CB6C0021A5F8 /* tolua_push.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882F14E3CB6A0021A5F8 /* tolua_push.c */; };
|
||||
F4808C2114E3CB6C0021A5F8 /* tolua_to.c in Sources */ = {isa = PBXBuildFile; fileRef = F480883014E3CB6A0021A5F8 /* tolua_to.c */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
159A665C159047B3003AEEC0 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 1551A33F158F2AB200E66CFE;
|
||||
remoteInfo = cocos2dx;
|
||||
};
|
||||
159A665E15904864003AEEC0 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 1551A33E158F2AB200E66CFE;
|
||||
remoteInfo = cocos2dx;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
|
||||
15DD6D81156DD1EF003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
|
||||
1D6058910D05DD3D006BFB54 /* HelloLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloLua.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
506EDB87102F4C4000A389B3 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
|
||||
78947C5E14EBB9B000DBD5A6 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = background.mp3; sourceTree = "<group>"; };
|
||||
78947C5F14EBB9B000DBD5A6 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = crop.png; sourceTree = "<group>"; };
|
||||
78947C6114EBB9B000DBD5A6 /* dog.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dog.png; sourceTree = "<group>"; };
|
||||
78947C6214EBB9B000DBD5A6 /* effect1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = effect1.wav; sourceTree = "<group>"; };
|
||||
78947C6314EBB9B000DBD5A6 /* farm.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = farm.jpg; sourceTree = "<group>"; };
|
||||
78947C6614EBB9B000DBD5A6 /* hello.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hello.lua; sourceTree = "<group>"; };
|
||||
78947C6714EBB9B000DBD5A6 /* hello2.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hello2.lua; sourceTree = "<group>"; };
|
||||
78947C6914EBB9B000DBD5A6 /* land.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = land.png; sourceTree = "<group>"; };
|
||||
78947C6A14EBB9B000DBD5A6 /* menu1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu1.png; sourceTree = "<group>"; };
|
||||
78947C6B14EBB9B000DBD5A6 /* menu2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu2.png; sourceTree = "<group>"; };
|
||||
78947C8114EBBB0300DBD5A6 /* CDAudioManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = "<group>"; };
|
||||
78947C8214EBBB0300DBD5A6 /* CDAudioManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = "<group>"; };
|
||||
78947C8314EBBB0300DBD5A6 /* CDConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = "<group>"; };
|
||||
78947C8414EBBB0300DBD5A6 /* CDOpenALSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = "<group>"; };
|
||||
78947C8514EBBB0300DBD5A6 /* CDOpenALSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = "<group>"; };
|
||||
78947C8614EBBB0300DBD5A6 /* CocosDenshion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = "<group>"; };
|
||||
78947C8714EBBB0300DBD5A6 /* CocosDenshion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = "<group>"; };
|
||||
78947C8814EBBB0300DBD5A6 /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = "<group>"; };
|
||||
78947C8914EBBB0300DBD5A6 /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = "<group>"; };
|
||||
78947C8A14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = "<group>"; };
|
||||
78DC4C9815490B9500317402 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; };
|
||||
78DC4C9915490B9500317402 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; };
|
||||
BF82F41513A864D700616D55 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppDelegate.cpp; path = ../Classes/AppDelegate.cpp; sourceTree = SOURCE_ROOT; };
|
||||
BF82F41613A864D700616D55 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../Classes/AppDelegate.h; sourceTree = SOURCE_ROOT; };
|
||||
BF82F41E13A8652A00616D55 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
|
||||
BF82F41F13A8652A00616D55 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = "<group>"; };
|
||||
BF82F42013A8652A00616D55 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
BF82F42313A8654600616D55 /* HelloLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloLua_Prefix.pch; sourceTree = "<group>"; };
|
||||
D403B5D8135D1AF1004B518D /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
|
||||
D4CEAD7713B4634300780515 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = "<group>"; };
|
||||
D4CEAD7813B4634300780515 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
|
||||
DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
|
||||
DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
|
||||
DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
DCCBF1B80F6022AE0040855A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
DCCBF1BA0F6022AE0040855A /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
|
||||
DCCBF1BC0F6022AE0040855A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
DCCBF1BE0F6022AE0040855A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
F480877714E3CB6A0021A5F8 /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = "<group>"; };
|
||||
F480877814E3CB6A0021A5F8 /* SimpleAudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = "<group>"; };
|
||||
F48087E114E3CB6A0021A5F8 /* CCLuaEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLuaEngine.cpp; sourceTree = "<group>"; };
|
||||
F48087E214E3CB6A0021A5F8 /* CCLuaEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaEngine.h; sourceTree = "<group>"; };
|
||||
F48087E314E3CB6A0021A5F8 /* Cocos2dxLuaLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cocos2dxLuaLoader.cpp; sourceTree = "<group>"; };
|
||||
F48087E414E3CB6A0021A5F8 /* Cocos2dxLuaLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cocos2dxLuaLoader.h; sourceTree = "<group>"; };
|
||||
F48087E514E3CB6A0021A5F8 /* LuaCocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaCocos2d.cpp; sourceTree = "<group>"; };
|
||||
F48087E614E3CB6A0021A5F8 /* LuaCocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaCocos2d.h; sourceTree = "<group>"; };
|
||||
F48087E714E3CB6A0021A5F8 /* tolua_fix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_fix.c; sourceTree = "<group>"; };
|
||||
F48087E814E3CB6A0021A5F8 /* tolua_fix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tolua_fix.h; sourceTree = "<group>"; };
|
||||
F48087EA14E3CB6A0021A5F8 /* lapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lapi.c; sourceTree = "<group>"; };
|
||||
F48087EB14E3CB6A0021A5F8 /* lapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lapi.h; sourceTree = "<group>"; };
|
||||
F48087EC14E3CB6A0021A5F8 /* lauxlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lauxlib.c; sourceTree = "<group>"; };
|
||||
F48087ED14E3CB6A0021A5F8 /* lauxlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lauxlib.h; sourceTree = "<group>"; };
|
||||
F48087EE14E3CB6A0021A5F8 /* lbaselib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lbaselib.c; sourceTree = "<group>"; };
|
||||
F48087EF14E3CB6A0021A5F8 /* lcode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lcode.c; sourceTree = "<group>"; };
|
||||
F48087F014E3CB6A0021A5F8 /* lcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lcode.h; sourceTree = "<group>"; };
|
||||
F48087F114E3CB6A0021A5F8 /* ldblib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldblib.c; sourceTree = "<group>"; };
|
||||
F48087F214E3CB6A0021A5F8 /* ldebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldebug.c; sourceTree = "<group>"; };
|
||||
F48087F314E3CB6A0021A5F8 /* ldebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ldebug.h; sourceTree = "<group>"; };
|
||||
F48087F414E3CB6A0021A5F8 /* ldo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldo.c; sourceTree = "<group>"; };
|
||||
F48087F514E3CB6A0021A5F8 /* ldo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ldo.h; sourceTree = "<group>"; };
|
||||
F48087F614E3CB6A0021A5F8 /* ldump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldump.c; sourceTree = "<group>"; };
|
||||
F48087F714E3CB6A0021A5F8 /* lfunc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lfunc.c; sourceTree = "<group>"; };
|
||||
F48087F814E3CB6A0021A5F8 /* lfunc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lfunc.h; sourceTree = "<group>"; };
|
||||
F48087F914E3CB6A0021A5F8 /* lgc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lgc.c; sourceTree = "<group>"; };
|
||||
F48087FA14E3CB6A0021A5F8 /* lgc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lgc.h; sourceTree = "<group>"; };
|
||||
F48087FB14E3CB6A0021A5F8 /* linit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = linit.c; sourceTree = "<group>"; };
|
||||
F48087FC14E3CB6A0021A5F8 /* liolib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = liolib.c; sourceTree = "<group>"; };
|
||||
F48087FD14E3CB6A0021A5F8 /* llex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = llex.c; sourceTree = "<group>"; };
|
||||
F48087FE14E3CB6A0021A5F8 /* llex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llex.h; sourceTree = "<group>"; };
|
||||
F48087FF14E3CB6A0021A5F8 /* llimits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llimits.h; sourceTree = "<group>"; };
|
||||
F480880014E3CB6A0021A5F8 /* lmathlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmathlib.c; sourceTree = "<group>"; };
|
||||
F480880114E3CB6A0021A5F8 /* lmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmem.c; sourceTree = "<group>"; };
|
||||
F480880214E3CB6A0021A5F8 /* lmem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lmem.h; sourceTree = "<group>"; };
|
||||
F480880314E3CB6A0021A5F8 /* loadlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = loadlib.c; sourceTree = "<group>"; };
|
||||
F480880414E3CB6A0021A5F8 /* lobject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lobject.c; sourceTree = "<group>"; };
|
||||
F480880514E3CB6A0021A5F8 /* lobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lobject.h; sourceTree = "<group>"; };
|
||||
F480880614E3CB6A0021A5F8 /* lopcodes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lopcodes.c; sourceTree = "<group>"; };
|
||||
F480880714E3CB6A0021A5F8 /* lopcodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lopcodes.h; sourceTree = "<group>"; };
|
||||
F480880814E3CB6A0021A5F8 /* loslib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = loslib.c; sourceTree = "<group>"; };
|
||||
F480880914E3CB6A0021A5F8 /* lparser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lparser.c; sourceTree = "<group>"; };
|
||||
F480880A14E3CB6A0021A5F8 /* lparser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lparser.h; sourceTree = "<group>"; };
|
||||
F480880B14E3CB6A0021A5F8 /* lstate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lstate.c; sourceTree = "<group>"; };
|
||||
F480880C14E3CB6A0021A5F8 /* lstate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lstate.h; sourceTree = "<group>"; };
|
||||
F480880D14E3CB6A0021A5F8 /* lstring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lstring.c; sourceTree = "<group>"; };
|
||||
F480880E14E3CB6A0021A5F8 /* lstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lstring.h; sourceTree = "<group>"; };
|
||||
F480880F14E3CB6A0021A5F8 /* lstrlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lstrlib.c; sourceTree = "<group>"; };
|
||||
F480881014E3CB6A0021A5F8 /* ltable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltable.c; sourceTree = "<group>"; };
|
||||
F480881114E3CB6A0021A5F8 /* ltable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ltable.h; sourceTree = "<group>"; };
|
||||
F480881214E3CB6A0021A5F8 /* ltablib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltablib.c; sourceTree = "<group>"; };
|
||||
F480881314E3CB6A0021A5F8 /* ltm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltm.c; sourceTree = "<group>"; };
|
||||
F480881414E3CB6A0021A5F8 /* ltm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ltm.h; sourceTree = "<group>"; };
|
||||
F480881514E3CB6A0021A5F8 /* lua.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lua.c; sourceTree = "<group>"; };
|
||||
F480881614E3CB6A0021A5F8 /* lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua.h; sourceTree = "<group>"; };
|
||||
F480881714E3CB6A0021A5F8 /* luaconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = luaconf.h; sourceTree = "<group>"; };
|
||||
F480881814E3CB6A0021A5F8 /* lualib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lualib.h; sourceTree = "<group>"; };
|
||||
F480881914E3CB6A0021A5F8 /* lundump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lundump.c; sourceTree = "<group>"; };
|
||||
F480881A14E3CB6A0021A5F8 /* lundump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lundump.h; sourceTree = "<group>"; };
|
||||
F480881B14E3CB6A0021A5F8 /* lvm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lvm.c; sourceTree = "<group>"; };
|
||||
F480881C14E3CB6A0021A5F8 /* lvm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lvm.h; sourceTree = "<group>"; };
|
||||
F480881D14E3CB6A0021A5F8 /* lzio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lzio.c; sourceTree = "<group>"; };
|
||||
F480881E14E3CB6A0021A5F8 /* lzio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lzio.h; sourceTree = "<group>"; };
|
||||
F480881F14E3CB6A0021A5F8 /* print.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = print.c; sourceTree = "<group>"; };
|
||||
F480882A14E3CB6A0021A5F8 /* tolua++.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "tolua++.h"; sourceTree = "<group>"; };
|
||||
F480882B14E3CB6A0021A5F8 /* tolua_event.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_event.c; sourceTree = "<group>"; };
|
||||
F480882C14E3CB6A0021A5F8 /* tolua_event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tolua_event.h; sourceTree = "<group>"; };
|
||||
F480882D14E3CB6A0021A5F8 /* tolua_is.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_is.c; sourceTree = "<group>"; };
|
||||
F480882E14E3CB6A0021A5F8 /* tolua_map.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_map.c; sourceTree = "<group>"; };
|
||||
F480882F14E3CB6A0021A5F8 /* tolua_push.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_push.c; sourceTree = "<group>"; };
|
||||
F480883014E3CB6A0021A5F8 /* tolua_to.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_to.c; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
159A66601590486A003AEEC0 /* libcocos2dx.a in Frameworks */,
|
||||
DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */,
|
||||
DCCBF1B90F6022AE0040855A /* Foundation.framework in Frameworks */,
|
||||
DCCBF1BB0F6022AE0040855A /* OpenGLES.framework in Frameworks */,
|
||||
DCCBF1BD0F6022AE0040855A /* QuartzCore.framework in Frameworks */,
|
||||
DCCBF1BF0F6022AE0040855A /* UIKit.framework in Frameworks */,
|
||||
DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */,
|
||||
DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */,
|
||||
506EDB88102F4C4000A389B3 /* libz.dylib in Frameworks */,
|
||||
506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */,
|
||||
D403B5D9135D1AF1004B518D /* libxml2.dylib in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
159A6656159047B3003AEEC0 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
159A665D159047B3003AEEC0 /* libcocos2dx.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1D6058910D05DD3D006BFB54 /* HelloLua.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */,
|
||||
78947C5C14EBB9B000DBD5A6 /* Resources */,
|
||||
BF82F41413A864B000616D55 /* Classes */,
|
||||
506EDAA3102F461B00A389B3 /* libs */,
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||
);
|
||||
name = CustomTemplate;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4CEAD7713B4634300780515 /* RootViewController.mm */,
|
||||
D4CEAD7813B4634300780515 /* RootViewController.h */,
|
||||
BF82F42313A8654600616D55 /* HelloLua_Prefix.pch */,
|
||||
BF82F41E13A8652A00616D55 /* AppController.h */,
|
||||
BF82F41F13A8652A00616D55 /* AppController.mm */,
|
||||
BF82F42013A8652A00616D55 /* main.m */,
|
||||
);
|
||||
name = "Other Sources";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */,
|
||||
DCCBF1B80F6022AE0040855A /* Foundation.framework */,
|
||||
DCCBF1BA0F6022AE0040855A /* OpenGLES.framework */,
|
||||
DCCBF1BC0F6022AE0040855A /* QuartzCore.framework */,
|
||||
DCCBF1BE0F6022AE0040855A /* UIKit.framework */,
|
||||
DC6640040F83B3EA000B3E49 /* OpenAL.framework */,
|
||||
DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */,
|
||||
506EDB87102F4C4000A389B3 /* libz.dylib */,
|
||||
506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */,
|
||||
D403B5D8135D1AF1004B518D /* libxml2.dylib */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
506EDAA3102F461B00A389B3 /* libs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F480871B14E3CB6A0021A5F8 /* CocosDenshion */,
|
||||
F48087DF14E3CB6A0021A5F8 /* lua */,
|
||||
);
|
||||
name = libs;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
78947C5C14EBB9B000DBD5A6 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15DD6D81156DD1EF003E7567 /* fps_images.png */,
|
||||
78947C5E14EBB9B000DBD5A6 /* background.mp3 */,
|
||||
78947C5F14EBB9B000DBD5A6 /* crop.png */,
|
||||
78DC4C9815490B9500317402 /* Default.png */,
|
||||
78947C6114EBB9B000DBD5A6 /* dog.png */,
|
||||
78947C6214EBB9B000DBD5A6 /* effect1.wav */,
|
||||
78947C6314EBB9B000DBD5A6 /* farm.jpg */,
|
||||
78947C6614EBB9B000DBD5A6 /* hello.lua */,
|
||||
78947C6714EBB9B000DBD5A6 /* hello2.lua */,
|
||||
78DC4C9915490B9500317402 /* Icon.png */,
|
||||
78947C6914EBB9B000DBD5A6 /* land.png */,
|
||||
78947C6A14EBB9B000DBD5A6 /* menu1.png */,
|
||||
78947C6B14EBB9B000DBD5A6 /* menu2.png */,
|
||||
);
|
||||
name = Resources;
|
||||
path = ../Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
78947C8014EBBB0300DBD5A6 /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
78947C8114EBBB0300DBD5A6 /* CDAudioManager.h */,
|
||||
78947C8214EBBB0300DBD5A6 /* CDAudioManager.m */,
|
||||
78947C8314EBBB0300DBD5A6 /* CDConfig.h */,
|
||||
78947C8414EBBB0300DBD5A6 /* CDOpenALSupport.h */,
|
||||
78947C8514EBBB0300DBD5A6 /* CDOpenALSupport.m */,
|
||||
78947C8614EBBB0300DBD5A6 /* CocosDenshion.h */,
|
||||
78947C8714EBBB0300DBD5A6 /* CocosDenshion.m */,
|
||||
78947C8814EBBB0300DBD5A6 /* SimpleAudioEngine.mm */,
|
||||
78947C8914EBBB0300DBD5A6 /* SimpleAudioEngine_objc.h */,
|
||||
78947C8A14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m */,
|
||||
);
|
||||
path = ios;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF82F41413A864B000616D55 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF82F41513A864D700616D55 /* AppDelegate.cpp */,
|
||||
BF82F41613A864D700616D55 /* AppDelegate.h */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F480871B14E3CB6A0021A5F8 /* CocosDenshion */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
78947C8014EBBB0300DBD5A6 /* ios */,
|
||||
F480877614E3CB6A0021A5F8 /* include */,
|
||||
);
|
||||
name = CocosDenshion;
|
||||
path = ../../CocosDenshion;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F480877614E3CB6A0021A5F8 /* include */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F480877714E3CB6A0021A5F8 /* Export.h */,
|
||||
F480877814E3CB6A0021A5F8 /* SimpleAudioEngine.h */,
|
||||
);
|
||||
path = include;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F48087DF14E3CB6A0021A5F8 /* lua */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F48087E014E3CB6A0021A5F8 /* cocos2dx_support */,
|
||||
F48087E914E3CB6A0021A5F8 /* lua */,
|
||||
F480882914E3CB6A0021A5F8 /* tolua */,
|
||||
);
|
||||
name = lua;
|
||||
path = ../../lua;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F48087E014E3CB6A0021A5F8 /* cocos2dx_support */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F48087E114E3CB6A0021A5F8 /* CCLuaEngine.cpp */,
|
||||
F48087E214E3CB6A0021A5F8 /* CCLuaEngine.h */,
|
||||
F48087E314E3CB6A0021A5F8 /* Cocos2dxLuaLoader.cpp */,
|
||||
F48087E414E3CB6A0021A5F8 /* Cocos2dxLuaLoader.h */,
|
||||
F48087E514E3CB6A0021A5F8 /* LuaCocos2d.cpp */,
|
||||
F48087E614E3CB6A0021A5F8 /* LuaCocos2d.h */,
|
||||
F48087E714E3CB6A0021A5F8 /* tolua_fix.c */,
|
||||
F48087E814E3CB6A0021A5F8 /* tolua_fix.h */,
|
||||
);
|
||||
path = cocos2dx_support;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F48087E914E3CB6A0021A5F8 /* lua */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F48087EA14E3CB6A0021A5F8 /* lapi.c */,
|
||||
F48087EB14E3CB6A0021A5F8 /* lapi.h */,
|
||||
F48087EC14E3CB6A0021A5F8 /* lauxlib.c */,
|
||||
F48087ED14E3CB6A0021A5F8 /* lauxlib.h */,
|
||||
F48087EE14E3CB6A0021A5F8 /* lbaselib.c */,
|
||||
F48087EF14E3CB6A0021A5F8 /* lcode.c */,
|
||||
F48087F014E3CB6A0021A5F8 /* lcode.h */,
|
||||
F48087F114E3CB6A0021A5F8 /* ldblib.c */,
|
||||
F48087F214E3CB6A0021A5F8 /* ldebug.c */,
|
||||
F48087F314E3CB6A0021A5F8 /* ldebug.h */,
|
||||
F48087F414E3CB6A0021A5F8 /* ldo.c */,
|
||||
F48087F514E3CB6A0021A5F8 /* ldo.h */,
|
||||
F48087F614E3CB6A0021A5F8 /* ldump.c */,
|
||||
F48087F714E3CB6A0021A5F8 /* lfunc.c */,
|
||||
F48087F814E3CB6A0021A5F8 /* lfunc.h */,
|
||||
F48087F914E3CB6A0021A5F8 /* lgc.c */,
|
||||
F48087FA14E3CB6A0021A5F8 /* lgc.h */,
|
||||
F48087FB14E3CB6A0021A5F8 /* linit.c */,
|
||||
F48087FC14E3CB6A0021A5F8 /* liolib.c */,
|
||||
F48087FD14E3CB6A0021A5F8 /* llex.c */,
|
||||
F48087FE14E3CB6A0021A5F8 /* llex.h */,
|
||||
F48087FF14E3CB6A0021A5F8 /* llimits.h */,
|
||||
F480880014E3CB6A0021A5F8 /* lmathlib.c */,
|
||||
F480880114E3CB6A0021A5F8 /* lmem.c */,
|
||||
F480880214E3CB6A0021A5F8 /* lmem.h */,
|
||||
F480880314E3CB6A0021A5F8 /* loadlib.c */,
|
||||
F480880414E3CB6A0021A5F8 /* lobject.c */,
|
||||
F480880514E3CB6A0021A5F8 /* lobject.h */,
|
||||
F480880614E3CB6A0021A5F8 /* lopcodes.c */,
|
||||
F480880714E3CB6A0021A5F8 /* lopcodes.h */,
|
||||
F480880814E3CB6A0021A5F8 /* loslib.c */,
|
||||
F480880914E3CB6A0021A5F8 /* lparser.c */,
|
||||
F480880A14E3CB6A0021A5F8 /* lparser.h */,
|
||||
F480880B14E3CB6A0021A5F8 /* lstate.c */,
|
||||
F480880C14E3CB6A0021A5F8 /* lstate.h */,
|
||||
F480880D14E3CB6A0021A5F8 /* lstring.c */,
|
||||
F480880E14E3CB6A0021A5F8 /* lstring.h */,
|
||||
F480880F14E3CB6A0021A5F8 /* lstrlib.c */,
|
||||
F480881014E3CB6A0021A5F8 /* ltable.c */,
|
||||
F480881114E3CB6A0021A5F8 /* ltable.h */,
|
||||
F480881214E3CB6A0021A5F8 /* ltablib.c */,
|
||||
F480881314E3CB6A0021A5F8 /* ltm.c */,
|
||||
F480881414E3CB6A0021A5F8 /* ltm.h */,
|
||||
F480881514E3CB6A0021A5F8 /* lua.c */,
|
||||
F480881614E3CB6A0021A5F8 /* lua.h */,
|
||||
F480881714E3CB6A0021A5F8 /* luaconf.h */,
|
||||
F480881814E3CB6A0021A5F8 /* lualib.h */,
|
||||
F480881914E3CB6A0021A5F8 /* lundump.c */,
|
||||
F480881A14E3CB6A0021A5F8 /* lundump.h */,
|
||||
F480881B14E3CB6A0021A5F8 /* lvm.c */,
|
||||
F480881C14E3CB6A0021A5F8 /* lvm.h */,
|
||||
F480881D14E3CB6A0021A5F8 /* lzio.c */,
|
||||
F480881E14E3CB6A0021A5F8 /* lzio.h */,
|
||||
F480881F14E3CB6A0021A5F8 /* print.c */,
|
||||
);
|
||||
path = lua;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F480882914E3CB6A0021A5F8 /* tolua */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F480882A14E3CB6A0021A5F8 /* tolua++.h */,
|
||||
F480882B14E3CB6A0021A5F8 /* tolua_event.c */,
|
||||
F480882C14E3CB6A0021A5F8 /* tolua_event.h */,
|
||||
F480882D14E3CB6A0021A5F8 /* tolua_is.c */,
|
||||
F480882E14E3CB6A0021A5F8 /* tolua_map.c */,
|
||||
F480882F14E3CB6A0021A5F8 /* tolua_push.c */,
|
||||
F480883014E3CB6A0021A5F8 /* tolua_to.c */,
|
||||
);
|
||||
path = tolua;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
1D6058900D05DD3D006BFB54 /* HelloLua */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloLua" */;
|
||||
buildPhases = (
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */,
|
||||
1D60588E0D05DD3D006BFB54 /* Sources */,
|
||||
1D60588F0D05DD3D006BFB54 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
159A665F15904864003AEEC0 /* PBXTargetDependency */,
|
||||
);
|
||||
name = HelloLua;
|
||||
productName = HelloLua;
|
||||
productReference = 1D6058910D05DD3D006BFB54 /* HelloLua.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloLua" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = 159A6656159047B3003AEEC0 /* Products */;
|
||||
ProjectRef = 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
1D6058900D05DD3D006BFB54 /* HelloLua */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
159A665D159047B3003AEEC0 /* libcocos2dx.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libcocos2dx.a;
|
||||
remoteRef = 159A665C159047B3003AEEC0 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
78947C6D14EBB9B100DBD5A6 /* background.mp3 in Resources */,
|
||||
78947C6E14EBB9B100DBD5A6 /* crop.png in Resources */,
|
||||
78947C7014EBB9B100DBD5A6 /* dog.png in Resources */,
|
||||
78947C7114EBB9B100DBD5A6 /* effect1.wav in Resources */,
|
||||
78947C7214EBB9B100DBD5A6 /* farm.jpg in Resources */,
|
||||
78947C7414EBB9B100DBD5A6 /* hello.lua in Resources */,
|
||||
78947C7514EBB9B100DBD5A6 /* hello2.lua in Resources */,
|
||||
78947C7714EBB9B100DBD5A6 /* land.png in Resources */,
|
||||
78947C7814EBB9B100DBD5A6 /* menu1.png in Resources */,
|
||||
78947C7914EBB9B100DBD5A6 /* menu2.png in Resources */,
|
||||
78DC4C9A15490B9500317402 /* Default.png in Resources */,
|
||||
78DC4C9B15490B9500317402 /* Icon.png in Resources */,
|
||||
15DD6D83156DD1EF003E7567 /* fps_images.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
1D60588E0D05DD3D006BFB54 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BF82F41713A864D700616D55 /* AppDelegate.cpp in Sources */,
|
||||
BF82F42113A8652A00616D55 /* AppController.mm in Sources */,
|
||||
BF82F42213A8652A00616D55 /* main.m in Sources */,
|
||||
D4CEAD7913B4634300780515 /* RootViewController.mm in Sources */,
|
||||
F4808BF414E3CB6C0021A5F8 /* CCLuaEngine.cpp in Sources */,
|
||||
F4808BF514E3CB6C0021A5F8 /* Cocos2dxLuaLoader.cpp in Sources */,
|
||||
F4808BF614E3CB6C0021A5F8 /* LuaCocos2d.cpp in Sources */,
|
||||
F4808BF714E3CB6C0021A5F8 /* tolua_fix.c in Sources */,
|
||||
F4808BF814E3CB6C0021A5F8 /* lapi.c in Sources */,
|
||||
F4808BF914E3CB6C0021A5F8 /* lauxlib.c in Sources */,
|
||||
F4808BFA14E3CB6C0021A5F8 /* lbaselib.c in Sources */,
|
||||
F4808BFB14E3CB6C0021A5F8 /* lcode.c in Sources */,
|
||||
F4808BFC14E3CB6C0021A5F8 /* ldblib.c in Sources */,
|
||||
F4808BFD14E3CB6C0021A5F8 /* ldebug.c in Sources */,
|
||||
F4808BFE14E3CB6C0021A5F8 /* ldo.c in Sources */,
|
||||
F4808BFF14E3CB6C0021A5F8 /* ldump.c in Sources */,
|
||||
F4808C0014E3CB6C0021A5F8 /* lfunc.c in Sources */,
|
||||
F4808C0114E3CB6C0021A5F8 /* lgc.c in Sources */,
|
||||
F4808C0214E3CB6C0021A5F8 /* linit.c in Sources */,
|
||||
F4808C0314E3CB6C0021A5F8 /* liolib.c in Sources */,
|
||||
F4808C0414E3CB6C0021A5F8 /* llex.c in Sources */,
|
||||
F4808C0514E3CB6C0021A5F8 /* lmathlib.c in Sources */,
|
||||
F4808C0614E3CB6C0021A5F8 /* lmem.c in Sources */,
|
||||
F4808C0714E3CB6C0021A5F8 /* loadlib.c in Sources */,
|
||||
F4808C0814E3CB6C0021A5F8 /* lobject.c in Sources */,
|
||||
F4808C0914E3CB6C0021A5F8 /* lopcodes.c in Sources */,
|
||||
F4808C0A14E3CB6C0021A5F8 /* loslib.c in Sources */,
|
||||
F4808C0B14E3CB6C0021A5F8 /* lparser.c in Sources */,
|
||||
F4808C0C14E3CB6C0021A5F8 /* lstate.c in Sources */,
|
||||
F4808C0D14E3CB6C0021A5F8 /* lstring.c in Sources */,
|
||||
F4808C0E14E3CB6C0021A5F8 /* lstrlib.c in Sources */,
|
||||
F4808C0F14E3CB6C0021A5F8 /* ltable.c in Sources */,
|
||||
F4808C1014E3CB6C0021A5F8 /* ltablib.c in Sources */,
|
||||
F4808C1114E3CB6C0021A5F8 /* ltm.c in Sources */,
|
||||
F4808C1214E3CB6C0021A5F8 /* lua.c in Sources */,
|
||||
F4808C1314E3CB6C0021A5F8 /* lundump.c in Sources */,
|
||||
F4808C1414E3CB6C0021A5F8 /* lvm.c in Sources */,
|
||||
F4808C1514E3CB6C0021A5F8 /* lzio.c in Sources */,
|
||||
F4808C1614E3CB6C0021A5F8 /* print.c in Sources */,
|
||||
F4808C1D14E3CB6C0021A5F8 /* tolua_event.c in Sources */,
|
||||
F4808C1E14E3CB6C0021A5F8 /* tolua_is.c in Sources */,
|
||||
F4808C1F14E3CB6C0021A5F8 /* tolua_map.c in Sources */,
|
||||
F4808C2014E3CB6C0021A5F8 /* tolua_push.c in Sources */,
|
||||
F4808C2114E3CB6C0021A5F8 /* tolua_to.c in Sources */,
|
||||
78947C8B14EBBB0300DBD5A6 /* CDAudioManager.m in Sources */,
|
||||
78947C8C14EBBB0300DBD5A6 /* CDOpenALSupport.m in Sources */,
|
||||
78947C8D14EBBB0300DBD5A6 /* CocosDenshion.m in Sources */,
|
||||
78947C8E14EBBB0300DBD5A6 /* SimpleAudioEngine.mm in Sources */,
|
||||
78947C8F14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
159A665F15904864003AEEC0 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = cocos2dx;
|
||||
targetProxy = 159A665E15904864003AEEC0 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1D6058940D05DD3E006BFB54 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_FAST_OBJC_DISPATCH = YES;
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_OBJC_CALL_CXX_CDTORS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = HelloLua_Prefix.pch;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
USE_FILE32API,
|
||||
TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"\"$(SDKROOT)/usr/include/libxml2/\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/kazmath/include\"",
|
||||
"\"$(SRCROOT)/../../lua/tolua\"",
|
||||
"\"$(SRCROOT)/../../lua/src\"",
|
||||
"$(SRCROOT)/../../lua/cocos2dx_support",
|
||||
"$(SRCROOT)/../../cocos2dx/platform/ios",
|
||||
"$(SRCROOT)/../../cocos2dx/include",
|
||||
);
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/../../cocos2dx/platform/third_party/ios/libraries\"",
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LDFLAGS = (
|
||||
"-ObjC",
|
||||
"-all_load",
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = HelloLua;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = NO;
|
||||
WARNING_CFLAGS = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1D6058950D05DD3E006BFB54 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_FAST_OBJC_DISPATCH = YES;
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_OBJC_CALL_CXX_CDTORS = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = HelloLua_Prefix.pch;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
USE_FILE32API,
|
||||
TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"\"$(SDKROOT)/usr/include/libxml2/\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/kazmath/include\"",
|
||||
"\"$(SRCROOT)/../../lua/tolua\"",
|
||||
"\"$(SRCROOT)/../../lua/src\"",
|
||||
"$(SRCROOT)/../../lua/cocos2dx_support",
|
||||
"$(SRCROOT)/../../cocos2dx/platform/ios",
|
||||
"$(SRCROOT)/../../cocos2dx/include",
|
||||
);
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/../../cocos2dx/platform/third_party/ios/libraries\"",
|
||||
);
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
OTHER_LDFLAGS = (
|
||||
"-ObjC",
|
||||
"-all_load",
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = HelloLua;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = NO;
|
||||
WARNING_CFLAGS = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C01FCF4F08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
DEBUG,
|
||||
"COCOS2D_DEBUG=1",
|
||||
"CD_DEBUG=1",
|
||||
);
|
||||
"GCC_THUMB_SUPPORT[arch=armv6]" = NO;
|
||||
"GCC_THUMB_SUPPORT[arch=armv7]" = YES;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALID_ARCHS = "armv6 armv7 i386";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF5008A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
"GCC_THUMB_SUPPORT[arch=armv6]" = NO;
|
||||
"GCC_THUMB_SUPPORT[arch=armv7]" = YES;
|
||||
GCC_UNROLL_LOOPS = YES;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALID_ARCHS = "armv6 armv7 i386";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloLua" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1D6058940D05DD3E006BFB54 /* Debug */,
|
||||
1D6058950D05DD3E006BFB54 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloLua" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247B /* Debug */,
|
||||
C01FCF5008A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
842462907b895bea8fcf8fc4a567560e546e440f
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -49,15 +49,15 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\Classes;"$(SolutionDir)\lua\cocos2dx_support";"$(SolutionDir)\lua\CocosDenshion_support";"$(SolutionDir)\lua\lua";"$(SolutionDir)\lua\tolua";"$(SolutionDir)\lua\src";.;"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\actions";"$(SolutionDir)cocos2dx\base_nodes";"$(SolutionDir)cocos2dx\cocoa";"$(SolutionDir)cocos2dx\effects";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\keypad_dispatcher";"$(SolutionDir)cocos2dx\label_nodes";"$(SolutionDir)cocos2dx\layers_scenes_transitions_nodes";"$(SolutionDir)cocos2dx\menu_nodes";"$(SolutionDir)cocos2dx\misc_nodes";"$(SolutionDir)cocos2dx\particle_nodes";"$(SolutionDir)cocos2dx\script_support";"$(SolutionDir)cocos2dx\shaders";"$(SolutionDir)cocos2dx\sprite_nodes";"$(SolutionDir)cocos2dx\support";"$(SolutionDir)cocos2dx\text_input_node";"$(SolutionDir)cocos2dx\textures";"$(SolutionDir)cocos2dx\tileMap_parallax_nodes";"$(SolutionDir)cocos2dx\touch_dispatcher";"$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";"$(SolutionDir)CocosDenshion\include""
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1"
|
||||
AdditionalIncludeDirectories="..\Classes;"$(SolutionDir)\lua\cocos2dx_support";"$(SolutionDir)\lua\CocosDenshion_support";"$(SolutionDir)\lua\lua";"$(SolutionDir)\lua\tolua";"$(SolutionDir)\lua\src";.;"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";"$(SolutionDir)CocosDenshion\include""
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4251"
|
||||
DisableSpecificWarnings="4267;4251;4244"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -73,7 +73,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libcocos2d.lib libCocosDenshion.lib libGLESv2.lib liblua.lib"
|
||||
AdditionalDependencies="libcocos2d.lib libCocosDenshion.lib opengl32.lib glew32.lib liblua.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="$(OutDir)"
|
||||
GenerateDebugInformation="true"
|
||||
|
@ -107,7 +107,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -135,14 +135,14 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\Classes;"$(SolutionDir)lua\cocos2dx_support";"$(SolutionDir)lua\CocosDenshion_support";"$(SolutionDir)lua\tolua";"$(SolutionDir)lua\lua";"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";"$(SolutionDir)CocosDenshion\Include""
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;NDEBUG"
|
||||
AdditionalIncludeDirectories="..\Classes;"$(SolutionDir)\lua\cocos2dx_support";"$(SolutionDir)\lua\CocosDenshion_support";"$(SolutionDir)\lua\lua";"$(SolutionDir)\lua\tolua";"$(SolutionDir)\lua\src";.;"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";"$(SolutionDir)CocosDenshion\include""
|
||||
PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;NDEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="0"
|
||||
DisableSpecificWarnings="4251"
|
||||
DisableSpecificWarnings="4267;4251;4244"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -158,7 +158,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libcocos2d.lib libCocosDenshion.lib libgles_cm.lib liblua.lib"
|
||||
AdditionalDependencies="libcocos2d.lib libCocosDenshion.lib opengl32.lib glew32.lib liblua.lib"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="$(OutDir)"
|
||||
SubSystem="2"
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
@ -64,8 +64,8 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;ENABLE_LUA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -73,7 +73,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -102,8 +102,8 @@
|
|||
<ProxyFileName>HelloLua_p.c</ProxyFileName>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;NDEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ExceptionHandling>
|
||||
</ExceptionHandling>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
|
@ -112,7 +112,7 @@
|
|||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>
|
||||
</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
@ -120,7 +120,7 @@
|
|||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libcocos2d.lib;libCocosDenshion.lib;libgles_cm.lib;liblua.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>libcocos2d.lib;libCocosDenshion.lib;liblua.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#include "AppDelegate.h"
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "HelloWorldScene.h"
|
||||
|
||||
#include "CCEGLView.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
AppDelegate::AppDelegate() {
|
||||
|
@ -27,8 +23,6 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|||
// turn on display FPS
|
||||
pDirector->setDisplayStats(true);
|
||||
|
||||
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||
|
||||
// set FPS. the default value is 1.0/60 if you don't call this
|
||||
pDirector->setAnimationInterval(1.0 / 60);
|
||||
|
||||
|
@ -43,7 +37,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
|||
|
||||
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||
void AppDelegate::applicationDidEnterBackground() {
|
||||
CCDirector::sharedDirector()->pause();
|
||||
CCDirector::sharedDirector()->stopAnimation();
|
||||
|
||||
// if you use SimpleAudioEngine, it must be pause
|
||||
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
|
||||
|
@ -51,7 +45,7 @@ void AppDelegate::applicationDidEnterBackground() {
|
|||
|
||||
// this function will be called when the app is active again
|
||||
void AppDelegate::applicationWillEnterForeground() {
|
||||
CCDirector::sharedDirector()->resume();
|
||||
CCDirector::sharedDirector()->startAnimation();
|
||||
|
||||
// if you use SimpleAudioEngine, it must resume here
|
||||
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _APP_DELEGATE_H_
|
||||
#define _APP_DELEGATE_H_
|
||||
|
||||
#include "CCApplication.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
/**
|
||||
@brief The cocos2d Application.
|
||||
|
|
|
@ -5,10 +5,10 @@ USING_NS_CC;
|
|||
CCScene* HelloWorld::scene()
|
||||
{
|
||||
// 'scene' is an autorelease object
|
||||
CCScene *scene = CCScene::node();
|
||||
CCScene *scene = CCScene::create();
|
||||
|
||||
// 'layer' is an autorelease object
|
||||
HelloWorld *layer = HelloWorld::node();
|
||||
HelloWorld *layer = HelloWorld::create();
|
||||
|
||||
// add layer as a child to scene
|
||||
scene->addChild(layer);
|
||||
|
@ -32,7 +32,7 @@ bool HelloWorld::init()
|
|||
// you may modify it.
|
||||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage(
|
||||
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
|
||||
"CloseNormal.png",
|
||||
"CloseSelected.png",
|
||||
this,
|
||||
|
@ -40,7 +40,7 @@ bool HelloWorld::init()
|
|||
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
|
||||
|
||||
// create menu, it's an autorelease object
|
||||
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
|
||||
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
this->addChild(pMenu, 1);
|
||||
|
||||
|
@ -49,7 +49,7 @@ bool HelloWorld::init()
|
|||
|
||||
// add a label shows "Hello World"
|
||||
// create and initialize a label
|
||||
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24);
|
||||
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
|
||||
// ask director the window size
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
|
@ -60,7 +60,7 @@ bool HelloWorld::init()
|
|||
this->addChild(pLabel, 1);
|
||||
|
||||
// add "HelloWorld" splash screen"
|
||||
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");
|
||||
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
|
||||
|
||||
// position the sprite on the center of the screen
|
||||
pSprite->setPosition( ccp(size.width/2, size.height/2) );
|
||||
|
|
|
@ -13,10 +13,10 @@ public:
|
|||
static cocos2d::CCScene* scene();
|
||||
|
||||
// a selector callback
|
||||
virtual void menuCloseCallback(CCObject* pSender);
|
||||
void menuCloseCallback(CCObject* pSender);
|
||||
|
||||
// implement the "static node()" method manually
|
||||
LAYER_NODE_FUNC(HelloWorld);
|
||||
LAYER_CREATE_FUNC(HelloWorld);
|
||||
};
|
||||
|
||||
#endif // __HELLOWORLD_SCENE_H__
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[Trace]
|
||||
GAME <0 or 1> Game Channel
|
||||
|
||||
[Assert]
|
||||
GAME <0 or 1> Game Assert Channel
|
|
@ -1,17 +0,0 @@
|
|||
[S3E]
|
||||
MemSize=4000000
|
||||
#MemFlags0=USE_STACK_ALLOCATOR
|
||||
#SysStackSwitch=1
|
||||
#landscape
|
||||
#DispFixRot=2
|
||||
#or portrait
|
||||
#DispFixRot=1
|
||||
#autorotate
|
||||
#DispFixRot=0
|
||||
# fix for new ati drivers in simulator
|
||||
# DisableGL=1
|
||||
|
||||
[Trace]
|
||||
GAME=1
|
||||
IW_GL=1
|
||||
IW_GL_VERBOSE=1
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="src" path="src_common"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>HelloWorld</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>src_common</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/cocos2dx/platform/android/java/src_common</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="HelloWorld" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
|
||||
<!-- extension targets. Uncomment the ones where you want to do custom work
|
||||
in between standard targets -->
|
||||
<!--
|
||||
<target name="-pre-build">
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
</target>
|
||||
|
||||
/* This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir} */
|
||||
<target name="-post-compile">
|
||||
</target>
|
||||
-->
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
|
@ -60,6 +60,9 @@ cp $file $HELLOWORLD_ROOT/assets
|
|||
fi
|
||||
done
|
||||
|
||||
# Change the authority of Resources folder.
|
||||
chmod -R 666 $HELLOWORLD_ROOT/assets
|
||||
|
||||
if [[ $buildexternalsfromsource ]]; then
|
||||
echo "Building external dependencies from source"
|
||||
$NDK_ROOT_LOCAL/ndk-build -C $HELLOWORLD_ROOT $* \
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package org.cocos2dx.application;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int icon=0x7f020000;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int helloworld_gl_surfaceview=0x7f050001;
|
||||
public static final int textField=0x7f050000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int helloworld_demo=0x7f030000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040000;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
#include "AppDelegate.h"
|
||||
#include "cocos2d.h"
|
||||
#include "platform/android/jni/JniHelper.h"
|
||||
#include "CCEventType.h"
|
||||
#include <jni.h>
|
||||
#include <android/log.h>
|
||||
|
||||
|
@ -30,7 +28,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
|||
CCEGLView *view = &CCEGLView::sharedOpenGLView();
|
||||
view->setFrameSize(w, h);
|
||||
// set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line.
|
||||
// view.setDesignResolutionSize(480, 320);
|
||||
// view->setDesignResolutionSize(480, 320);
|
||||
|
||||
AppDelegate *pAppDelegate = new AppDelegate();
|
||||
CCApplication::sharedApplication().run();
|
||||
|
|
|
@ -8,4 +8,6 @@
|
|||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-10
|
||||
target=android-8
|
||||
|
||||
android.library.reference.1=../../cocos2dx/platform/android/java
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.cocos2dx.lib.Cocos2dxEditText
|
||||
android:id="@+id/textField"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@null"/>
|
||||
|
||||
<org.cocos2dx.lib.Cocos2dxGLSurfaceView
|
||||
android:id="@+id/helloworld_gl_surfaceview"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -33,6 +33,8 @@ import android.content.Context;
|
|||
import android.content.pm.ConfigurationInfo;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.FrameLayout;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
public class ApplicationDemo extends Cocos2dxActivity{
|
||||
private Cocos2dxGLSurfaceView mGLView;
|
||||
|
@ -45,11 +47,35 @@ public class ApplicationDemo extends Cocos2dxActivity{
|
|||
String packageName = getApplication().getPackageName();
|
||||
super.setPackageName(packageName);
|
||||
|
||||
setContentView(R.layout.helloworld_demo);
|
||||
mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.helloworld_gl_surfaceview);
|
||||
mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.textField));
|
||||
// FrameLayout
|
||||
ViewGroup.LayoutParams framelayout_params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.FILL_PARENT);
|
||||
FrameLayout framelayout = new FrameLayout(this);
|
||||
framelayout.setLayoutParams(framelayout_params);
|
||||
|
||||
// Cocos2dxEditText layout
|
||||
ViewGroup.LayoutParams edittext_layout_params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
Cocos2dxEditText edittext = new Cocos2dxEditText(this);
|
||||
edittext.setLayoutParams(edittext_layout_params);
|
||||
|
||||
// ...add to FrameLayout
|
||||
framelayout.addView(edittext);
|
||||
|
||||
// Cocos2dxGLSurfaceView
|
||||
mGLView = new Cocos2dxGLSurfaceView(this);
|
||||
|
||||
// ...add to FrameLayout
|
||||
framelayout.addView(mGLView);
|
||||
|
||||
mGLView.setEGLContextClientVersion(2);
|
||||
mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
||||
mGLView.setTextField(edittext);
|
||||
|
||||
// Set framelayout as the content view
|
||||
setContentView(framelayout);
|
||||
}
|
||||
else {
|
||||
Log.d("activity", "don't support gles2.0");
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for controlling the Accelerometer
|
||||
*
|
||||
*/
|
||||
public class Cocos2dxAccelerometer implements SensorEventListener {
|
||||
|
||||
private static final String TAG = "Cocos2dxAccelerometer";
|
||||
private Context mContext;
|
||||
private SensorManager mSensorManager;
|
||||
private Sensor mAccelerometer;
|
||||
private int mNaturalOrientation;
|
||||
|
||||
public Cocos2dxAccelerometer(Context context){
|
||||
mContext = context;
|
||||
|
||||
//Get an instance of the SensorManager
|
||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
|
||||
Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||
mNaturalOrientation = display.getOrientation();
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
|
||||
public void disable () {
|
||||
mSensorManager.unregisterListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
|
||||
if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER){
|
||||
return;
|
||||
}
|
||||
|
||||
float x = event.values[0];
|
||||
float y = event.values[1];
|
||||
float z = event.values[2];
|
||||
|
||||
/*
|
||||
* Because the axes are not swapped when the device's screen orientation changes.
|
||||
* So we should swap it here.
|
||||
* In tablets such as Motorola Xoom, the default orientation is landscape, so should
|
||||
* consider this.
|
||||
*/
|
||||
int orientation = mContext.getResources().getConfiguration().orientation;
|
||||
if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)){
|
||||
float tmp = x;
|
||||
x = -y;
|
||||
y = tmp;
|
||||
}
|
||||
else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0))
|
||||
{
|
||||
float tmp = x;
|
||||
x = y;
|
||||
y = -tmp;
|
||||
}
|
||||
|
||||
onSensorChanged(x, y, z, event.timestamp);
|
||||
// Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
|
||||
private static native void onSensorChanged(float x, float y, float z, long timeStamp);
|
||||
}
|
|
@ -1,253 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
public class Cocos2dxActivity extends Activity{
|
||||
private static Cocos2dxMusic backgroundMusicPlayer;
|
||||
private static Cocos2dxSound soundPlayer;
|
||||
private static Cocos2dxAccelerometer accelerometer;
|
||||
private static boolean accelerometerEnabled = false;
|
||||
private static Handler handler;
|
||||
private final static int HANDLER_SHOW_DIALOG = 1;
|
||||
private static String packageName;
|
||||
|
||||
private static native void nativeSetPaths(String apkPath);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// get frame size
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
accelerometer = new Cocos2dxAccelerometer(this);
|
||||
|
||||
// init media player and sound player
|
||||
backgroundMusicPlayer = new Cocos2dxMusic(this);
|
||||
soundPlayer = new Cocos2dxSound(this);
|
||||
|
||||
// init bitmap context
|
||||
Cocos2dxBitmap.setContext(this);
|
||||
|
||||
handler = new Handler(){
|
||||
public void handleMessage(Message msg){
|
||||
switch(msg.what){
|
||||
case HANDLER_SHOW_DIALOG:
|
||||
showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static String getCurrentLanguage() {
|
||||
String languageName = java.util.Locale.getDefault().getLanguage();
|
||||
return languageName;
|
||||
}
|
||||
|
||||
public static void showMessageBox(String title, String message){
|
||||
Message msg = new Message();
|
||||
msg.what = HANDLER_SHOW_DIALOG;
|
||||
msg.obj = new DialogMessage(title, message);
|
||||
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
|
||||
public static void enableAccelerometer() {
|
||||
accelerometerEnabled = true;
|
||||
accelerometer.enable();
|
||||
}
|
||||
|
||||
public static void disableAccelerometer() {
|
||||
accelerometerEnabled = false;
|
||||
accelerometer.disable();
|
||||
}
|
||||
|
||||
public static void preloadBackgroundMusic(String path){
|
||||
backgroundMusicPlayer.preloadBackgroundMusic(path);
|
||||
}
|
||||
|
||||
public static void playBackgroundMusic(String path, boolean isLoop){
|
||||
backgroundMusicPlayer.playBackgroundMusic(path, isLoop);
|
||||
}
|
||||
|
||||
public static void stopBackgroundMusic(){
|
||||
backgroundMusicPlayer.stopBackgroundMusic();
|
||||
}
|
||||
|
||||
public static void pauseBackgroundMusic(){
|
||||
backgroundMusicPlayer.pauseBackgroundMusic();
|
||||
}
|
||||
|
||||
public static void resumeBackgroundMusic(){
|
||||
backgroundMusicPlayer.resumeBackgroundMusic();
|
||||
}
|
||||
|
||||
public static void rewindBackgroundMusic(){
|
||||
backgroundMusicPlayer.rewindBackgroundMusic();
|
||||
}
|
||||
|
||||
public static boolean isBackgroundMusicPlaying(){
|
||||
return backgroundMusicPlayer.isBackgroundMusicPlaying();
|
||||
}
|
||||
|
||||
public static float getBackgroundMusicVolume(){
|
||||
return backgroundMusicPlayer.getBackgroundVolume();
|
||||
}
|
||||
|
||||
public static void setBackgroundMusicVolume(float volume){
|
||||
backgroundMusicPlayer.setBackgroundVolume(volume);
|
||||
}
|
||||
|
||||
public static int playEffect(String path, boolean isLoop){
|
||||
return soundPlayer.playEffect(path, isLoop);
|
||||
}
|
||||
|
||||
public static void stopEffect(int soundId){
|
||||
soundPlayer.stopEffect(soundId);
|
||||
}
|
||||
|
||||
public static void pauseEffect(int soundId){
|
||||
soundPlayer.pauseEffect(soundId);
|
||||
}
|
||||
|
||||
public static void resumeEffect(int soundId){
|
||||
soundPlayer.resumeEffect(soundId);
|
||||
}
|
||||
|
||||
public static float getEffectsVolume(){
|
||||
return soundPlayer.getEffectsVolume();
|
||||
}
|
||||
|
||||
public static void setEffectsVolume(float volume){
|
||||
soundPlayer.setEffectsVolume(volume);
|
||||
}
|
||||
|
||||
public static void preloadEffect(String path){
|
||||
soundPlayer.preloadEffect(path);
|
||||
}
|
||||
|
||||
public static void unloadEffect(String path){
|
||||
soundPlayer.unloadEffect(path);
|
||||
}
|
||||
|
||||
public static void stopAllEffects(){
|
||||
soundPlayer.stopAllEffects();
|
||||
}
|
||||
|
||||
public static void pauseAllEffects(){
|
||||
soundPlayer.pauseAllEffects();
|
||||
}
|
||||
|
||||
public static void resumeAllEffects(){
|
||||
soundPlayer.resumeAllEffects();
|
||||
}
|
||||
|
||||
public static void end(){
|
||||
backgroundMusicPlayer.end();
|
||||
soundPlayer.end();
|
||||
}
|
||||
|
||||
public static String getCocos2dxPackageName(){
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public static void terminateProcess(){
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (accelerometerEnabled) {
|
||||
accelerometer.enable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (accelerometerEnabled) {
|
||||
accelerometer.disable();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setPackageName(String packageName) {
|
||||
Cocos2dxActivity.packageName = packageName;
|
||||
|
||||
String apkFilePath = "";
|
||||
ApplicationInfo appInfo = null;
|
||||
PackageManager packMgmr = getApplication().getPackageManager();
|
||||
try {
|
||||
appInfo = packMgmr.getApplicationInfo(packageName, 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
Log.w("apk path", apkFilePath);
|
||||
|
||||
// add this link at the renderer class
|
||||
nativeSetPaths(apkFilePath);
|
||||
}
|
||||
|
||||
private void showDialog(String title, String message){
|
||||
Dialog dialog = new AlertDialog.Builder(this)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton("Ok",
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int whichButton){
|
||||
|
||||
}
|
||||
}).create();
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
class DialogMessage {
|
||||
public String title;
|
||||
public String message;
|
||||
|
||||
public DialogMessage(String title, String message){
|
||||
this.message = message;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
|
@ -1,381 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.FontMetricsInt;
|
||||
import android.util.Log;
|
||||
|
||||
public class Cocos2dxBitmap{
|
||||
/*
|
||||
* The values are the same as cocos2dx/platform/CCImage.h.
|
||||
* I think three alignments are OK.
|
||||
*/
|
||||
private static final int ALIGNCENTER = 0x33;
|
||||
private static final int ALIGNLEFT = 0x31;
|
||||
private static final int ALIGNRIGHT = 0x32;
|
||||
|
||||
private static Context context;
|
||||
|
||||
public static void setContext(Context context){
|
||||
Cocos2dxBitmap.context = context;
|
||||
}
|
||||
|
||||
/*
|
||||
* @width: the width to draw, it can be 0
|
||||
* @height: the height to draw, it can be 0
|
||||
*/
|
||||
public static void createTextBitmap(String content, String fontName,
|
||||
int fontSize, int alignment, int width, int height){
|
||||
|
||||
content = refactorString(content);
|
||||
Paint paint = newPaint(fontName, fontSize, alignment);
|
||||
|
||||
TextProperty textProperty = computeTextProperty(content, paint, width, height);
|
||||
|
||||
int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height);
|
||||
|
||||
// Draw text to bitmap
|
||||
Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth,
|
||||
bitmapTotalHeight, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
|
||||
// Draw string
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int x = 0;
|
||||
int y = height == 0 ?(-fm.top):
|
||||
(-fm.top + (height - textProperty.totalHeight)/2);
|
||||
String[] lines = textProperty.lines;
|
||||
for (String line : lines){
|
||||
x = computeX(paint, line, textProperty.maxWidth, alignment);
|
||||
canvas.drawText(line, x, y, paint);
|
||||
y += textProperty.heightPerLine;
|
||||
}
|
||||
|
||||
initNativeObject(bitmap);
|
||||
}
|
||||
|
||||
private static int computeX(Paint paint, String content, int w, int alignment){
|
||||
int ret = 0;
|
||||
|
||||
switch (alignment){
|
||||
case ALIGNCENTER:
|
||||
ret = w / 2;
|
||||
break;
|
||||
|
||||
// ret = 0
|
||||
case ALIGNLEFT:
|
||||
break;
|
||||
|
||||
case ALIGNRIGHT:
|
||||
ret = w;
|
||||
break;
|
||||
|
||||
/*
|
||||
* Default is align left.
|
||||
* Should be same as newPaint().
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static class TextProperty{
|
||||
// The max width of lines
|
||||
int maxWidth;
|
||||
// The height of all lines
|
||||
int totalHeight;
|
||||
int heightPerLine;
|
||||
String[] lines;
|
||||
|
||||
TextProperty(int w, int h, String[] lines){
|
||||
this.maxWidth = w;
|
||||
this.heightPerLine = h;
|
||||
this.totalHeight = h * lines.length;
|
||||
this.lines = lines;
|
||||
}
|
||||
}
|
||||
|
||||
private static TextProperty computeTextProperty(String content, Paint paint,
|
||||
int maxWidth, int maxHeight){
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int h = (int)Math.ceil(fm.bottom - fm.top);
|
||||
int maxContentWidth = 0;
|
||||
|
||||
String[] lines = splitString(content, maxHeight, maxWidth, paint);
|
||||
|
||||
if (maxWidth != 0){
|
||||
maxContentWidth = maxWidth;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Compute the max width
|
||||
*/
|
||||
int temp = 0;
|
||||
for (String line : lines){
|
||||
temp = (int)Math.ceil(paint.measureText(line, 0, line.length()));
|
||||
if (temp > maxContentWidth){
|
||||
maxContentWidth = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TextProperty(maxContentWidth, h, lines);
|
||||
}
|
||||
|
||||
/*
|
||||
* If maxWidth or maxHeight is not 0,
|
||||
* split the string to fix the maxWidth and maxHeight.
|
||||
*/
|
||||
private static String[] splitString(String content, int maxHeight, int maxWidth,
|
||||
Paint paint){
|
||||
String[] lines = content.split("\\n");
|
||||
String[] ret = null;
|
||||
FontMetricsInt fm = paint.getFontMetricsInt();
|
||||
int heightPerLine = (int)Math.ceil(fm.bottom - fm.top);
|
||||
int maxLines = maxHeight / heightPerLine;
|
||||
|
||||
if (maxWidth != 0){
|
||||
LinkedList<String> strList = new LinkedList<String>();
|
||||
for (String line : lines){
|
||||
/*
|
||||
* The width of line is exceed maxWidth, should divide it into
|
||||
* two or more lines.
|
||||
*/
|
||||
int lineWidth = (int)Math.ceil(paint.measureText(line));
|
||||
if (lineWidth > maxWidth){
|
||||
strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth));
|
||||
}
|
||||
else{
|
||||
strList.add(line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Should not exceed the max height;
|
||||
*/
|
||||
if (maxLines > 0 && strList.size() >= maxLines){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove exceeding lines
|
||||
*/
|
||||
if (maxLines > 0 && strList.size() > maxLines){
|
||||
while (strList.size() > maxLines){
|
||||
strList.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
ret = new String[strList.size()];
|
||||
strList.toArray(ret);
|
||||
} else
|
||||
if (maxHeight != 0 && lines.length > maxLines) {
|
||||
/*
|
||||
* Remove exceeding lines
|
||||
*/
|
||||
LinkedList<String> strList = new LinkedList<String>();
|
||||
for (int i = 0; i < maxLines; i++){
|
||||
strList.add(lines[i]);
|
||||
}
|
||||
ret = new String[strList.size()];
|
||||
strList.toArray(ret);
|
||||
}
|
||||
else {
|
||||
ret = lines;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static LinkedList<String> divideStringWithMaxWidth(Paint paint, String content,
|
||||
int width){
|
||||
int charLength = content.length();
|
||||
int start = 0;
|
||||
int tempWidth = 0;
|
||||
LinkedList<String> strList = new LinkedList<String>();
|
||||
|
||||
/*
|
||||
* Break a String into String[] by the width & should wrap the word
|
||||
*/
|
||||
for (int i = 1; i <= charLength; ++i){
|
||||
tempWidth = (int)Math.ceil(paint.measureText(content, start, i));
|
||||
if (tempWidth >= width){
|
||||
int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" ");
|
||||
|
||||
if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){
|
||||
/**
|
||||
* Should wrap the word
|
||||
*/
|
||||
strList.add(content.substring(start, lastIndexOfSpace));
|
||||
i = lastIndexOfSpace;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Should not exceed the width
|
||||
*/
|
||||
if (tempWidth > width){
|
||||
strList.add(content.substring(start, i - 1));
|
||||
/*
|
||||
* compute from previous char
|
||||
*/
|
||||
--i;
|
||||
}
|
||||
else {
|
||||
strList.add(content.substring(start, i));
|
||||
}
|
||||
}
|
||||
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the last chars
|
||||
*/
|
||||
if (start < charLength){
|
||||
strList.add(content.substring(start));
|
||||
}
|
||||
|
||||
return strList;
|
||||
}
|
||||
|
||||
private static Paint newPaint(String fontName, int fontSize, int alignment){
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(Color.WHITE);
|
||||
paint.setTextSize(fontSize);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
/*
|
||||
* Set type face for paint, now it support .ttf file.
|
||||
*/
|
||||
if (fontName.endsWith(".ttf")){
|
||||
try {
|
||||
//Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName);
|
||||
Typeface typeFace = Cocos2dxTypefaces.get(context, fontName);
|
||||
paint.setTypeface(typeFace);
|
||||
} catch (Exception e){
|
||||
Log.e("Cocos2dxBitmap",
|
||||
"error to create ttf type face: " + fontName);
|
||||
|
||||
/*
|
||||
* The file may not find, use system font
|
||||
*/
|
||||
paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL));
|
||||
}
|
||||
}
|
||||
else {
|
||||
paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL));
|
||||
}
|
||||
|
||||
switch (alignment){
|
||||
case ALIGNCENTER:
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
break;
|
||||
|
||||
case ALIGNLEFT:
|
||||
paint.setTextAlign(Align.LEFT);
|
||||
break;
|
||||
|
||||
case ALIGNRIGHT:
|
||||
paint.setTextAlign(Align.RIGHT);
|
||||
break;
|
||||
|
||||
default:
|
||||
paint.setTextAlign(Align.LEFT);
|
||||
break;
|
||||
}
|
||||
|
||||
return paint;
|
||||
}
|
||||
|
||||
private static String refactorString(String str){
|
||||
// Avoid error when content is ""
|
||||
if (str.compareTo("") == 0){
|
||||
return " ";
|
||||
}
|
||||
|
||||
/*
|
||||
* If the font of "\n" is "" or "\n", insert " " in front of it.
|
||||
*
|
||||
* For example:
|
||||
* "\nabc" -> " \nabc"
|
||||
* "\nabc\n\n" -> " \nabc\n \n"
|
||||
*/
|
||||
StringBuilder strBuilder = new StringBuilder(str);
|
||||
int start = 0;
|
||||
int index = strBuilder.indexOf("\n");
|
||||
while (index != -1){
|
||||
if (index == 0 || strBuilder.charAt(index -1) == '\n'){
|
||||
strBuilder.insert(start, " ");
|
||||
start = index + 2;
|
||||
} else {
|
||||
start = index + 1;
|
||||
}
|
||||
|
||||
if (start > strBuilder.length() || index == strBuilder.length()){
|
||||
break;
|
||||
}
|
||||
|
||||
index = strBuilder.indexOf("\n", start);
|
||||
}
|
||||
|
||||
return strBuilder.toString();
|
||||
}
|
||||
|
||||
private static void initNativeObject(Bitmap bitmap){
|
||||
byte[] pixels = getPixels(bitmap);
|
||||
if (pixels == null){
|
||||
return;
|
||||
}
|
||||
|
||||
nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels);
|
||||
}
|
||||
|
||||
private static byte[] getPixels(Bitmap bitmap){
|
||||
if (bitmap != null){
|
||||
byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4];
|
||||
ByteBuffer buf = ByteBuffer.wrap(pixels);
|
||||
buf.order(ByteOrder.nativeOrder());
|
||||
bitmap.copyPixelsToBuffer(buf);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static native void nativeInitBitmapDC(int width, int height, byte[] pixels);
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2012 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class Cocos2dxEditText extends EditText {
|
||||
|
||||
private Cocos2dxGLSurfaceView mView;
|
||||
|
||||
public Cocos2dxEditText(Context context) {
|
||||
super(context);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Cocos2dxEditText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public Cocos2dxEditText(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
public void setMainView(Cocos2dxGLSurfaceView glSurfaceView) {
|
||||
mView = glSurfaceView;
|
||||
}
|
||||
|
||||
/*
|
||||
* Let GlSurfaceView get focus if back key is input
|
||||
*/
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
super.onKeyDown(keyCode, event);
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
mView.requestFocus();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,417 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
|
||||
class TextInputWraper implements TextWatcher, OnEditorActionListener {
|
||||
|
||||
private static final Boolean debug = false;
|
||||
private void LogD(String msg) {
|
||||
if (debug) Log.d("TextInputFilter", msg);
|
||||
}
|
||||
|
||||
private Cocos2dxGLSurfaceView mMainView;
|
||||
private String mText;
|
||||
private String mOriginText;
|
||||
|
||||
private Boolean isFullScreenEdit() {
|
||||
InputMethodManager imm = (InputMethodManager)mMainView.getTextField().getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
return imm.isFullscreenMode();
|
||||
}
|
||||
|
||||
public TextInputWraper(Cocos2dxGLSurfaceView view) {
|
||||
mMainView = view;
|
||||
}
|
||||
|
||||
public void setOriginText(String text) {
|
||||
mOriginText = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (isFullScreenEdit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LogD("afterTextChanged: " + s);
|
||||
int nModified = s.length() - mText.length();
|
||||
if (nModified > 0) {
|
||||
final String insertText = s.subSequence(mText.length(), s.length()).toString();
|
||||
mMainView.insertText(insertText);
|
||||
LogD("insertText(" + insertText + ")");
|
||||
}
|
||||
else {
|
||||
for (; nModified < 0; ++nModified) {
|
||||
mMainView.deleteBackward();
|
||||
LogD("deleteBackward");
|
||||
}
|
||||
}
|
||||
mText = s.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
int after) {
|
||||
LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after);
|
||||
mText = s.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (mMainView.getTextField() == v && isFullScreenEdit()) {
|
||||
// user press the action button, delete all old text and insert new text
|
||||
for (int i = mOriginText.length(); i > 0; --i) {
|
||||
mMainView.deleteBackward();
|
||||
LogD("deleteBackward");
|
||||
}
|
||||
String text = v.getText().toString();
|
||||
|
||||
/*
|
||||
* If user input nothing, translate "\n" to engine.
|
||||
*/
|
||||
if (text.compareTo("") == 0){
|
||||
text = "\n";
|
||||
}
|
||||
|
||||
if ('\n' != text.charAt(text.length() - 1)) {
|
||||
text += '\n';
|
||||
}
|
||||
|
||||
final String insertText = text;
|
||||
mMainView.insertText(insertText);
|
||||
LogD("insertText(" + insertText + ")");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class Cocos2dxGLSurfaceView extends GLSurfaceView {
|
||||
|
||||
static private Cocos2dxGLSurfaceView mainView;
|
||||
|
||||
private static final String TAG = Cocos2dxGLSurfaceView.class.getCanonicalName();
|
||||
private Cocos2dxRenderer mRenderer;
|
||||
|
||||
private static final boolean debug = false;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// for initialize
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
public Cocos2dxGLSurfaceView(Context context) {
|
||||
super(context);
|
||||
initView();
|
||||
}
|
||||
|
||||
public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView();
|
||||
}
|
||||
|
||||
public void setCocos2dxRenderer(Cocos2dxRenderer renderer){
|
||||
mRenderer = renderer;
|
||||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
protected void initView() {
|
||||
setFocusableInTouchMode(true);
|
||||
|
||||
textInputWraper = new TextInputWraper(this);
|
||||
|
||||
handler = new Handler(){
|
||||
public void handleMessage(Message msg){
|
||||
switch(msg.what){
|
||||
case HANDLER_OPEN_IME_KEYBOARD:
|
||||
if (null != mTextField && mTextField.requestFocus()) {
|
||||
mTextField.removeTextChangedListener(textInputWraper);
|
||||
mTextField.setText("");
|
||||
String text = (String)msg.obj;
|
||||
mTextField.append(text);
|
||||
textInputWraper.setOriginText(text);
|
||||
mTextField.addTextChangedListener(textInputWraper);
|
||||
InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(mTextField, 0);
|
||||
Log.d("GLSurfaceView", "showSoftInput");
|
||||
}
|
||||
break;
|
||||
|
||||
case HANDLER_CLOSE_IME_KEYBOARD:
|
||||
if (null != mTextField) {
|
||||
mTextField.removeTextChangedListener(textInputWraper);
|
||||
InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0);
|
||||
Log.d("GLSurfaceView", "HideSoftInput");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mainView = this;
|
||||
}
|
||||
|
||||
public void onPause(){
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleOnPause();
|
||||
}
|
||||
});
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleOnResume();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// for text input
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
private final static int HANDLER_OPEN_IME_KEYBOARD = 2;
|
||||
private final static int HANDLER_CLOSE_IME_KEYBOARD = 3;
|
||||
private static Handler handler;
|
||||
private static TextInputWraper textInputWraper;
|
||||
private Cocos2dxEditText mTextField;
|
||||
|
||||
public TextView getTextField() {
|
||||
return mTextField;
|
||||
}
|
||||
|
||||
public void setTextField(Cocos2dxEditText view) {
|
||||
mTextField = view;
|
||||
if (null != mTextField && null != textInputWraper) {
|
||||
mTextField.setOnEditorActionListener(textInputWraper);
|
||||
mTextField.setMainView(this);
|
||||
this.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public static void openIMEKeyboard() {
|
||||
Message msg = new Message();
|
||||
msg.what = HANDLER_OPEN_IME_KEYBOARD;
|
||||
msg.obj = mainView.getContentText();
|
||||
handler.sendMessage(msg);
|
||||
|
||||
}
|
||||
|
||||
private String getContentText() {
|
||||
return mRenderer.getContentText();
|
||||
}
|
||||
|
||||
public static void closeIMEKeyboard() {
|
||||
Message msg = new Message();
|
||||
msg.what = HANDLER_CLOSE_IME_KEYBOARD;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
|
||||
public void insertText(final String text) {
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleInsertText(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteBackward() {
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleDeleteBackward();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// for touch event
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
// these data are used in ACTION_MOVE and ACTION_CANCEL
|
||||
final int pointerNumber = event.getPointerCount();
|
||||
final int[] ids = new int[pointerNumber];
|
||||
final float[] xs = new float[pointerNumber];
|
||||
final float[] ys = new float[pointerNumber];
|
||||
|
||||
for (int i = 0; i < pointerNumber; i++) {
|
||||
ids[i] = event.getPointerId(i);
|
||||
xs[i] = event.getX(i);
|
||||
ys[i] = event.getY(i);
|
||||
}
|
||||
|
||||
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
final int indexPointerDown = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT;
|
||||
final int idPointerDown = event.getPointerId(indexPointerDown);
|
||||
final float xPointerDown = event.getX(indexPointerDown);
|
||||
final float yPointerDown = event.getY(indexPointerDown);
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
// there are only one finger on the screen
|
||||
final int idDown = event.getPointerId(0);
|
||||
final float xDown = xs[0];
|
||||
final float yDown = ys[0];
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleActionDown(idDown, xDown, yDown);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleActionMove(ids, xs, ys);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT;
|
||||
final int idPointerUp = event.getPointerId(indexPointUp);
|
||||
final float xPointerUp = event.getX(indexPointUp);
|
||||
final float yPointerUp = event.getY(indexPointUp);
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
// there are only one finger on the screen
|
||||
final int idUp = event.getPointerId(0);
|
||||
final float xUp = xs[0];
|
||||
final float yUp = ys[0];
|
||||
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleActionUp(idUp, xUp, yUp);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleActionCancel(ids, xs, ys);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
if (debug){
|
||||
dumpEvent(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct.
|
||||
*/
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh){
|
||||
this.mRenderer.setScreenWidthAndHeight(w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
final int kc = keyCode;
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
|
||||
queueEvent(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRenderer.handleKeyDown(kc);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
// Show an event in the LogCat view, for debugging
|
||||
private void dumpEvent(MotionEvent event) {
|
||||
String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" ,
|
||||
"POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" };
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int action = event.getAction();
|
||||
int actionCode = action & MotionEvent.ACTION_MASK;
|
||||
sb.append("event ACTION_" ).append(names[actionCode]);
|
||||
if (actionCode == MotionEvent.ACTION_POINTER_DOWN
|
||||
|| actionCode == MotionEvent.ACTION_POINTER_UP) {
|
||||
sb.append("(pid " ).append(
|
||||
action >> MotionEvent.ACTION_POINTER_ID_SHIFT);
|
||||
sb.append(")" );
|
||||
}
|
||||
sb.append("[" );
|
||||
for (int i = 0; i < event.getPointerCount(); i++) {
|
||||
sb.append("#" ).append(i);
|
||||
sb.append("(pid " ).append(event.getPointerId(i));
|
||||
sb.append(")=" ).append((int) event.getX(i));
|
||||
sb.append("," ).append((int) event.getY(i));
|
||||
if (i + 1 < event.getPointerCount())
|
||||
sb.append(";" );
|
||||
}
|
||||
sb.append("]" );
|
||||
Log.d(TAG, sb.toString());
|
||||
}
|
||||
}
|
|
@ -1,228 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.media.MediaPlayer;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for controlling background music
|
||||
*
|
||||
*/
|
||||
public class Cocos2dxMusic {
|
||||
|
||||
private static final String TAG = "Cocos2dxMusic";
|
||||
private float mLeftVolume;
|
||||
private float mRightVolume;
|
||||
private Context mContext;
|
||||
private MediaPlayer mBackgroundMediaPlayer;
|
||||
private boolean mIsPaused;
|
||||
private String mCurrentPath;
|
||||
|
||||
public Cocos2dxMusic(Context context){
|
||||
this.mContext = context;
|
||||
initData();
|
||||
}
|
||||
|
||||
public void preloadBackgroundMusic(String path){
|
||||
if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){
|
||||
// preload new background music
|
||||
|
||||
// release old resource and create a new one
|
||||
if (mBackgroundMediaPlayer != null){
|
||||
mBackgroundMediaPlayer.release();
|
||||
}
|
||||
|
||||
mBackgroundMediaPlayer = createMediaplayerFromAssets(path);
|
||||
|
||||
// record the path
|
||||
mCurrentPath = path;
|
||||
}
|
||||
}
|
||||
|
||||
public void playBackgroundMusic(String path, boolean isLoop){
|
||||
if (mCurrentPath == null){
|
||||
// it is the first time to play background music
|
||||
// or end() was called
|
||||
mBackgroundMediaPlayer = createMediaplayerFromAssets(path);
|
||||
mCurrentPath = path;
|
||||
}
|
||||
else {
|
||||
if (! mCurrentPath.equals(path)){
|
||||
// play new background music
|
||||
|
||||
// release old resource and create a new one
|
||||
if (mBackgroundMediaPlayer != null){
|
||||
mBackgroundMediaPlayer.release();
|
||||
}
|
||||
mBackgroundMediaPlayer = createMediaplayerFromAssets(path);
|
||||
|
||||
// record the path
|
||||
mCurrentPath = path;
|
||||
}
|
||||
}
|
||||
|
||||
if (mBackgroundMediaPlayer == null){
|
||||
Log.e(TAG, "playBackgroundMusic: background media player is null");
|
||||
} else {
|
||||
// if the music is playing or paused, stop it
|
||||
mBackgroundMediaPlayer.stop();
|
||||
|
||||
mBackgroundMediaPlayer.setLooping(isLoop);
|
||||
|
||||
try {
|
||||
mBackgroundMediaPlayer.prepare();
|
||||
mBackgroundMediaPlayer.seekTo(0);
|
||||
mBackgroundMediaPlayer.start();
|
||||
|
||||
this.mIsPaused = false;
|
||||
} catch (Exception e){
|
||||
Log.e(TAG, "playBackgroundMusic: error state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopBackgroundMusic(){
|
||||
if (mBackgroundMediaPlayer != null){
|
||||
mBackgroundMediaPlayer.stop();
|
||||
|
||||
// should set the state, if not , the following sequence will be error
|
||||
// play -> pause -> stop -> resume
|
||||
this.mIsPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseBackgroundMusic(){
|
||||
if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){
|
||||
mBackgroundMediaPlayer.pause();
|
||||
this.mIsPaused = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void resumeBackgroundMusic(){
|
||||
if (mBackgroundMediaPlayer != null && this.mIsPaused){
|
||||
mBackgroundMediaPlayer.start();
|
||||
this.mIsPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void rewindBackgroundMusic(){
|
||||
if (mBackgroundMediaPlayer != null){
|
||||
mBackgroundMediaPlayer.stop();
|
||||
|
||||
try {
|
||||
mBackgroundMediaPlayer.prepare();
|
||||
mBackgroundMediaPlayer.seekTo(0);
|
||||
mBackgroundMediaPlayer.start();
|
||||
|
||||
this.mIsPaused = false;
|
||||
} catch (Exception e){
|
||||
Log.e(TAG, "rewindBackgroundMusic: error state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBackgroundMusicPlaying(){
|
||||
boolean ret = false;
|
||||
|
||||
if (mBackgroundMediaPlayer == null){
|
||||
ret = false;
|
||||
} else {
|
||||
ret = mBackgroundMediaPlayer.isPlaying();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void end(){
|
||||
if (mBackgroundMediaPlayer != null){
|
||||
mBackgroundMediaPlayer.release();
|
||||
}
|
||||
|
||||
initData();
|
||||
}
|
||||
|
||||
public float getBackgroundVolume(){
|
||||
if (this.mBackgroundMediaPlayer != null){
|
||||
return (this.mLeftVolume + this.mRightVolume) / 2;
|
||||
} else {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundVolume(float volume){
|
||||
if (volume < 0.0f){
|
||||
volume = 0.0f;
|
||||
}
|
||||
|
||||
if (volume > 1.0f){
|
||||
volume = 1.0f;
|
||||
}
|
||||
|
||||
this.mLeftVolume = this.mRightVolume = volume;
|
||||
if (this.mBackgroundMediaPlayer != null){
|
||||
this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume);
|
||||
}
|
||||
}
|
||||
|
||||
private void initData(){
|
||||
mLeftVolume =0.5f;
|
||||
mRightVolume = 0.5f;
|
||||
mBackgroundMediaPlayer = null;
|
||||
mIsPaused = false;
|
||||
mCurrentPath = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* create mediaplayer for music
|
||||
* @param path the path relative to assets
|
||||
* @return
|
||||
*/
|
||||
private MediaPlayer createMediaplayerFromAssets(String path){
|
||||
MediaPlayer mediaPlayer = new MediaPlayer();
|
||||
|
||||
try{
|
||||
if (path.startsWith("/")) {
|
||||
mediaPlayer.setDataSource(path);
|
||||
}
|
||||
else {
|
||||
AssetFileDescriptor assetFileDescritor = mContext.getAssets().openFd(path);
|
||||
mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(),
|
||||
assetFileDescritor.getStartOffset(), assetFileDescritor.getLength());
|
||||
}
|
||||
|
||||
mediaPlayer.prepare();
|
||||
|
||||
mediaPlayer.setVolume(mLeftVolume, mRightVolume);
|
||||
}catch (Exception e) {
|
||||
mediaPlayer = null;
|
||||
Log.e(TAG, "error: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
return mediaPlayer;
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
public class Cocos2dxRenderer implements GLSurfaceView.Renderer {
|
||||
private final static long NANOSECONDSPERSECOND = 1000000000L;
|
||||
private final static long NANOSECONDSPERMINISECOND = 1000000;
|
||||
private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND);
|
||||
private long last;
|
||||
private int screenWidth;
|
||||
private int screenHeight;
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
nativeInit(screenWidth, screenHeight);
|
||||
last = System.nanoTime();
|
||||
}
|
||||
|
||||
public void setScreenWidthAndHeight(int w, int h){
|
||||
this.screenWidth = w;
|
||||
this.screenHeight = h;
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||
}
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
|
||||
long now = System.nanoTime();
|
||||
long interval = now - last;
|
||||
|
||||
// should render a frame when onDrawFrame() is called
|
||||
// or there is a "ghost"
|
||||
nativeRender();
|
||||
|
||||
// fps controlling
|
||||
if (interval < animationInterval){
|
||||
try {
|
||||
// because we render it before, so we should sleep twice time interval
|
||||
Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND);
|
||||
} catch (Exception e){}
|
||||
}
|
||||
|
||||
last = now;
|
||||
}
|
||||
|
||||
public void handleActionDown(int id, float x, float y)
|
||||
{
|
||||
nativeTouchesBegin(id, x, y);
|
||||
}
|
||||
|
||||
public void handleActionUp(int id, float x, float y)
|
||||
{
|
||||
nativeTouchesEnd(id, x, y);
|
||||
}
|
||||
|
||||
public void handleActionCancel(int[] id, float[] x, float[] y)
|
||||
{
|
||||
nativeTouchesCancel(id, x, y);
|
||||
}
|
||||
|
||||
public void handleActionMove(int[] id, float[] x, float[] y)
|
||||
{
|
||||
nativeTouchesMove(id, x, y);
|
||||
}
|
||||
|
||||
public void handleKeyDown(int keyCode)
|
||||
{
|
||||
nativeKeyDown(keyCode);
|
||||
}
|
||||
|
||||
public void handleOnPause(){
|
||||
nativeOnPause();
|
||||
}
|
||||
|
||||
public void handleOnResume(){
|
||||
nativeOnResume();
|
||||
}
|
||||
|
||||
public static void setAnimationInterval(double interval){
|
||||
animationInterval = (long)(interval * NANOSECONDSPERSECOND);
|
||||
}
|
||||
private static native void nativeTouchesBegin(int id, float x, float y);
|
||||
private static native void nativeTouchesEnd(int id, float x, float y);
|
||||
private static native void nativeTouchesMove(int[] id, float[] x, float[] y);
|
||||
private static native void nativeTouchesCancel(int[] id, float[] x, float[] y);
|
||||
private static native boolean nativeKeyDown(int keyCode);
|
||||
private static native void nativeRender();
|
||||
private static native void nativeInit(int w, int h);
|
||||
private static native void nativeOnPause();
|
||||
private static native void nativeOnResume();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// handle input method edit message
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void handleInsertText(final String text) {
|
||||
nativeInsertText(text);
|
||||
}
|
||||
|
||||
public void handleDeleteBackward() {
|
||||
nativeDeleteBackward();
|
||||
}
|
||||
|
||||
public String getContentText() {
|
||||
return nativeGetContentText();
|
||||
}
|
||||
|
||||
private static native void nativeInsertText(String text);
|
||||
private static native void nativeDeleteBackward();
|
||||
private static native String nativeGetContentText();
|
||||
}
|
|
@ -1,258 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.media.SoundPool;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for controlling effect
|
||||
*
|
||||
*/
|
||||
|
||||
public class Cocos2dxSound {
|
||||
private Context mContext;
|
||||
private SoundPool mSoundPool;
|
||||
private float mLeftVolume;
|
||||
private float mRightVolume;
|
||||
|
||||
// sound id and stream id map
|
||||
private HashMap<Integer,Integer> mSoundIdStreamIdMap;
|
||||
// sound path and sound id map
|
||||
private HashMap<String,Integer> mPathSoundIDMap;
|
||||
|
||||
private static final String TAG = "Cocos2dxSound";
|
||||
private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5;
|
||||
private static final float SOUND_RATE = 1.0f;
|
||||
private static final int SOUND_PRIORITY = 1;
|
||||
private static final int SOUND_QUALITY = 5;
|
||||
|
||||
private final int INVALID_SOUND_ID = -1;
|
||||
private final int INVALID_STREAM_ID = -1;
|
||||
|
||||
public Cocos2dxSound(Context context){
|
||||
this.mContext = context;
|
||||
initData();
|
||||
}
|
||||
|
||||
public int preloadEffect(String path){
|
||||
int soundId = INVALID_SOUND_ID;
|
||||
|
||||
// if the sound is preloaded, pass it
|
||||
if (this.mPathSoundIDMap.get(path) != null){
|
||||
soundId = this.mPathSoundIDMap.get(path).intValue();
|
||||
} else {
|
||||
soundId = createSoundIdFromAsset(path);
|
||||
|
||||
if (soundId != INVALID_SOUND_ID){
|
||||
// the sound is loaded but has not been played
|
||||
this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID);
|
||||
|
||||
// record path and sound id map
|
||||
this.mPathSoundIDMap.put(path, soundId);
|
||||
}
|
||||
}
|
||||
|
||||
return soundId;
|
||||
}
|
||||
|
||||
public void unloadEffect(String path){
|
||||
// get sound id and remove from mPathSoundIDMap
|
||||
Integer soundId = this.mPathSoundIDMap.remove(path);
|
||||
|
||||
if (soundId != null){
|
||||
// unload effect
|
||||
this.mSoundPool.unload(soundId.intValue());
|
||||
|
||||
// remove record from mSoundIdStreamIdMap
|
||||
this.mSoundIdStreamIdMap.remove(soundId);
|
||||
}
|
||||
}
|
||||
|
||||
public int playEffect(String path, boolean isLoop){
|
||||
Integer soundId = this.mPathSoundIDMap.get(path);
|
||||
|
||||
if (soundId != null){
|
||||
// the sound is preloaded, stop it first
|
||||
|
||||
this.mSoundPool.stop(soundId);
|
||||
|
||||
// play sound
|
||||
int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume,
|
||||
this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE);
|
||||
|
||||
// record sound id and stream id map
|
||||
this.mSoundIdStreamIdMap.put(soundId, streamId);
|
||||
} else {
|
||||
// the effect is not prepared
|
||||
soundId = preloadEffect(path);
|
||||
if (soundId == INVALID_SOUND_ID){
|
||||
// can not preload effect
|
||||
return INVALID_SOUND_ID;
|
||||
}
|
||||
|
||||
/*
|
||||
* Someone reports that, it can not play effect for the
|
||||
* first time. If you are lucky to meet it. There are two
|
||||
* ways to resolve it.
|
||||
* 1. Add some delay here. I don't know how long it is, so
|
||||
* I don't add it here.
|
||||
* 2. If you use 2.2(API level 8), you can call
|
||||
* SoundPool.setOnLoadCompleteListener() to play the effect.
|
||||
* Because the method is supported from 2.2, so I can't use
|
||||
* it here.
|
||||
*/
|
||||
playEffect(path, isLoop);
|
||||
}
|
||||
|
||||
return soundId.intValue();
|
||||
}
|
||||
|
||||
public void stopEffect(int soundId){
|
||||
Integer streamId = this.mSoundIdStreamIdMap.get(soundId);
|
||||
|
||||
if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){
|
||||
this.mSoundPool.stop(streamId.intValue());
|
||||
this.mPathSoundIDMap.remove(soundId);
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseEffect(int soundId){
|
||||
Integer streamId = this.mSoundIdStreamIdMap.get(soundId);
|
||||
|
||||
if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){
|
||||
this.mSoundPool.pause(streamId.intValue());
|
||||
this.mPathSoundIDMap.remove(soundId);
|
||||
}
|
||||
}
|
||||
|
||||
public void resumeEffect(int soundId){
|
||||
Integer streamId = this.mSoundIdStreamIdMap.get(soundId);
|
||||
|
||||
if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){
|
||||
this.mSoundPool.resume(streamId.intValue());
|
||||
this.mPathSoundIDMap.remove(soundId);
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseAllEffects(){
|
||||
// autoResume is available since level 8
|
||||
pauseOrResumeAllEffects(true);
|
||||
}
|
||||
|
||||
public void resumeAllEffects(){
|
||||
// autoPause() is available since level 8
|
||||
pauseOrResumeAllEffects(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void stopAllEffects(){
|
||||
Iterator<?> iter = this.mSoundIdStreamIdMap.entrySet().iterator();
|
||||
while (iter.hasNext()){
|
||||
Map.Entry<Integer, Integer> entry = (Map.Entry<Integer, Integer>)iter.next();
|
||||
int soundId = entry.getKey();
|
||||
this.stopEffect(soundId);
|
||||
}
|
||||
}
|
||||
|
||||
public float getEffectsVolume(){
|
||||
return (this.mLeftVolume + this.mRightVolume) / 2;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setEffectsVolume(float volume){
|
||||
// volume should be in [0, 1.0]
|
||||
if (volume < 0){
|
||||
volume = 0;
|
||||
}
|
||||
if (volume > 1){
|
||||
volume = 1;
|
||||
}
|
||||
|
||||
this.mLeftVolume = this.mRightVolume = volume;
|
||||
|
||||
// change the volume of playing sounds
|
||||
Iterator<?> iter = this.mSoundIdStreamIdMap.entrySet().iterator();
|
||||
while (iter.hasNext()){
|
||||
Map.Entry<Integer, Integer> entry = (Map.Entry<Integer, Integer>)iter.next();
|
||||
this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume);
|
||||
}
|
||||
}
|
||||
|
||||
public void end(){
|
||||
this.mSoundPool.release();
|
||||
this.mPathSoundIDMap.clear();
|
||||
this.mSoundIdStreamIdMap.clear();
|
||||
|
||||
initData();
|
||||
}
|
||||
|
||||
public int createSoundIdFromAsset(String path){
|
||||
int soundId = INVALID_SOUND_ID;
|
||||
|
||||
try {
|
||||
if (path.startsWith("/")){
|
||||
soundId = mSoundPool.load(path, 0);
|
||||
}
|
||||
else {
|
||||
soundId = mSoundPool.load(mContext.getAssets().openFd(path), 0);
|
||||
}
|
||||
} catch(Exception e){
|
||||
soundId = INVALID_SOUND_ID;
|
||||
Log.e(TAG, "error: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
return soundId;
|
||||
}
|
||||
|
||||
private void initData(){
|
||||
this.mSoundIdStreamIdMap = new HashMap<Integer,Integer>();
|
||||
mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY);
|
||||
mPathSoundIDMap = new HashMap<String,Integer>();
|
||||
|
||||
this.mLeftVolume = 0.5f;
|
||||
this.mRightVolume = 0.5f;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void pauseOrResumeAllEffects(boolean isPause){
|
||||
Iterator<?> iter = this.mSoundIdStreamIdMap.entrySet().iterator();
|
||||
while (iter.hasNext()){
|
||||
Map.Entry<Integer, Integer> entry = (Map.Entry<Integer, Integer>)iter.next();
|
||||
int soundId = entry.getKey();
|
||||
if (isPause) {
|
||||
this.pauseEffect(soundId);
|
||||
} else {
|
||||
this.resumeEffect(soundId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2010-2011 cocos2d-x.org
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
package org.cocos2dx.lib;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
public class Cocos2dxTypefaces {
|
||||
private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();
|
||||
|
||||
public static Typeface get(Context context, String name){
|
||||
synchronized(cache){
|
||||
if (! cache.containsKey(name)){
|
||||
Typeface t = Typeface.createFromAsset(context.getAssets(), name);
|
||||
cache.put(name, t);
|
||||
}
|
||||
|
||||
return cache.get(name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,405 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 45;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1551A89A158F33C400E66CFE /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A897158F2F7D00E66CFE /* libcocos2dx.a */; };
|
||||
15DD6D7A156DD120003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD6D78156DD120003E7567 /* fps_images.png */; };
|
||||
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
|
||||
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
|
||||
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
|
||||
782F4619153FEDF0009FC2E5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4617153FEDF0009FC2E5 /* Default.png */; };
|
||||
782F461A153FEDF0009FC2E5 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4618153FEDF0009FC2E5 /* Icon.png */; };
|
||||
784521CE14EBA449009D533B /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521C514EBA449009D533B /* CloseNormal.png */; };
|
||||
784521CF14EBA449009D533B /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521C614EBA449009D533B /* CloseSelected.png */; };
|
||||
784521D214EBA449009D533B /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521CA14EBA449009D533B /* HelloWorld.png */; };
|
||||
BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; };
|
||||
BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; };
|
||||
BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; };
|
||||
BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF137426128A8E4600D9F789 /* QuartzCore.framework */; };
|
||||
BF23D4E7143315EB00657E08 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E3143315EB00657E08 /* AppDelegate.cpp */; };
|
||||
BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */; };
|
||||
BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; };
|
||||
BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; };
|
||||
D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
1551A896158F2F7D00E66CFE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 1551A33F158F2AB200E66CFE;
|
||||
remoteInfo = cocos2dx;
|
||||
};
|
||||
1551A898158F339F00E66CFE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 1551A33E158F2AB200E66CFE;
|
||||
remoteInfo = cocos2dx;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
|
||||
15DD6D78156DD120003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
|
||||
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
1D6058910D05DD3D006BFB54 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
|
||||
288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
781C33B11547F06B00633F88 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
|
||||
781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
|
||||
781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
|
||||
782F4617153FEDF0009FC2E5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; };
|
||||
782F4618153FEDF0009FC2E5 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; };
|
||||
784521C514EBA449009D533B /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = "<group>"; };
|
||||
784521C614EBA449009D533B /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = "<group>"; };
|
||||
784521CA14EBA449009D533B /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HelloWorld.png; sourceTree = "<group>"; };
|
||||
BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
BF23D4E3143315EB00657E08 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
|
||||
BF23D4E4143315EB00657E08 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HelloWorldScene.cpp; sourceTree = "<group>"; };
|
||||
BF23D4E6143315EB00657E08 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloWorldScene.h; sourceTree = "<group>"; };
|
||||
BF365AA612A103F70050DCF4 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
|
||||
BF365AA712A103F70050DCF4 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = "<group>"; };
|
||||
BF492B6912891AC600A09262 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
BF492C21128924A800A09262 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
|
||||
BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
|
||||
BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
|
||||
BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = "<group>"; };
|
||||
D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1551A89A158F33C400E66CFE /* libcocos2dx.a in Frameworks */,
|
||||
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
|
||||
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
|
||||
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
|
||||
BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */,
|
||||
BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */,
|
||||
BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */,
|
||||
BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
1551A890158F2F7D00E66CFE /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1551A897158F2F7D00E66CFE /* libcocos2dx.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1D6058910D05DD3D006BFB54 /* HelloWorld.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */,
|
||||
BF23D4E2143315EB00657E08 /* Classes */,
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||
BF5681CC1313A84D0055EEAC /* ios */,
|
||||
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||
784521C214EBA449009D533B /* Resources */,
|
||||
);
|
||||
name = CustomTemplate;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF492B6912891AC600A09262 /* libz.dylib */,
|
||||
BF137426128A8E4600D9F789 /* QuartzCore.framework */,
|
||||
BF492D4B1289302400A09262 /* OpenGLES.framework */,
|
||||
BF492C21128924A800A09262 /* libxml2.dylib */,
|
||||
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
|
||||
1D30AB110D05D00D00671497 /* Foundation.framework */,
|
||||
288765A40DF7441C002DB57D /* CoreGraphics.framework */,
|
||||
781C33B11547F06B00633F88 /* OpenAL.framework */,
|
||||
781C33B31547F06B00633F88 /* AudioToolbox.framework */,
|
||||
781C33B51547F06B00633F88 /* AVFoundation.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
784521C214EBA449009D533B /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15DD6D78156DD120003E7567 /* fps_images.png */,
|
||||
782F4617153FEDF0009FC2E5 /* Default.png */,
|
||||
782F4618153FEDF0009FC2E5 /* Icon.png */,
|
||||
784521C514EBA449009D533B /* CloseNormal.png */,
|
||||
784521C614EBA449009D533B /* CloseSelected.png */,
|
||||
784521CA14EBA449009D533B /* HelloWorld.png */,
|
||||
);
|
||||
name = Resources;
|
||||
path = ../Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF23D4E2143315EB00657E08 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF23D4E3143315EB00657E08 /* AppDelegate.cpp */,
|
||||
BF23D4E4143315EB00657E08 /* AppDelegate.h */,
|
||||
BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */,
|
||||
BF23D4E6143315EB00657E08 /* HelloWorldScene.h */,
|
||||
);
|
||||
name = Classes;
|
||||
path = ../Classes;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
BF5681CC1313A84D0055EEAC /* ios */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4ABB4B213B4395300552E6E /* main.m */,
|
||||
BF365AA612A103F70050DCF4 /* AppController.h */,
|
||||
BF365AA712A103F70050DCF4 /* AppController.mm */,
|
||||
BF4DE6AB138BB89600CF907D /* RootViewController.h */,
|
||||
BF4DE6AC138BB89600CF907D /* RootViewController.mm */,
|
||||
);
|
||||
name = ios;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
1D6058900D05DD3D006BFB54 /* HelloWorld */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloWorld" */;
|
||||
buildPhases = (
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */,
|
||||
1D60588E0D05DD3D006BFB54 /* Sources */,
|
||||
1D60588F0D05DD3D006BFB54 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
1551A899158F339F00E66CFE /* PBXTargetDependency */,
|
||||
);
|
||||
name = HelloWorld;
|
||||
productName = HelloWorld;
|
||||
productReference = 1D6058910D05DD3D006BFB54 /* HelloWorld.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloWorld" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
|
||||
projectDirPath = "";
|
||||
projectReferences = (
|
||||
{
|
||||
ProductGroup = 1551A890158F2F7D00E66CFE /* Products */;
|
||||
ProjectRef = 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
1D6058900D05DD3D006BFB54 /* HelloWorld */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXReferenceProxy section */
|
||||
1551A897158F2F7D00E66CFE /* libcocos2dx.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libcocos2dx.a;
|
||||
remoteRef = 1551A896158F2F7D00E66CFE /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
784521CE14EBA449009D533B /* CloseNormal.png in Resources */,
|
||||
784521CF14EBA449009D533B /* CloseSelected.png in Resources */,
|
||||
784521D214EBA449009D533B /* HelloWorld.png in Resources */,
|
||||
782F4619153FEDF0009FC2E5 /* Default.png in Resources */,
|
||||
782F461A153FEDF0009FC2E5 /* Icon.png in Resources */,
|
||||
15DD6D7A156DD120003E7567 /* fps_images.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
1D60588E0D05DD3D006BFB54 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
BF365AA812A103F70050DCF4 /* AppController.mm in Sources */,
|
||||
BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */,
|
||||
D4ABB4B313B4395300552E6E /* main.m in Sources */,
|
||||
BF23D4E7143315EB00657E08 /* AppDelegate.cpp in Sources */,
|
||||
BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
1551A899158F339F00E66CFE /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = cocos2dx;
|
||||
targetProxy = 1551A898158F339F00E66CFE /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1D6058940D05DD3E006BFB54 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = HelloWorld_Prefix.pch;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
USE_FILE32API,
|
||||
TARGET_OS_IPHONE,
|
||||
"COCOS2D_DEBUG=1",
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = "";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"\"$(SDKROOT)/usr/include/libxml2/\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/include\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/platform/ios\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/kazmath/include\"",
|
||||
);
|
||||
INFOPLIST_FILE = "HelloWorld-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
||||
PRODUCT_NAME = HelloWorld;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALID_ARCHS = "armv6 armv7 i386";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1D6058950D05DD3E006BFB54 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = HelloWorld_Prefix.pch;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
USE_FILE32API,
|
||||
TARGET_OS_IPHONE,
|
||||
);
|
||||
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = "";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"\"$(SDKROOT)/usr/include/libxml2/\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/include\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/platform/ios\"",
|
||||
"\"$(SRCROOT)/../../cocos2dx/kazmath/include\"",
|
||||
);
|
||||
INFOPLIST_FILE = "HelloWorld-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
|
||||
PRODUCT_NAME = HelloWorld;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VALID_ARCHS = "armv6 armv7 i386";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C01FCF4F08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALID_ARCHS = "armv6 armv7 i386";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF5008A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
PREBINDING = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALID_ARCHS = "armv6 armv7 i386";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloWorld" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1D6058940D05DD3E006BFB54 /* Debug */,
|
||||
1D6058950D05DD3E006BFB54 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloWorld" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247B /* Debug */,
|
||||
C01FCF5008A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
c7a3fbb2c6d8e698889720796681db135c37b25b
|
|
@ -21,7 +21,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -41,14 +41,15 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\actions";"$(SolutionDir)cocos2dx\base_nodes";"$(SolutionDir)cocos2dx\cocoa";"$(SolutionDir)cocos2dx\effects";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\keypad_dispatcher";"$(SolutionDir)cocos2dx\label_nodes";"$(SolutionDir)cocos2dx\layers_scenes_transitions_nodes";"$(SolutionDir)cocos2dx\menu_nodes";"$(SolutionDir)cocos2dx\misc_nodes";"$(SolutionDir)cocos2dx\particle_nodes";"$(SolutionDir)cocos2dx\script_support";"$(SolutionDir)cocos2dx\shaders";"$(SolutionDir)cocos2dx\sprite_nodes";"$(SolutionDir)cocos2dx\support";"$(SolutionDir)cocos2dx\text_input_node";"$(SolutionDir)cocos2dx\textures";"$(SolutionDir)cocos2dx\tileMap_parallax_nodes";"$(SolutionDir)cocos2dx\touch_dispatcher";"$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
DisableSpecificWarnings="4267;4251;4244"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -61,7 +62,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libcocos2d.lib libGLESv2.lib"
|
||||
AdditionalDependencies="opengl32.lib glew32.lib libcocos2d.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="$(OutDir)"
|
||||
|
@ -97,7 +98,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
|
@ -119,13 +120,14 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\actions";"$(SolutionDir)cocos2dx\base_nodes";"$(SolutionDir)cocos2dx\cocoa";"$(SolutionDir)cocos2dx\effects";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\keypad_dispatcher";"$(SolutionDir)cocos2dx\label_nodes";"$(SolutionDir)cocos2dx\layers_scenes_transitions_nodes";"$(SolutionDir)cocos2dx\menu_nodes";"$(SolutionDir)cocos2dx\misc_nodes";"$(SolutionDir)cocos2dx\particle_nodes";"$(SolutionDir)cocos2dx\script_support";"$(SolutionDir)cocos2dx\shaders";"$(SolutionDir)cocos2dx\sprite_nodes";"$(SolutionDir)cocos2dx\support";"$(SolutionDir)cocos2dx\text_input_node";"$(SolutionDir)cocos2dx\textures";"$(SolutionDir)cocos2dx\tileMap_parallax_nodes";"$(SolutionDir)cocos2dx\touch_dispatcher";"$(SolutionDir)cocos2dx\platform";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||
AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
DisableSpecificWarnings="4267;4251;4244"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -138,7 +140,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libcocos2d.lib"
|
||||
AdditionalDependencies="opengl32.lib glew32.lib libcocos2d.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="$(OutDir)"
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
@ -54,8 +54,8 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
|
@ -63,6 +63,7 @@
|
|||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4267;4251;4244</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libcocos2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
@ -81,14 +82,15 @@
|
|||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>.;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4267;4251;4244</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libcocos2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
|
10
README.mdown
10
README.mdown
|
@ -2,14 +2,14 @@ cocos2d-x
|
|||
==================
|
||||
|
||||
[cocos2d-x][1] is a multi-platform 2D game engine in C++, based on [cocos2d-iphone][2] and licensed under MIT.
|
||||
Now this engine has been expended to iOS, Android, Bada, BlackBerry Playbook, Marmalade and desktop operating systems like Linux, WindowsXP & Windows7.
|
||||
Now this engine has been expanded to iOS, Android, Bada, BlackBerry, Marmalade and desktop operating systems like Linux, WindowsXP & Windows7.
|
||||
|
||||
Multi Platform
|
||||
-------------
|
||||
* iOS: stable, well tested on iOS 4.0 ~ 5.0 SDK.
|
||||
* Android: stable, well tested on 2.0~3.1, based on ndk r5 ~ r7.
|
||||
* iOS: stable, well tested on iOS 4.x ~ 5.x SDK.
|
||||
* Android: stable, well tested on 2.0~4.0, based on ndk r5 ~ r8.
|
||||
* Bada: stable on Bada SDK 1.0 & 2.0
|
||||
* BlackBerry Playbook: stable, contribued by engineers working at RIM
|
||||
* BlackBerry Playbook & BB10: stable, contribued by engineers working at RIM
|
||||
* Marmalade: stable since cocos2d-x-0.11.0
|
||||
* Windows: stable, tested on WinXP, Vista, Win7. Please upgrde the drive of your video card if you meet problems on OpenGL functions
|
||||
* Linux: usable.
|
||||
|
@ -28,7 +28,7 @@ Contact us
|
|||
[1]: http://www.cocos2d-x.org "cocos2d-x"
|
||||
[2]: http://www.cocos2d-iphone.org "cocos2d for iPhone"
|
||||
[3]: http://www.cocos2d-x.org "www.cocos2d-x.org"
|
||||
[4]: http://www.cocos2d-x.org/embedded/cocos2d-x/classes.html "API References"
|
||||
[4]: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Reference "API References"
|
||||
[5]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org"
|
||||
[6]: http://www.twitter.com/cocos2dx "http://www.twitter.com/cocos2dx"
|
||||
[7]: http://t.sina.com.cn/cocos2dx "http://t.sina.com.cn/cocos2dx"
|
||||
|
|
|
@ -46,6 +46,7 @@ set CC_TEST_BIN=tests.exe
|
|||
set CC_TEST_RES=..\tests\Resources\*.*
|
||||
set CC_HELLOWORLD_RES=..\HelloWorld\Resources\*.*
|
||||
set CC_HELLOLUA_RES=..\HelloLua\Resources\*.*
|
||||
set CC_TESTJS_RES=..\testjs\Resources\*.*
|
||||
|
||||
if not exist "%CC_TEST_BIN%" (
|
||||
echo Can't find the binary "tests.exe", is there build error?
|
||||
|
@ -59,6 +60,8 @@ echo.
|
|||
xcopy /E /Y /Q "%CC_TEST_RES%" .
|
||||
xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" .
|
||||
xcopy /E /Y /Q "%CC_HELLOLUA_RES%" .
|
||||
xcopy /E /Y /Q "%CC_TESTJS_RES%" .
|
||||
|
||||
call "%CC_TEST_BIN%"
|
||||
start http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide
|
||||
goto EOF
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#ifndef CHIPMUNK_HEADER
|
||||
#define CHIPMUNK_HEADER
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -103,10 +106,10 @@ typedef struct cpSpace cpSpace;
|
|||
|
||||
#include "cpSpace.h"
|
||||
|
||||
// Chipmunk 6.0.3
|
||||
// Chipmunk 6.1.1
|
||||
#define CP_VERSION_MAJOR 6
|
||||
#define CP_VERSION_MINOR 0
|
||||
#define CP_VERSION_RELEASE 3
|
||||
#define CP_VERSION_MINOR 1
|
||||
#define CP_VERSION_RELEASE 1
|
||||
|
||||
/// Version string.
|
||||
extern const char *cpVersionString;
|
||||
|
@ -148,6 +151,54 @@ cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height);
|
|||
/// Calculate the moment of inertia for a solid box.
|
||||
cpFloat cpMomentForBox2(cpFloat m, cpBB box);
|
||||
|
||||
/// Calculate the convex hull of a given set of points. Returns the count of points in the hull.
|
||||
/// @c result must be a pointer to a @c cpVect array with at least @c count elements. If @c result is @c NULL, then @c verts will be reduced instead.
|
||||
/// @c first is an optional pointer to an integer to store where the first vertex in the hull came from (i.e. verts[first] == result[0])
|
||||
/// @c tol is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull.
|
||||
int cpConvexHull(int count, cpVect *verts, cpVect *result, int *first, cpFloat tol);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include "malloc.h"
|
||||
#endif
|
||||
|
||||
/// Convenience macro to work with cpConvexHull.
|
||||
/// @c count and @c verts is the input array passed to cpConvexHull().
|
||||
/// @c count_var and @c verts_var are the names of the variables the macro creates to store the result.
|
||||
/// The output vertex array is allocated on the stack using alloca() so it will be freed automatically, but cannot be returned from the current scope.
|
||||
#define CP_CONVEX_HULL(__count__, __verts__, __count_var__, __verts_var__) \
|
||||
cpVect *__verts_var__ = (cpVect *)alloca(__count__*sizeof(cpVect)); \
|
||||
int __count_var__ = cpConvexHull(__count__, __verts__, __verts_var__, NULL, 0.0); \
|
||||
|
||||
#if defined(__has_extension)
|
||||
#if __has_extension(blocks)
|
||||
// Define alternate block based alternatives for a few of the callback heavy functions.
|
||||
// Collision handlers are post-step callbacks are not included to avoid memory management issues.
|
||||
// If you want to use blocks for those and are aware of how to correctly manage the memory, the implementation is trivial.
|
||||
|
||||
void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body));
|
||||
void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape));
|
||||
void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint));
|
||||
|
||||
void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape));
|
||||
void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint));
|
||||
void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter));
|
||||
|
||||
typedef void (^cpSpaceNearestPointQueryBlock)(cpShape *shape, cpFloat distance, cpVect point);
|
||||
void cpSpaceNearestPointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryBlock block);
|
||||
|
||||
typedef void (^cpSpaceSegmentQueryBlock)(cpShape *shape, cpFloat t, cpVect n);
|
||||
void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryBlock block);
|
||||
|
||||
typedef void (^cpSpaceBBQueryBlock)(cpShape *shape);
|
||||
void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryBlock block);
|
||||
|
||||
typedef void (^cpSpaceShapeQueryBlock)(cpShape *shape, cpContactPointSet *points);
|
||||
cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//@}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -152,7 +152,6 @@ MAKE_REF(cpSpatialIndexInsert);
|
|||
MAKE_REF(cpSpatialIndexRemove);
|
||||
MAKE_REF(cpSpatialIndexReindex);
|
||||
MAKE_REF(cpSpatialIndexReindexObject);
|
||||
MAKE_REF(cpSpatialIndexPointQuery);
|
||||
MAKE_REF(cpSpatialIndexSegmentQuery);
|
||||
MAKE_REF(cpSpatialIndexQuery);
|
||||
MAKE_REF(cpSpatialIndexReindexQuery);
|
||||
|
|
|
@ -99,16 +99,42 @@ void cpBodyRemoveConstraint(cpBody *body, cpConstraint *constraint);
|
|||
|
||||
//MARK: Shape/Collision Functions
|
||||
|
||||
// TODO should move this to the cpVect API. It's pretty useful.
|
||||
static inline cpVect
|
||||
cpClosetPointOnSegment(const cpVect p, const cpVect a, const cpVect b)
|
||||
{
|
||||
cpVect delta = cpvsub(a, b);
|
||||
cpFloat t = cpfclamp01(cpvdot(delta, cpvsub(p, b))/cpvlengthsq(delta));
|
||||
return cpvadd(b, cpvmult(delta, t));
|
||||
}
|
||||
|
||||
cpShape* cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body);
|
||||
|
||||
static inline cpBool
|
||||
cpShapeActive(cpShape *shape)
|
||||
{
|
||||
return shape->prev || shape->body->shapeList == shape;
|
||||
return shape->prev || (shape->body && shape->body->shapeList == shape);
|
||||
}
|
||||
|
||||
int cpCollideShapes(const cpShape *a, const cpShape *b, cpContact *arr);
|
||||
|
||||
// TODO doesn't really need to be inline, but need a better place to put this function
|
||||
static inline cpSplittingPlane
|
||||
cpSplittingPlaneNew(cpVect a, cpVect b)
|
||||
{
|
||||
cpVect n = cpvnormalize(cpvperp(cpvsub(b, a)));
|
||||
cpSplittingPlane plane = {n, cpvdot(n, a)};
|
||||
return plane;
|
||||
}
|
||||
|
||||
static inline cpFloat
|
||||
cpSplittingPlaneCompare(cpSplittingPlane plane, cpVect v)
|
||||
{
|
||||
return cpvdot(plane.n, v) - plane.d;
|
||||
}
|
||||
|
||||
void cpLoopIndexes(cpVect *verts, int count, int *start, int *end);
|
||||
|
||||
static inline cpFloat
|
||||
cpPolyShapeValueOnAxis(const cpPolyShape *poly, const cpVect n, const cpFloat d)
|
||||
{
|
||||
|
@ -125,10 +151,10 @@ cpPolyShapeValueOnAxis(const cpPolyShape *poly, const cpVect n, const cpFloat d)
|
|||
static inline cpBool
|
||||
cpPolyShapeContainsVert(const cpPolyShape *poly, const cpVect v)
|
||||
{
|
||||
cpPolyShapeAxis *axes = poly->tAxes;
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d;
|
||||
cpFloat dist = cpSplittingPlaneCompare(planes[i], v);
|
||||
if(dist > 0.0f) return cpFalse;
|
||||
}
|
||||
|
||||
|
@ -138,11 +164,11 @@ cpPolyShapeContainsVert(const cpPolyShape *poly, const cpVect v)
|
|||
static inline cpBool
|
||||
cpPolyShapeContainsVertPartial(const cpPolyShape *poly, const cpVect v, const cpVect n)
|
||||
{
|
||||
cpPolyShapeAxis *axes = poly->tAxes;
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
if(cpvdot(axes[i].n, n) < 0.0f) continue;
|
||||
cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d;
|
||||
if(cpvdot(planes[i].n, n) < 0.0f) continue;
|
||||
cpFloat dist = cpSplittingPlaneCompare(planes[i], v);
|
||||
if(dist > 0.0f) return cpFalse;
|
||||
}
|
||||
|
||||
|
@ -162,7 +188,7 @@ void cpSpacePushFreshContactBuffer(cpSpace *space);
|
|||
cpContact *cpContactBufferGetArray(cpSpace *space);
|
||||
void cpSpacePushContacts(cpSpace *space, int count);
|
||||
|
||||
void *cpSpaceGetPostStepData(cpSpace *space, void *obj);
|
||||
void *cpSpaceGetPostStepData(cpSpace *space, void *key);
|
||||
|
||||
cpBool cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space);
|
||||
void cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter);
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
#import "TargetConditionals.h"
|
||||
#endif
|
||||
|
||||
#if (TARGET_OS_IPHONE == 1) && (!defined CP_USE_CGPOINTS)
|
||||
#if (TARGET_OS_IPHONE == 1) || (TARGET_OS_MAC == 1) && (!defined CP_USE_CGPOINTS)
|
||||
#define CP_USE_CGPOINTS 1
|
||||
#endif
|
||||
|
||||
#ifdef CP_USE_CGPOINTS
|
||||
#if CP_USE_CGPOINTS == 1
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <CoreGraphics/CGGeometry.h>
|
||||
#elif TARGET_OS_MAC
|
||||
|
@ -61,7 +61,6 @@
|
|||
#endif
|
||||
|
||||
#ifndef INFINITY
|
||||
//TODO use C++ infinity
|
||||
#ifdef _MSC_VER
|
||||
union MSVC_EVIL_FLOAT_HACK
|
||||
{
|
||||
|
@ -203,7 +202,7 @@ typedef uintptr_t cpHashValue;
|
|||
|
||||
// CGPoints are structurally the same, and allow
|
||||
// easy interoperability with other Cocoa libraries
|
||||
#ifdef CP_USE_CGPOINTS
|
||||
#if CP_USE_CGPOINTS
|
||||
typedef CGPoint cpVect;
|
||||
#else
|
||||
/// Chipmunk's 2D vector type.
|
||||
|
|
|
@ -110,6 +110,8 @@ static inline void cpConstraint##Set##name(cpConstraint *constraint, type value)
|
|||
CP_DefineConstraintStructGetter(type, member, name) \
|
||||
CP_DefineConstraintStructSetter(type, member, name)
|
||||
|
||||
CP_DefineConstraintStructGetter(cpSpace*, CP_PRIVATE(space), Space);
|
||||
|
||||
CP_DefineConstraintStructGetter(cpBody*, a, A);
|
||||
CP_DefineConstraintStructGetter(cpBody*, b, B);
|
||||
CP_DefineConstraintStructProperty(cpFloat, maxForce, MaxForce);
|
||||
|
|
|
@ -156,18 +156,6 @@ static inline void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody *
|
|||
/// A macro shortcut for defining and retrieving the bodies from an arbiter.
|
||||
#define CP_ARBITER_GET_BODIES(arb, a, b) cpBody *a, *b; cpArbiterGetBodies(arb, &a, &b);
|
||||
|
||||
/// Returns true if this is the first step a pair of objects started colliding.
|
||||
static inline cpBool cpArbiterIsFirstContact(const cpArbiter *arb)
|
||||
{
|
||||
return arb->CP_PRIVATE(state) == cpArbiterStateFirstColl;
|
||||
}
|
||||
|
||||
/// Get the number of contact points for this arbiter.
|
||||
static inline int cpArbiterGetCount(const cpArbiter *arb)
|
||||
{
|
||||
return arb->CP_PRIVATE(numContacts);
|
||||
}
|
||||
|
||||
/// A struct that wraps up the important collision data for an arbiter.
|
||||
typedef struct cpContactPointSet {
|
||||
/// The number of contact points in the set.
|
||||
|
@ -186,6 +174,10 @@ typedef struct cpContactPointSet {
|
|||
/// Return a contact set from an arbiter.
|
||||
cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb);
|
||||
|
||||
/// Returns true if this is the first step a pair of objects started colliding.
|
||||
cpBool cpArbiterIsFirstContact(const cpArbiter *arb);
|
||||
/// Get the number of contact points for this arbiter.
|
||||
int cpArbiterGetCount(const cpArbiter *arb);
|
||||
/// Get the normal of the @c ith contact point.
|
||||
cpVect cpArbiterGetNormal(const cpArbiter *arb, int i);
|
||||
/// Get the position of the @c ith contact point.
|
||||
|
|
|
@ -168,6 +168,9 @@ static inline void cpBodySet##name(cpBody *body, const type value){ \
|
|||
CP_DefineBodyStructGetter(type, member, name) \
|
||||
CP_DefineBodyStructSetter(type, member, name)
|
||||
|
||||
// TODO add to docs
|
||||
CP_DefineBodyStructGetter(cpSpace*, CP_PRIVATE(space), Space);
|
||||
|
||||
CP_DefineBodyStructGetter(cpFloat, m, Mass);
|
||||
/// Set the mass of a body.
|
||||
void cpBodySetMass(cpBody *body, cpFloat m);
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
/// @{
|
||||
|
||||
/// @private
|
||||
typedef struct cpPolyShapeAxis {
|
||||
typedef struct cpSplittingPlane {
|
||||
cpVect n;
|
||||
cpFloat d;
|
||||
} cpPolyShapeAxis;
|
||||
} cpSplittingPlane;
|
||||
|
||||
/// @private
|
||||
typedef struct cpPolyShape {
|
||||
|
@ -34,16 +34,16 @@ typedef struct cpPolyShape {
|
|||
|
||||
int numVerts;
|
||||
cpVect *verts, *tVerts;
|
||||
cpPolyShapeAxis *axes, *tAxes;
|
||||
cpSplittingPlane *planes, *tPlanes;
|
||||
} cpPolyShape;
|
||||
|
||||
/// Allocate a polygon shape.
|
||||
cpPolyShape* cpPolyShapeAlloc(void);
|
||||
/// Initialize a polygon shape.
|
||||
/// The vertexes must be convex and have a clockwise winding.
|
||||
/// A convex hull will be created from the vertexes.
|
||||
cpPolyShape* cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset);
|
||||
/// Allocate and initialize a polygon shape.
|
||||
/// The vertexes must be convex and have a clockwise winding.
|
||||
/// A convex hull will be created from the vertexes.
|
||||
cpShape* cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset);
|
||||
|
||||
/// Initialize a box shaped polygon shape.
|
||||
|
@ -56,6 +56,7 @@ cpShape* cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height);
|
|||
cpShape* cpBoxShapeNew2(cpBody *body, cpBB box);
|
||||
|
||||
/// Check that a set of vertexes is convex and has a clockwise winding.
|
||||
/// NOTE: Due to floating point precision issues, hulls created with cpQuickHull() are not guaranteed to validate!
|
||||
cpBool cpPolyValidate(const cpVect *verts, const int numVerts);
|
||||
|
||||
/// Get the number of verts in a polygon shape.
|
||||
|
|
|
@ -25,6 +25,16 @@
|
|||
|
||||
typedef struct cpShapeClass cpShapeClass;
|
||||
|
||||
/// Nearest point query info struct.
|
||||
typedef struct cpNearestPointQueryInfo {
|
||||
/// The nearest shape, NULL if no shape was within range.
|
||||
cpShape *shape;
|
||||
/// The closest point on the shape's surface. (in world space coordinates)
|
||||
cpVect p;
|
||||
/// The distance to the point. The distance is negative if the point is inside the shape.
|
||||
cpFloat d;
|
||||
} cpNearestPointQueryInfo;
|
||||
|
||||
/// Segment query info struct.
|
||||
typedef struct cpSegmentQueryInfo {
|
||||
/// The shape that was hit, NULL if no collision occured.
|
||||
|
@ -45,7 +55,7 @@ typedef enum cpShapeType{
|
|||
|
||||
typedef cpBB (*cpShapeCacheDataImpl)(cpShape *shape, cpVect p, cpVect rot);
|
||||
typedef void (*cpShapeDestroyImpl)(cpShape *shape);
|
||||
typedef cpBool (*cpShapePointQueryImpl)(cpShape *shape, cpVect p);
|
||||
typedef void (*cpShapeNearestPointQueryImpl)(cpShape *shape, cpVect p, cpNearestPointQueryInfo *info);
|
||||
typedef void (*cpShapeSegmentQueryImpl)(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info);
|
||||
|
||||
/// @private
|
||||
|
@ -54,7 +64,7 @@ struct cpShapeClass {
|
|||
|
||||
cpShapeCacheDataImpl cacheData;
|
||||
cpShapeDestroyImpl destroy;
|
||||
cpShapePointQueryImpl pointQuery;
|
||||
cpShapeNearestPointQueryImpl nearestPointQuery;
|
||||
cpShapeSegmentQueryImpl segmentQuery;
|
||||
};
|
||||
|
||||
|
@ -112,6 +122,25 @@ cpBB cpShapeUpdate(cpShape *shape, cpVect pos, cpVect rot);
|
|||
/// Test if a point lies within a shape.
|
||||
cpBool cpShapePointQuery(cpShape *shape, cpVect p);
|
||||
|
||||
/// Perform a nearest point query. It finds the closest point on the surface of shape to a specific point.
|
||||
/// The value returned is the distance between the points. A negative distance means the point is inside the shape.
|
||||
cpFloat cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpNearestPointQueryInfo *out);
|
||||
|
||||
/// Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure.
|
||||
cpBool cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info);
|
||||
|
||||
/// Get the hit point for a segment query.
|
||||
static inline cpVect cpSegmentQueryHitPoint(const cpVect start, const cpVect end, const cpSegmentQueryInfo info)
|
||||
{
|
||||
return cpvlerp(start, end, info.t);
|
||||
}
|
||||
|
||||
/// Get the hit distance for a segment query.
|
||||
static inline cpFloat cpSegmentQueryHitDist(const cpVect start, const cpVect end, const cpSegmentQueryInfo info)
|
||||
{
|
||||
return cpvdist(start, end)*info.t;
|
||||
}
|
||||
|
||||
#define CP_DefineShapeStructGetter(type, member, name) \
|
||||
static inline type cpShapeGet##name(const cpShape *shape){return shape->member;}
|
||||
|
||||
|
@ -125,6 +154,8 @@ static inline void cpShapeSet##name(cpShape *shape, type value){ \
|
|||
CP_DefineShapeStructGetter(type, member, name) \
|
||||
CP_DefineShapeStructSetter(type, member, name, activates)
|
||||
|
||||
CP_DefineShapeStructGetter(cpSpace*, CP_PRIVATE(space), Space);
|
||||
|
||||
CP_DefineShapeStructGetter(cpBody*, body, Body);
|
||||
void cpShapeSetBody(cpShape *shape, cpBody *body);
|
||||
|
||||
|
@ -143,21 +174,6 @@ CP_DefineShapeStructProperty(cpLayers, layers, Layers, cpTrue);
|
|||
/// when recreating a space. This will make the simulation be deterministic.
|
||||
void cpResetShapeIdCounter(void);
|
||||
|
||||
/// Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure.
|
||||
cpBool cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info);
|
||||
|
||||
/// Get the hit point for a segment query.
|
||||
static inline cpVect cpSegmentQueryHitPoint(const cpVect start, const cpVect end, const cpSegmentQueryInfo info)
|
||||
{
|
||||
return cpvlerp(start, end, info.t);
|
||||
}
|
||||
|
||||
/// Get the hit distance for a segment query.
|
||||
static inline cpFloat cpSegmentQueryHitDist(const cpVect start, const cpVect end, const cpSegmentQueryInfo info)
|
||||
{
|
||||
return cpvdist(start, end)*info.t;
|
||||
}
|
||||
|
||||
#define CP_DeclareShapeGetter(struct, type, name) type struct##Get##name(const cpShape *shape)
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -98,9 +98,9 @@ struct cpSpace {
|
|||
|
||||
CP_PRIVATE(cpHashSet *collisionHandlers);
|
||||
CP_PRIVATE(cpCollisionHandler defaultHandler);
|
||||
CP_PRIVATE(cpHashSet *postStepCallbacks);
|
||||
|
||||
CP_PRIVATE(cpSpaceArbiterApplyImpulseFunc arbiterApplyImpulse);
|
||||
CP_PRIVATE(cpBool skipPostStep);
|
||||
CP_PRIVATE(cpArray *postStepCallbacks);
|
||||
|
||||
CP_PRIVATE(cpBody _staticBody);
|
||||
};
|
||||
|
@ -204,8 +204,8 @@ cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint);
|
|||
/// Post Step callback function type.
|
||||
typedef void (*cpPostStepFunc)(cpSpace *space, void *obj, void *data);
|
||||
/// Schedule a post-step callback to be called when cpSpaceStep() finishes.
|
||||
/// @c obj is used a key, you can only register one callback per unique value for @c obj
|
||||
void cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *obj, void *data);
|
||||
/// You can only register one callback per unique value for @c key.
|
||||
void cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data);
|
||||
|
||||
/// Point query callback function type.
|
||||
typedef void (*cpSpacePointQueryFunc)(cpShape *shape, void *data);
|
||||
|
@ -214,6 +214,13 @@ void cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup gr
|
|||
/// Query the space at a point and return the first shape found. Returns NULL if no shapes were found.
|
||||
cpShape *cpSpacePointQueryFirst(cpSpace *space, cpVect point, cpLayers layers, cpGroup group);
|
||||
|
||||
/// Nearest point query callback function type.
|
||||
typedef void (*cpSpaceNearestPointQueryFunc)(cpShape *shape, cpFloat distance, cpVect point, void *data);
|
||||
/// Query the space at a point and call @c func for each shape found.
|
||||
void cpSpaceNearestPointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryFunc func, void *data);
|
||||
/// Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found.
|
||||
cpShape *cpSpaceNearestPointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpNearestPointQueryInfo *out);
|
||||
|
||||
/// Segment query callback function type.
|
||||
typedef void (*cpSpaceSegmentQueryFunc)(cpShape *shape, cpFloat t, cpVect n, void *data);
|
||||
/// Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected.
|
||||
|
|
|
@ -127,9 +127,8 @@ typedef void (*cpSpatialIndexReindexImpl)(cpSpatialIndex *index);
|
|||
typedef void (*cpSpatialIndexReindexObjectImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid);
|
||||
typedef void (*cpSpatialIndexReindexQueryImpl)(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data);
|
||||
|
||||
typedef void (*cpSpatialIndexPointQueryImpl)(cpSpatialIndex *index, cpVect point, cpSpatialIndexQueryFunc func, void *data);
|
||||
typedef void (*cpSpatialIndexSegmentQueryImpl)(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data);
|
||||
typedef void (*cpSpatialIndexQueryImpl)(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data);
|
||||
typedef void (*cpSpatialIndexSegmentQueryImpl)(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data);
|
||||
|
||||
struct cpSpatialIndexClass {
|
||||
cpSpatialIndexDestroyImpl destroy;
|
||||
|
@ -145,9 +144,8 @@ struct cpSpatialIndexClass {
|
|||
cpSpatialIndexReindexObjectImpl reindexObject;
|
||||
cpSpatialIndexReindexQueryImpl reindexQuery;
|
||||
|
||||
cpSpatialIndexPointQueryImpl pointQuery;
|
||||
cpSpatialIndexSegmentQueryImpl segmentQuery;
|
||||
cpSpatialIndexQueryImpl query;
|
||||
cpSpatialIndexSegmentQueryImpl segmentQuery;
|
||||
};
|
||||
|
||||
/// Destroy and free a spatial index.
|
||||
|
@ -206,11 +204,10 @@ static inline void cpSpatialIndexReindexObject(cpSpatialIndex *index, void *obj,
|
|||
index->klass->reindexObject(index, obj, hashid);
|
||||
}
|
||||
|
||||
/// Perform a point query against the spatial index, calling @c func for each potential match.
|
||||
/// A pointer to the point will be passed as @c obj1 of @c func.
|
||||
static inline void cpSpatialIndexPointQuery(cpSpatialIndex *index, cpVect point, cpSpatialIndexQueryFunc func, void *data)
|
||||
/// Perform a rectangle query against the spatial index, calling @c func for each potential match.
|
||||
static inline void cpSpatialIndexQuery(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data)
|
||||
{
|
||||
index->klass->pointQuery(index, point, func, data);
|
||||
index->klass->query(index, obj, bb, func, data);
|
||||
}
|
||||
|
||||
/// Perform a segment query against the spatial index, calling @c func for each potential match.
|
||||
|
@ -219,12 +216,6 @@ static inline void cpSpatialIndexSegmentQuery(cpSpatialIndex *index, void *obj,
|
|||
index->klass->segmentQuery(index, obj, a, b, t_exit, func, data);
|
||||
}
|
||||
|
||||
/// Perform a rectangle query against the spatial index, calling @c func for each potential match.
|
||||
static inline void cpSpatialIndexQuery(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data)
|
||||
{
|
||||
index->klass->query(index, obj, bb, func, data);
|
||||
}
|
||||
|
||||
/// Simultaneously reindex and find all colliding objects.
|
||||
/// @c func will be called once for each potentially overlapping pair of objects found.
|
||||
/// If the spatial index was initialized with a static index, it will collide it's objects against that as well.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
@ -87,7 +87,7 @@
|
|||
OutputDirectory="$(SolutionDir)$(ConfigurationName).win32"
|
||||
IntermediateDirectory="$(ConfigurationName).win32"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
|
|
|
@ -9,7 +9,7 @@ if(BUILD_SHARED)
|
|||
${chipmunk_source_files}
|
||||
)
|
||||
# set the lib's version number
|
||||
set_target_properties(chipmunk PROPERTIES VERSION 6.0.3)
|
||||
set_target_properties(chipmunk PROPERTIES VERSION 6.1.1)
|
||||
install(TARGETS chipmunk RUNTIME DESTINATION lib LIBRARY DESTINATION lib)
|
||||
endif(BUILD_SHARED)
|
||||
|
||||
|
|
|
@ -19,21 +19,12 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
// void cpInitCollisionFuncs(void);
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
void
|
||||
cpMessage(const char *condition, const char *file, int line, cpBool isError, cpBool isHardError, const char *message, ...)
|
||||
{
|
||||
|
@ -48,7 +39,7 @@ cpMessage(const char *condition, const char *file, int line, cpBool isError, cpB
|
|||
fprintf(stderr, "\tFailed condition: %s\n", condition);
|
||||
fprintf(stderr, "\tSource:%s:%d\n", file, line);
|
||||
|
||||
if(isHardError) abort();
|
||||
if(isError) abort();
|
||||
}
|
||||
|
||||
#define STR(s) #s
|
||||
|
@ -59,14 +50,11 @@ const char *cpVersionString = XSTR(CP_VERSION_MAJOR)"."XSTR(CP_VERSION_MINOR)"."
|
|||
void
|
||||
cpInitChipmunk(void)
|
||||
{
|
||||
//#ifndef NDEBUG
|
||||
// printf("Initializing Chipmunk v%s (Debug Enabled)\n", cpVersionString);
|
||||
// printf("Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks\n");
|
||||
//#endif
|
||||
//
|
||||
// cpInitCollisionFuncs();
|
||||
cpAssertWarn(cpFalse, "cpInitChipmunk is deprecated and no longer required. It will be removed in the future.");
|
||||
}
|
||||
|
||||
//MARK: Misc Functions
|
||||
|
||||
cpFloat
|
||||
cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset)
|
||||
{
|
||||
|
@ -82,10 +70,8 @@ cpAreaForCircle(cpFloat r1, cpFloat r2)
|
|||
cpFloat
|
||||
cpMomentForSegment(cpFloat m, cpVect a, cpVect b)
|
||||
{
|
||||
cpFloat length = cpvlength(cpvsub(b, a));
|
||||
cpVect offset = cpvmult(cpvadd(a, b), 1.0f/2.0f);
|
||||
|
||||
return m*(length*length/12.0f + cpvlengthsq(offset));
|
||||
cpVect offset = cpvmult(cpvadd(a, b), 0.5f);
|
||||
return m*(cpvdistsq(b, a)/12.0f + cpvlengthsq(offset));
|
||||
}
|
||||
|
||||
cpFloat
|
||||
|
@ -164,7 +150,173 @@ cpMomentForBox2(cpFloat m, cpBB box)
|
|||
cpFloat height = box.t - box.b;
|
||||
cpVect offset = cpvmult(cpv(box.l + box.r, box.b + box.t), 0.5f);
|
||||
|
||||
// TODO NaN when offset is 0 and m is INFINITY
|
||||
return cpMomentForBox(m, width, height) + m*cpvlengthsq(offset);
|
||||
}
|
||||
|
||||
//MARK: Quick Hull
|
||||
|
||||
void
|
||||
cpLoopIndexes(cpVect *verts, int count, int *start, int *end)
|
||||
{
|
||||
(*start) = (*end) = 0;
|
||||
cpVect min = verts[0];
|
||||
cpVect max = min;
|
||||
|
||||
for(int i=1; i<count; i++){
|
||||
cpVect v = verts[i];
|
||||
|
||||
if(v.x < min.x || (v.x == min.x && v.y < min.y)){
|
||||
min = v;
|
||||
(*start) = i;
|
||||
} else if(v.x > max.x || (v.x == max.x && v.y > max.y)){
|
||||
max = v;
|
||||
(*end) = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define SWAP(__A__, __B__) {cpVect __TMP__ = __A__; __A__ = __B__; __B__ = __TMP__;}
|
||||
|
||||
static int
|
||||
QHullPartition(cpVect *verts, int count, cpVect a, cpVect b, cpFloat tol)
|
||||
{
|
||||
if(count == 0) return 0;
|
||||
|
||||
cpFloat max = 0;
|
||||
int pivot = 0;
|
||||
|
||||
cpVect delta = cpvsub(b, a);
|
||||
cpFloat valueTol = tol*cpvlength(delta);
|
||||
|
||||
int head = 0;
|
||||
for(int tail = count-1; head <= tail;){
|
||||
cpFloat value = cpvcross(delta, cpvsub(verts[head], a));
|
||||
if(value > valueTol){
|
||||
if(value > max){
|
||||
max = value;
|
||||
pivot = head;
|
||||
}
|
||||
|
||||
head++;
|
||||
} else {
|
||||
SWAP(verts[head], verts[tail]);
|
||||
tail--;
|
||||
}
|
||||
}
|
||||
|
||||
// move the new pivot to the front if it's not already there.
|
||||
if(pivot != 0) SWAP(verts[0], verts[pivot]);
|
||||
return head;
|
||||
}
|
||||
|
||||
static int
|
||||
QHullReduce(cpFloat tol, cpVect *verts, int count, cpVect a, cpVect pivot, cpVect b, cpVect *result)
|
||||
{
|
||||
if(count < 0){
|
||||
return 0;
|
||||
} else if(count == 0) {
|
||||
result[0] = pivot;
|
||||
return 1;
|
||||
} else {
|
||||
int left_count = QHullPartition(verts, count, a, pivot, tol);
|
||||
int index = QHullReduce(tol, verts + 1, left_count - 1, a, verts[0], pivot, result);
|
||||
|
||||
result[index++] = pivot;
|
||||
|
||||
int right_count = QHullPartition(verts + left_count, count - left_count, pivot, b, tol);
|
||||
return index + QHullReduce(tol, verts + left_count + 1, right_count - 1, pivot, verts[left_count], b, result + index);
|
||||
}
|
||||
}
|
||||
|
||||
// QuickHull seemed like a neat algorithm, and efficient-ish for large input sets.
|
||||
// My implementation performs an in place reduction using the result array as scratch space.
|
||||
int
|
||||
cpConvexHull(int count, cpVect *verts, cpVect *result, int *first, cpFloat tol)
|
||||
{
|
||||
if(result){
|
||||
// Copy the line vertexes into the empty part of the result polyline to use as a scratch buffer.
|
||||
memcpy(result, verts, count*sizeof(cpVect));
|
||||
} else {
|
||||
// If a result array was not specified, reduce the input instead.
|
||||
result = verts;
|
||||
}
|
||||
|
||||
// Degenerate case, all poins are the same.
|
||||
int start, end;
|
||||
cpLoopIndexes(verts, count, &start, &end);
|
||||
if(start == end){
|
||||
if(first) (*first) = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SWAP(result[0], result[start]);
|
||||
SWAP(result[1], result[end == 0 ? start : end]);
|
||||
|
||||
cpVect a = result[0];
|
||||
cpVect b = result[1];
|
||||
|
||||
if(first) (*first) = start;
|
||||
int resultCount = QHullReduce(tol, result + 2, count - 2, a, b, a, result + 1) + 1;
|
||||
cpAssertSoft(cpPolyValidate(result, resultCount),
|
||||
"Internal error: cpConvexHull() and cpPolyValidate() did not agree."
|
||||
"Please report this error with as much info as you can.");
|
||||
return resultCount;
|
||||
}
|
||||
|
||||
//MARK: Alternate Block Iterators
|
||||
|
||||
#if defined(__has_extension)
|
||||
#if __has_extension(blocks)
|
||||
|
||||
static void IteratorFunc(void *ptr, void (^block)(void *ptr)){block(ptr);}
|
||||
|
||||
void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body)){
|
||||
cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)IteratorFunc, block);
|
||||
}
|
||||
|
||||
void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape)){
|
||||
cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)IteratorFunc, block);
|
||||
}
|
||||
|
||||
void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint)){
|
||||
cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)IteratorFunc, block);
|
||||
}
|
||||
|
||||
static void BodyIteratorFunc(cpBody *body, void *ptr, void (^block)(void *ptr)){block(ptr);}
|
||||
|
||||
void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape)){
|
||||
cpBodyEachShape(body, (cpBodyShapeIteratorFunc)BodyIteratorFunc, block);
|
||||
}
|
||||
|
||||
void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint)){
|
||||
cpBodyEachConstraint(body, (cpBodyConstraintIteratorFunc)BodyIteratorFunc, block);
|
||||
}
|
||||
|
||||
void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter)){
|
||||
cpBodyEachArbiter(body, (cpBodyArbiterIteratorFunc)BodyIteratorFunc, block);
|
||||
}
|
||||
|
||||
static void NearestPointQueryIteratorFunc(cpShape *shape, cpFloat distance, cpVect point, cpSpaceNearestPointQueryBlock block){block(shape, distance, point);}
|
||||
void cpSpaceNearestPointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryBlock block){
|
||||
cpSpaceNearestPointQuery(space, point, maxDistance, layers, group, (cpSpaceNearestPointQueryFunc)NearestPointQueryIteratorFunc, block);
|
||||
}
|
||||
|
||||
static void SegmentQueryIteratorFunc(cpShape *shape, cpFloat t, cpVect n, cpSpaceSegmentQueryBlock block){block(shape, t, n);}
|
||||
void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryBlock block){
|
||||
cpSpaceSegmentQuery(space, start, end, layers, group, (cpSpaceSegmentQueryFunc)SegmentQueryIteratorFunc, block);
|
||||
}
|
||||
|
||||
void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryBlock block){
|
||||
cpSpaceBBQuery(space, bb, layers, group, (cpSpaceBBQueryFunc)IteratorFunc, block);
|
||||
}
|
||||
|
||||
static void ShapeQueryIteratorFunc(cpShape *shape, cpContactPointSet *points, cpSpaceShapeQueryBlock block){block(shape, points);}
|
||||
cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block){
|
||||
return cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)ShapeQueryIteratorFunc, block);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "chipmunk_ffi.h"
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
@ -47,6 +44,7 @@ cpConstraintInit(cpConstraint *constraint, const cpConstraintClass *klass, cpBod
|
|||
|
||||
constraint->a = a;
|
||||
constraint->b = b;
|
||||
constraint->space = NULL;
|
||||
|
||||
constraint->next_a = NULL;
|
||||
constraint->next_b = NULL;
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
@ -42,7 +39,6 @@ preStep(cpSlideJoint *joint, cpFloat dt)
|
|||
joint->n = cpvnormalize_safe(delta);
|
||||
} else if(dist < joint->min) {
|
||||
pdist = joint->min - dist;
|
||||
dist = -dist;
|
||||
joint->n = cpvneg(cpvnormalize_safe(delta));
|
||||
} else {
|
||||
joint->n = cpvzero;
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
||||
|
@ -68,10 +65,21 @@ cpArbiterUnthread(cpArbiter *arb)
|
|||
unthreadHelper(arb, arb->body_b);
|
||||
}
|
||||
|
||||
cpBool cpArbiterIsFirstContact(const cpArbiter *arb)
|
||||
{
|
||||
return arb->CP_PRIVATE(state) == cpArbiterStateFirstColl;
|
||||
}
|
||||
|
||||
int cpArbiterGetCount(const cpArbiter *arb)
|
||||
{
|
||||
// Return 0 contacts if we are in a separate callback.
|
||||
return (arb->CP_PRIVATE(state) != cpArbiterStateCached ? arb->CP_PRIVATE(numContacts) : 0);
|
||||
}
|
||||
|
||||
cpVect
|
||||
cpArbiterGetNormal(const cpArbiter *arb, int i)
|
||||
{
|
||||
cpAssertHard(0 <= i && i < arb->numContacts, "Index error: The specified contact index is invalid for this arbiter");
|
||||
cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter");
|
||||
|
||||
cpVect n = arb->contacts[i].n;
|
||||
return arb->swappedColl ? cpvneg(n) : n;
|
||||
|
@ -80,7 +88,7 @@ cpArbiterGetNormal(const cpArbiter *arb, int i)
|
|||
cpVect
|
||||
cpArbiterGetPoint(const cpArbiter *arb, int i)
|
||||
{
|
||||
cpAssertHard(0 <= i && i < arb->numContacts, "Index error: The specified contact index is invalid for this arbiter");
|
||||
cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter");
|
||||
|
||||
return arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(p);
|
||||
}
|
||||
|
@ -88,7 +96,7 @@ cpArbiterGetPoint(const cpArbiter *arb, int i)
|
|||
cpFloat
|
||||
cpArbiterGetDepth(const cpArbiter *arb, int i)
|
||||
{
|
||||
cpAssertHard(0 <= i && i < arb->numContacts, "Index error: The specified contact index is invalid for this arbiter");
|
||||
cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter");
|
||||
|
||||
return arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(dist);
|
||||
}
|
||||
|
@ -116,7 +124,7 @@ cpArbiterTotalImpulse(const cpArbiter *arb)
|
|||
cpContact *contacts = arb->contacts;
|
||||
cpVect sum = cpvzero;
|
||||
|
||||
for(int i=0, count=arb->numContacts; i<count; i++){
|
||||
for(int i=0, count=cpArbiterGetCount(arb); i<count; i++){
|
||||
cpContact *con = &contacts[i];
|
||||
sum = cpvadd(sum, cpvmult(con->n, con->jnAcc));
|
||||
}
|
||||
|
@ -130,7 +138,7 @@ cpArbiterTotalImpulseWithFriction(const cpArbiter *arb)
|
|||
cpContact *contacts = arb->contacts;
|
||||
cpVect sum = cpvzero;
|
||||
|
||||
for(int i=0, count=arb->numContacts; i<count; i++){
|
||||
for(int i=0, count=cpArbiterGetCount(arb); i<count; i++){
|
||||
cpContact *con = &contacts[i];
|
||||
sum = cpvadd(sum, cpvrotate(con->n, cpv(con->jnAcc, con->jtAcc)));
|
||||
}
|
||||
|
@ -145,7 +153,7 @@ cpArbiterTotalKE(const cpArbiter *arb)
|
|||
cpFloat sum = 0.0;
|
||||
|
||||
cpContact *contacts = arb->contacts;
|
||||
for(int i=0, count=arb->numContacts; i<count; i++){
|
||||
for(int i=0, count=cpArbiterGetCount(arb); i<count; i++){
|
||||
cpContact *con = &contacts[i];
|
||||
cpFloat jnAcc = con->jnAcc;
|
||||
cpFloat jtAcc = con->jtAcc;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
||||
cpVect
|
||||
|
|
|
@ -308,7 +308,7 @@ NodeReplaceChild(Node *parent, Node *child, Node *value, cpBBTree *tree)
|
|||
static inline cpFloat
|
||||
cpBBProximity(cpBB a, cpBB b)
|
||||
{
|
||||
return cpfabs(a.l + a.r - b.l - b.r) + cpfabs(a.b + b.t - b.b - b.t);
|
||||
return cpfabs(a.l + a.r - b.l - b.r) + cpfabs(a.b + a.t - b.b - b.t);
|
||||
}
|
||||
|
||||
static Node *
|
||||
|
@ -658,13 +658,6 @@ cpBBTreeReindexObject(cpBBTree *tree, void *obj, cpHashValue hashid)
|
|||
|
||||
//MARK: Query
|
||||
|
||||
static void
|
||||
cpBBTreePointQuery(cpBBTree *tree, cpVect point, cpSpatialIndexQueryFunc func, void *data)
|
||||
{
|
||||
Node *root = tree->root;
|
||||
if(root) SubtreeQuery(root, &point, cpBBNew(point.x, point.y, point.x, point.y), func, data);
|
||||
}
|
||||
|
||||
static void
|
||||
cpBBTreeSegmentQuery(cpBBTree *tree, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data)
|
||||
{
|
||||
|
@ -714,9 +707,8 @@ static cpSpatialIndexClass klass = {
|
|||
(cpSpatialIndexReindexObjectImpl)cpBBTreeReindexObject,
|
||||
(cpSpatialIndexReindexQueryImpl)cpBBTreeReindexQuery,
|
||||
|
||||
(cpSpatialIndexPointQueryImpl)cpBBTreePointQuery,
|
||||
(cpSpatialIndexSegmentQueryImpl)cpBBTreeSegmentQuery,
|
||||
(cpSpatialIndexQueryImpl)cpBBTreeQuery,
|
||||
(cpSpatialIndexSegmentQueryImpl)cpBBTreeSegmentQuery,
|
||||
};
|
||||
|
||||
static inline cpSpatialIndexClass *Klass(){return &klass;}
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "constraints/util.h"
|
||||
|
@ -126,7 +124,7 @@ cpBodySanityCheck(cpBody *body)
|
|||
cpAssertSoft(body->w == body->w && cpfabs(body->w) != INFINITY, "Body's angular velocity is invalid.");
|
||||
cpAssertSoft(body->t == body->t && cpfabs(body->t) != INFINITY, "Body's torque is invalid.");
|
||||
|
||||
cpv_assert_sane(body->rot, "Internal error: Body's rotation vector is invalid.");
|
||||
cpv_assert_sane(body->rot, "Body's rotation vector is invalid.");
|
||||
|
||||
cpAssertSoft(body->v_limit == body->v_limit, "Body's velocity limit is invalid.");
|
||||
cpAssertSoft(body->w_limit == body->w_limit, "Body's angular velocity limit is invalid.");
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
//#include <stdio.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
||||
typedef int (*collisionFunc)(const cpShape *, const cpShape *, cpContact *);
|
||||
|
@ -104,14 +100,14 @@ nextContactPoint(cpContact *arr, int *numPtr)
|
|||
|
||||
// Find the minimum separating axis for the give poly and axis list.
|
||||
static inline int
|
||||
findMSA(const cpPolyShape *poly, const cpPolyShapeAxis *axes, const int num, cpFloat *min_out)
|
||||
findMSA(const cpPolyShape *poly, const cpSplittingPlane *planes, const int num, cpFloat *min_out)
|
||||
{
|
||||
int min_index = 0;
|
||||
cpFloat min = cpPolyShapeValueOnAxis(poly, axes->n, axes->d);
|
||||
cpFloat min = cpPolyShapeValueOnAxis(poly, planes->n, planes->d);
|
||||
if(min > 0.0f) return -1;
|
||||
|
||||
for(int i=1; i<num; i++){
|
||||
cpFloat dist = cpPolyShapeValueOnAxis(poly, axes[i].n, axes[i].d);
|
||||
cpFloat dist = cpPolyShapeValueOnAxis(poly, planes[i].n, planes[i].d);
|
||||
if(dist > 0.0f) {
|
||||
return -1;
|
||||
} else if(dist > min){
|
||||
|
@ -176,18 +172,18 @@ poly2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr)
|
|||
cpPolyShape *poly2 = (cpPolyShape *)shape2;
|
||||
|
||||
cpFloat min1;
|
||||
int mini1 = findMSA(poly2, poly1->tAxes, poly1->numVerts, &min1);
|
||||
int mini1 = findMSA(poly2, poly1->tPlanes, poly1->numVerts, &min1);
|
||||
if(mini1 == -1) return 0;
|
||||
|
||||
cpFloat min2;
|
||||
int mini2 = findMSA(poly1, poly2->tAxes, poly2->numVerts, &min2);
|
||||
int mini2 = findMSA(poly1, poly2->tPlanes, poly2->numVerts, &min2);
|
||||
if(mini2 == -1) return 0;
|
||||
|
||||
// There is overlap, find the penetrating verts
|
||||
if(min1 > min2)
|
||||
return findVerts(arr, poly1, poly2, poly1->tAxes[mini1].n, min1);
|
||||
return findVerts(arr, poly1, poly2, poly1->tPlanes[mini1].n, min1);
|
||||
else
|
||||
return findVerts(arr, poly1, poly2, cpvneg(poly2->tAxes[mini2].n), min2);
|
||||
return findVerts(arr, poly1, poly2, cpvneg(poly2->tPlanes[mini2].n), min2);
|
||||
}
|
||||
|
||||
// Like cpPolyValueOnAxis(), but for segments.
|
||||
|
@ -225,7 +221,7 @@ seg2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr)
|
|||
{
|
||||
cpSegmentShape *seg = (cpSegmentShape *)shape1;
|
||||
cpPolyShape *poly = (cpPolyShape *)shape2;
|
||||
cpPolyShapeAxis *axes = poly->tAxes;
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
|
||||
cpFloat segD = cpvdot(seg->tn, seg->ta);
|
||||
cpFloat minNorm = cpPolyShapeValueOnAxis(poly, seg->tn, segD) - seg->r;
|
||||
|
@ -233,10 +229,10 @@ seg2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr)
|
|||
if(minNeg > 0.0f || minNorm > 0.0f) return 0;
|
||||
|
||||
int mini = 0;
|
||||
cpFloat poly_min = segValueOnAxis(seg, axes->n, axes->d);
|
||||
cpFloat poly_min = segValueOnAxis(seg, planes->n, planes->d);
|
||||
if(poly_min > 0.0f) return 0;
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
cpFloat dist = segValueOnAxis(seg, axes[i].n, axes[i].d);
|
||||
cpFloat dist = segValueOnAxis(seg, planes[i].n, planes[i].d);
|
||||
if(dist > 0.0f){
|
||||
return 0;
|
||||
} else if(dist > poly_min){
|
||||
|
@ -247,7 +243,7 @@ seg2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr)
|
|||
|
||||
int num = 0;
|
||||
|
||||
cpVect poly_n = cpvneg(axes[mini].n);
|
||||
cpVect poly_n = cpvneg(planes[mini].n);
|
||||
|
||||
cpVect va = cpvadd(seg->ta, cpvmult(poly_n, seg->r));
|
||||
cpVect vb = cpvadd(seg->tb, cpvmult(poly_n, seg->r));
|
||||
|
@ -288,12 +284,12 @@ circle2poly(const cpShape *shape1, const cpShape *shape2, cpContact *con)
|
|||
{
|
||||
cpCircleShape *circ = (cpCircleShape *)shape1;
|
||||
cpPolyShape *poly = (cpPolyShape *)shape2;
|
||||
cpPolyShapeAxis *axes = poly->tAxes;
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
|
||||
int mini = 0;
|
||||
cpFloat min = cpvdot(axes->n, circ->tc) - axes->d - circ->r;
|
||||
cpFloat min = cpSplittingPlaneCompare(planes[0], circ->tc) - circ->r;
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
cpFloat dist = cpvdot(axes[i].n, circ->tc) - axes[i].d - circ->r;
|
||||
cpFloat dist = cpSplittingPlaneCompare(planes[i], circ->tc) - circ->r;
|
||||
if(dist > 0.0f){
|
||||
return 0;
|
||||
} else if(dist > min) {
|
||||
|
@ -302,7 +298,7 @@ circle2poly(const cpShape *shape1, const cpShape *shape2, cpContact *con)
|
|||
}
|
||||
}
|
||||
|
||||
cpVect n = axes[mini].n;
|
||||
cpVect n = planes[mini].n;
|
||||
cpVect a = poly->tVerts[mini];
|
||||
cpVect b = poly->tVerts[(mini + 1)%poly->numVerts];
|
||||
cpFloat dta = cpvcross(n, a);
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "prime.h"
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "chipmunk_unsafe.h"
|
||||
|
||||
|
@ -55,8 +53,8 @@ cpPolyShapeTransformVerts(cpPolyShape *poly, cpVect p, cpVect rot)
|
|||
static void
|
||||
cpPolyShapeTransformAxes(cpPolyShape *poly, cpVect p, cpVect rot)
|
||||
{
|
||||
cpPolyShapeAxis *src = poly->axes;
|
||||
cpPolyShapeAxis *dst = poly->tAxes;
|
||||
cpSplittingPlane *src = poly->planes;
|
||||
cpSplittingPlane *dst = poly->tPlanes;
|
||||
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
cpVect n = cpvrotate(src[i].n, rot);
|
||||
|
@ -78,21 +76,44 @@ static void
|
|||
cpPolyShapeDestroy(cpPolyShape *poly)
|
||||
{
|
||||
cpfree(poly->verts);
|
||||
cpfree(poly->tVerts);
|
||||
|
||||
cpfree(poly->axes);
|
||||
cpfree(poly->tAxes);
|
||||
cpfree(poly->planes);
|
||||
}
|
||||
|
||||
static cpBool
|
||||
cpPolyShapePointQuery(cpPolyShape *poly, cpVect p){
|
||||
return cpBBContainsVect(poly->shape.bb, p) && cpPolyShapeContainsVert(poly, p);
|
||||
static void
|
||||
cpPolyShapeNearestPointQuery(cpPolyShape *poly, cpVect p, cpNearestPointQueryInfo *info){
|
||||
int count = poly->numVerts;
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
cpVect *verts = poly->tVerts;
|
||||
|
||||
cpVect v0 = verts[count - 1];
|
||||
cpFloat minDist = INFINITY;
|
||||
cpVect closestPoint = cpvzero;
|
||||
cpBool outside = cpFalse;
|
||||
|
||||
for(int i=0; i<count; i++){
|
||||
if(cpSplittingPlaneCompare(planes[i], p) > 0.0f) outside = cpTrue;
|
||||
|
||||
cpVect v1 = verts[i];
|
||||
cpVect closest = cpClosetPointOnSegment(p, v0, v1);
|
||||
|
||||
cpFloat dist = cpvdist(p, closest);
|
||||
if(dist < minDist){
|
||||
minDist = dist;
|
||||
closestPoint = closest;
|
||||
}
|
||||
|
||||
v0 = v1;
|
||||
}
|
||||
|
||||
info->shape = (cpShape *)poly;
|
||||
info->p = closestPoint; // TODO div/0
|
||||
info->d = (outside ? minDist : -minDist);
|
||||
}
|
||||
|
||||
static void
|
||||
cpPolyShapeSegmentQuery(cpPolyShape *poly, cpVect a, cpVect b, cpSegmentQueryInfo *info)
|
||||
{
|
||||
cpPolyShapeAxis *axes = poly->tAxes;
|
||||
cpSplittingPlane *axes = poly->tPlanes;
|
||||
cpVect *verts = poly->tVerts;
|
||||
int numVerts = poly->numVerts;
|
||||
|
||||
|
@ -122,7 +143,7 @@ static const cpShapeClass polyClass = {
|
|||
CP_POLY_SHAPE,
|
||||
(cpShapeCacheDataImpl)cpPolyShapeCacheData,
|
||||
(cpShapeDestroyImpl)cpPolyShapeDestroy,
|
||||
(cpShapePointQueryImpl)cpPolyShapePointQuery,
|
||||
(cpShapeNearestPointQueryImpl)cpPolyShapeNearestPointQuery,
|
||||
(cpShapeSegmentQueryImpl)cpPolyShapeSegmentQuery,
|
||||
};
|
||||
|
||||
|
@ -134,9 +155,10 @@ cpPolyValidate(const cpVect *verts, const int numVerts)
|
|||
cpVect b = verts[(i+1)%numVerts];
|
||||
cpVect c = verts[(i+2)%numVerts];
|
||||
|
||||
if(cpvcross(cpvsub(b, a), cpvsub(c, b)) > 0.0f)
|
||||
if(cpvcross(cpvsub(b, a), cpvsub(c, a)) > 0.0f){
|
||||
return cpFalse;
|
||||
}
|
||||
}
|
||||
|
||||
return cpTrue;
|
||||
}
|
||||
|
@ -161,12 +183,14 @@ cpPolyShapeGetVert(cpShape *shape, int idx)
|
|||
static void
|
||||
setUpVerts(cpPolyShape *poly, int numVerts, cpVect *verts, cpVect offset)
|
||||
{
|
||||
poly->numVerts = numVerts;
|
||||
// Fail if the user attempts to pass a concave poly, or a bad winding.
|
||||
cpAssertHard(cpPolyValidate(verts, numVerts), "Polygon is concave or has a reversed winding. Consider using cpConvexHull() or CP_CONVEX_HULL().");
|
||||
|
||||
poly->verts = (cpVect *)cpcalloc(numVerts, sizeof(cpVect));
|
||||
poly->tVerts = (cpVect *)cpcalloc(numVerts, sizeof(cpVect));
|
||||
poly->axes = (cpPolyShapeAxis *)cpcalloc(numVerts, sizeof(cpPolyShapeAxis));
|
||||
poly->tAxes = (cpPolyShapeAxis *)cpcalloc(numVerts, sizeof(cpPolyShapeAxis));
|
||||
poly->numVerts = numVerts;
|
||||
poly->verts = (cpVect *)cpcalloc(2*numVerts, sizeof(cpVect));
|
||||
poly->planes = (cpSplittingPlane *)cpcalloc(2*numVerts, sizeof(cpSplittingPlane));
|
||||
poly->tVerts = poly->verts + numVerts;
|
||||
poly->tPlanes = poly->planes + numVerts;
|
||||
|
||||
for(int i=0; i<numVerts; i++){
|
||||
cpVect a = cpvadd(offset, verts[i]);
|
||||
|
@ -174,17 +198,15 @@ setUpVerts(cpPolyShape *poly, int numVerts, cpVect *verts, cpVect offset)
|
|||
cpVect n = cpvnormalize(cpvperp(cpvsub(b, a)));
|
||||
|
||||
poly->verts[i] = a;
|
||||
poly->axes[i].n = n;
|
||||
poly->axes[i].d = cpvdot(n, a);
|
||||
poly->planes[i].n = n;
|
||||
poly->planes[i].d = cpvdot(n, a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cpPolyShape *
|
||||
cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset)
|
||||
{
|
||||
// Fail if the user attempts to pass a concave poly, or a bad winding.
|
||||
cpAssertHard(cpPolyValidate(verts, numVerts), "Polygon is concave or has a reversed winding.");
|
||||
|
||||
setUpVerts(poly, numVerts, verts, offset);
|
||||
cpShapeInit((cpShape *)poly, &polyClass, body);
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "chipmunk_unsafe.h"
|
||||
|
||||
|
@ -61,6 +57,9 @@ cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body)
|
|||
shape->layers = CP_ALL_LAYERS;
|
||||
|
||||
shape->data = NULL;
|
||||
|
||||
shape->space = NULL;
|
||||
|
||||
shape->next = NULL;
|
||||
shape->prev = NULL;
|
||||
|
||||
|
@ -85,7 +84,7 @@ cpShapeFree(cpShape *shape)
|
|||
void
|
||||
cpShapeSetBody(cpShape *shape, cpBody *body)
|
||||
{
|
||||
cpAssertHard(!cpShapeActive(shape), "You cannot change the body on an active shape. You must remove the shape, then ");
|
||||
cpAssertHard(!cpShapeActive(shape), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body.");
|
||||
shape->body = body;
|
||||
}
|
||||
|
||||
|
@ -104,13 +103,35 @@ cpShapeUpdate(cpShape *shape, cpVect pos, cpVect rot)
|
|||
|
||||
cpBool
|
||||
cpShapePointQuery(cpShape *shape, cpVect p){
|
||||
return shape->klass->pointQuery(shape, p);
|
||||
cpNearestPointQueryInfo info = {};
|
||||
cpShapeNearestPointQuery(shape, p, &info);
|
||||
|
||||
return (info.d < 0.0f);
|
||||
}
|
||||
|
||||
cpFloat
|
||||
cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpNearestPointQueryInfo *info)
|
||||
{
|
||||
cpNearestPointQueryInfo blank = {NULL, cpvzero, INFINITY};
|
||||
if(info){
|
||||
(*info) = blank;
|
||||
} else {
|
||||
info = ␣
|
||||
}
|
||||
|
||||
shape->klass->nearestPointQuery(shape, p, info);
|
||||
return info->d;
|
||||
}
|
||||
|
||||
|
||||
cpBool
|
||||
cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info){
|
||||
cpSegmentQueryInfo blank = {NULL, 0.0f, cpvzero};
|
||||
if(info){
|
||||
(*info) = blank;
|
||||
} else {
|
||||
info = ␣
|
||||
}
|
||||
|
||||
shape->klass->segmentQuery(shape, a, b, info);
|
||||
return (info->shape != NULL);
|
||||
|
@ -129,9 +150,16 @@ cpCircleShapeCacheData(cpCircleShape *circle, cpVect p, cpVect rot)
|
|||
return cpBBNewForCircle(c, circle->r);
|
||||
}
|
||||
|
||||
static cpBool
|
||||
cpCircleShapePointQuery(cpCircleShape *circle, cpVect p){
|
||||
return cpvnear(circle->tc, p, circle->r);
|
||||
static void
|
||||
cpCicleShapeNearestPointQuery(cpCircleShape *circle, cpVect p, cpNearestPointQueryInfo *info)
|
||||
{
|
||||
cpVect delta = cpvsub(p, circle->tc);
|
||||
cpFloat d = cpvlength(delta);
|
||||
cpFloat r = circle->r;
|
||||
|
||||
info->shape = (cpShape *)circle;
|
||||
info->p = cpvadd(circle->tc, cpvmult(delta, r/d)); // TODO div/0
|
||||
info->d = d - r;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -167,7 +195,7 @@ static const cpShapeClass cpCircleShapeClass = {
|
|||
CP_CIRCLE_SHAPE,
|
||||
(cpShapeCacheDataImpl)cpCircleShapeCacheData,
|
||||
NULL,
|
||||
(cpShapePointQueryImpl)cpCircleShapePointQuery,
|
||||
(cpShapeNearestPointQueryImpl)cpCicleShapeNearestPointQuery,
|
||||
(cpShapeSegmentQueryImpl)cpCircleShapeSegmentQuery,
|
||||
};
|
||||
|
||||
|
@ -226,40 +254,18 @@ cpSegmentShapeCacheData(cpSegmentShape *seg, cpVect p, cpVect rot)
|
|||
return cpBBNew(l - rad, b - rad, r + rad, t + rad);
|
||||
}
|
||||
|
||||
static cpBool
|
||||
cpSegmentShapePointQuery(cpSegmentShape *seg, cpVect p){
|
||||
if(!cpBBContainsVect(seg->shape.bb, p)) return cpFalse;
|
||||
static void
|
||||
cpSegmentShapeNearestPointQuery(cpSegmentShape *seg, cpVect p, cpNearestPointQueryInfo *info)
|
||||
{
|
||||
cpVect closest = cpClosetPointOnSegment(p, seg->ta, seg->tb);
|
||||
|
||||
// Calculate normal distance from segment.
|
||||
cpFloat dn = cpvdot(seg->tn, p) - cpvdot(seg->ta, seg->tn);
|
||||
cpFloat dist = cpfabs(dn) - seg->r;
|
||||
if(dist > 0.0f) return cpFalse;
|
||||
cpVect delta = cpvsub(p, closest);
|
||||
cpFloat d = cpvlength(delta);
|
||||
cpFloat r = seg->r;
|
||||
|
||||
// Calculate tangential distance along segment.
|
||||
cpFloat dt = -cpvcross(seg->tn, p);
|
||||
cpFloat dtMin = -cpvcross(seg->tn, seg->ta);
|
||||
cpFloat dtMax = -cpvcross(seg->tn, seg->tb);
|
||||
|
||||
// Decision tree to decide which feature of the segment to collide with.
|
||||
if(dt <= dtMin){
|
||||
if(dt < (dtMin - seg->r)){
|
||||
return cpFalse;
|
||||
} else {
|
||||
return cpvlengthsq(cpvsub(seg->ta, p)) < (seg->r*seg->r);
|
||||
}
|
||||
} else {
|
||||
if(dt < dtMax){
|
||||
return cpTrue;
|
||||
} else {
|
||||
if(dt < (dtMax + seg->r)) {
|
||||
return cpvlengthsq(cpvsub(seg->tb, p)) < (seg->r*seg->r);
|
||||
} else {
|
||||
return cpFalse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cpTrue;
|
||||
info->shape = (cpShape *)seg;
|
||||
info->p = (d ? cpvadd(closest, cpvmult(delta, r/d)) : closest);
|
||||
info->d = d - r;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -305,7 +311,7 @@ static const cpShapeClass cpSegmentShapeClass = {
|
|||
CP_SEGMENT_SHAPE,
|
||||
(cpShapeCacheDataImpl)cpSegmentShapeCacheData,
|
||||
NULL,
|
||||
(cpShapePointQueryImpl)cpSegmentShapePointQuery,
|
||||
(cpShapeNearestPointQueryImpl)cpSegmentShapeNearestPointQuery,
|
||||
(cpShapeSegmentQueryImpl)cpSegmentShapeSegmentQuery,
|
||||
};
|
||||
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
||||
|
@ -128,9 +126,8 @@ cpSpaceInit(cpSpace *space)
|
|||
space->collisionHandlers = cpHashSetNew(0, (cpHashSetEqlFunc)handlerSetEql);
|
||||
cpHashSetSetDefaultValue(space->collisionHandlers, &cpDefaultCollisionHandler);
|
||||
|
||||
space->postStepCallbacks = NULL;
|
||||
|
||||
space->arbiterApplyImpulse = cpArbiterApplyImpulse;
|
||||
space->postStepCallbacks = cpArrayNew(0);
|
||||
space->skipPostStep = cpFalse;
|
||||
|
||||
cpBodyInitStatic(&space->_staticBody);
|
||||
space->staticBody = &space->_staticBody;
|
||||
|
@ -147,6 +144,8 @@ cpSpaceNew(void)
|
|||
void
|
||||
cpSpaceDestroy(cpSpace *space)
|
||||
{
|
||||
cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)cpBodyActivate, NULL);
|
||||
|
||||
cpSpatialIndexFree(space->staticShapes);
|
||||
cpSpatialIndexFree(space->activeShapes);
|
||||
|
||||
|
@ -166,8 +165,10 @@ cpSpaceDestroy(cpSpace *space)
|
|||
cpArrayFree(space->allocatedBuffers);
|
||||
}
|
||||
|
||||
if(space->postStepCallbacks) cpHashSetEach(space->postStepCallbacks, freeWrap, NULL);
|
||||
cpHashSetFree(space->postStepCallbacks);
|
||||
if(space->postStepCallbacks){
|
||||
cpArrayFreeEach(space->postStepCallbacks, cpfree);
|
||||
cpArrayFree(space->postStepCallbacks);
|
||||
}
|
||||
|
||||
if(space->collisionHandlers) cpHashSetEach(space->collisionHandlers, freeWrap, NULL);
|
||||
cpHashSetFree(space->collisionHandlers);
|
||||
|
@ -352,8 +353,10 @@ cachedArbitersFilter(cpArbiter *arb, struct arbiterFilterContext *context)
|
|||
void
|
||||
cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter)
|
||||
{
|
||||
cpSpaceLock(space); {
|
||||
struct arbiterFilterContext context = {space, body, filter};
|
||||
cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cachedArbitersFilter, &context);
|
||||
} cpSpaceUnlock(space, cpTrue);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
@ -212,20 +210,31 @@ ComponentActive(cpBody *root, cpFloat threshold)
|
|||
void
|
||||
cpSpaceProcessComponents(cpSpace *space, cpFloat dt)
|
||||
{
|
||||
cpBool sleep = (space->sleepTimeThreshold != INFINITY);
|
||||
cpArray *bodies = space->bodies;
|
||||
|
||||
#ifndef NDEBUG
|
||||
for(int i=0; i<bodies->num; i++){
|
||||
cpBody *body = (cpBody*)bodies->arr[i];
|
||||
|
||||
cpAssertSoft(body->node.next == NULL, "Internal Error: Dangling next pointer detected in contact graph.");
|
||||
cpAssertSoft(body->node.root == NULL, "Internal Error: Dangling root pointer detected in contact graph.");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Calculate the kinetic energy of all the bodies.
|
||||
if(sleep){
|
||||
cpFloat dv = space->idleSpeedThreshold;
|
||||
cpFloat dvsq = (dv ? dv*dv : cpvlengthsq(space->gravity)*dt*dt);
|
||||
|
||||
// update idling and reset component nodes
|
||||
cpArray *bodies = space->bodies;
|
||||
for(int i=0; i<bodies->num; i++){
|
||||
cpBody *body = (cpBody*)bodies->arr[i];
|
||||
|
||||
// Need to deal with infinite mass objects
|
||||
cpFloat keThreshold = (dvsq ? body->m*dvsq : 0.0f);
|
||||
body->node.idleTime = (cpBodyKineticEnergy(body) > keThreshold ? 0.0f : body->node.idleTime + dt);
|
||||
|
||||
cpAssertSoft(body->node.next == NULL, "Internal Error: Dangling next pointer detected in contact graph.");
|
||||
cpAssertSoft(body->node.root == NULL, "Internal Error: Dangling root pointer detected in contact graph.");
|
||||
}
|
||||
}
|
||||
|
||||
// Awaken any sleeping bodies found and then push arbiters to the bodies' lists.
|
||||
|
@ -234,13 +243,16 @@ cpSpaceProcessComponents(cpSpace *space, cpFloat dt)
|
|||
cpArbiter *arb = (cpArbiter*)arbiters->arr[i];
|
||||
cpBody *a = arb->body_a, *b = arb->body_b;
|
||||
|
||||
if(sleep){
|
||||
if((cpBodyIsRogue(b) && !cpBodyIsStatic(b)) || cpBodyIsSleeping(a)) cpBodyActivate(a);
|
||||
if((cpBodyIsRogue(a) && !cpBodyIsStatic(a)) || cpBodyIsSleeping(b)) cpBodyActivate(b);
|
||||
}
|
||||
|
||||
cpBodyPushArbiter(a, arb);
|
||||
cpBodyPushArbiter(b, arb);
|
||||
}
|
||||
|
||||
if(sleep){
|
||||
// Bodies should be held active if connected by a joint to a non-static rouge body.
|
||||
cpArray *constraints = space->constraints;
|
||||
for(int i=0; i<constraints->num; i++){
|
||||
|
@ -277,6 +289,7 @@ cpSpaceProcessComponents(cpSpace *space, cpFloat dt)
|
|||
body->node.root = NULL;
|
||||
body->node.next = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
#include "prime.h"
|
||||
|
||||
|
@ -376,16 +373,6 @@ query_helper(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr, void *obj, cpSpatialIn
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cpSpaceHashPointQuery(cpSpaceHash *hash, cpVect point, cpSpatialIndexQueryFunc func, void *data)
|
||||
{
|
||||
cpFloat dim = hash->celldim;
|
||||
cpHashValue idx = hash_func(floor_int(point.x/dim), floor_int(point.y/dim), hash->numcells); // Fix by ShiftZ
|
||||
|
||||
query_helper(hash, &hash->table[idx], &point, func, data);
|
||||
hash->stamp++;
|
||||
}
|
||||
|
||||
static void
|
||||
cpSpaceHashQuery(cpSpaceHash *hash, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data)
|
||||
{
|
||||
|
@ -597,9 +584,8 @@ static cpSpatialIndexClass klass = {
|
|||
(cpSpatialIndexReindexObjectImpl)cpSpaceHashRehashObject,
|
||||
(cpSpatialIndexReindexQueryImpl)cpSpaceHashReindexQuery,
|
||||
|
||||
(cpSpatialIndexPointQueryImpl)cpSpaceHashPointQuery,
|
||||
(cpSpatialIndexSegmentQueryImpl)cpSpaceHashSegmentQuery,
|
||||
(cpSpatialIndexQueryImpl)cpSpaceHashQuery,
|
||||
(cpSpatialIndexSegmentQueryImpl)cpSpaceHashSegmentQuery,
|
||||
};
|
||||
|
||||
static inline cpSpatialIndexClass *Klass(){return &klass;}
|
||||
|
|
|
@ -19,25 +19,24 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chipmunk_private.h"
|
||||
|
||||
//MARK: Point Query Functions
|
||||
|
||||
typedef struct pointQueryContext {
|
||||
struct PointQueryContext {
|
||||
cpVect point;
|
||||
cpLayers layers;
|
||||
cpGroup group;
|
||||
cpSpacePointQueryFunc func;
|
||||
void *data;
|
||||
} pointQueryContext;
|
||||
};
|
||||
|
||||
static void
|
||||
pointQueryHelper(cpVect *point, cpShape *shape, pointQueryContext *context)
|
||||
PointQuery(struct PointQueryContext *context, cpShape *shape, void *data)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
|
||||
cpShapePointQuery(shape, *point)
|
||||
cpShapePointQuery(shape, context->point)
|
||||
){
|
||||
context->func(shape, context->data);
|
||||
}
|
||||
|
@ -46,16 +45,17 @@ pointQueryHelper(cpVect *point, cpShape *shape, pointQueryContext *context)
|
|||
void
|
||||
cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup group, cpSpacePointQueryFunc func, void *data)
|
||||
{
|
||||
pointQueryContext context = {layers, group, func, data};
|
||||
struct PointQueryContext context = {point, layers, group, func, data};
|
||||
cpBB bb = cpBBNewForCircle(point, 0.0f);
|
||||
|
||||
cpSpaceLock(space); {
|
||||
cpSpatialIndexPointQuery(space->activeShapes, point, (cpSpatialIndexQueryFunc)pointQueryHelper, &context);
|
||||
cpSpatialIndexPointQuery(space->staticShapes, point, (cpSpatialIndexQueryFunc)pointQueryHelper, &context);
|
||||
cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)PointQuery, data);
|
||||
cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)PointQuery, data);
|
||||
} cpSpaceUnlock(space, cpTrue);
|
||||
}
|
||||
|
||||
static void
|
||||
rememberLastPointQuery(cpShape *shape, cpShape **outShape)
|
||||
PointQueryFirst(cpShape *shape, cpShape **outShape)
|
||||
{
|
||||
if(!shape->sensor) *outShape = shape;
|
||||
}
|
||||
|
@ -64,23 +64,94 @@ cpShape *
|
|||
cpSpacePointQueryFirst(cpSpace *space, cpVect point, cpLayers layers, cpGroup group)
|
||||
{
|
||||
cpShape *shape = NULL;
|
||||
cpSpacePointQuery(space, point, layers, group, (cpSpacePointQueryFunc)rememberLastPointQuery, &shape);
|
||||
cpSpacePointQuery(space, point, layers, group, (cpSpacePointQueryFunc)PointQueryFirst, &shape);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
//MARK: Nearest Point Query Functions
|
||||
|
||||
struct NearestPointQueryContext {
|
||||
cpVect point;
|
||||
cpFloat maxDistance;
|
||||
cpLayers layers;
|
||||
cpGroup group;
|
||||
cpSpaceNearestPointQueryFunc func;
|
||||
};
|
||||
|
||||
static void
|
||||
NearestPointQuery(struct NearestPointQueryContext *context, cpShape *shape, void *data)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers)
|
||||
){
|
||||
cpNearestPointQueryInfo info;
|
||||
cpShapeNearestPointQuery(shape, context->point, &info);
|
||||
|
||||
if(info.shape && info.d < context->maxDistance) context->func(shape, info.d, info.p, data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cpSpaceNearestPointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryFunc func, void *data)
|
||||
{
|
||||
struct NearestPointQueryContext context = {point, maxDistance, layers, group, func};
|
||||
cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f));
|
||||
|
||||
cpSpaceLock(space); {
|
||||
cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data);
|
||||
cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data);
|
||||
} cpSpaceUnlock(space, cpTrue);
|
||||
}
|
||||
|
||||
static void
|
||||
NearestPointQueryNearest(struct NearestPointQueryContext *context, cpShape *shape, cpNearestPointQueryInfo *out)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers) && !shape->sensor
|
||||
){
|
||||
cpNearestPointQueryInfo info;
|
||||
cpShapeNearestPointQuery(shape, context->point, &info);
|
||||
|
||||
if(info.d < out->d) (*out) = info;
|
||||
}
|
||||
}
|
||||
|
||||
cpShape *
|
||||
cpSpaceNearestPointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpNearestPointQueryInfo *out)
|
||||
{
|
||||
cpNearestPointQueryInfo info = {NULL, cpvzero, maxDistance};
|
||||
if(out){
|
||||
(*out) = info;
|
||||
} else {
|
||||
out = &info;
|
||||
}
|
||||
|
||||
struct NearestPointQueryContext context = {
|
||||
point, maxDistance,
|
||||
layers, group,
|
||||
NULL
|
||||
};
|
||||
|
||||
cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f));
|
||||
cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out);
|
||||
cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out);
|
||||
|
||||
return out->shape;
|
||||
}
|
||||
|
||||
|
||||
//MARK: Segment Query Functions
|
||||
|
||||
typedef struct segQueryContext {
|
||||
struct SegmentQueryContext {
|
||||
cpVect start, end;
|
||||
cpLayers layers;
|
||||
cpGroup group;
|
||||
cpSpaceSegmentQueryFunc func;
|
||||
} segQueryContext;
|
||||
};
|
||||
|
||||
static cpFloat
|
||||
segQueryFunc(segQueryContext *context, cpShape *shape, void *data)
|
||||
SegmentQuery(struct SegmentQueryContext *context, cpShape *shape, void *data)
|
||||
{
|
||||
cpSegmentQueryInfo info;
|
||||
|
||||
|
@ -97,26 +168,20 @@ segQueryFunc(segQueryContext *context, cpShape *shape, void *data)
|
|||
void
|
||||
cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryFunc func, void *data)
|
||||
{
|
||||
segQueryContext context = {
|
||||
struct SegmentQueryContext context = {
|
||||
start, end,
|
||||
layers, group,
|
||||
func,
|
||||
};
|
||||
|
||||
cpSpaceLock(space); {
|
||||
cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data);
|
||||
cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data);
|
||||
cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQuery, data);
|
||||
cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQuery, data);
|
||||
} cpSpaceUnlock(space, cpTrue);
|
||||
}
|
||||
|
||||
typedef struct segQueryFirstContext {
|
||||
cpVect start, end;
|
||||
cpLayers layers;
|
||||
cpGroup group;
|
||||
} segQueryFirstContext;
|
||||
|
||||
static cpFloat
|
||||
segQueryFirst(segQueryFirstContext *context, cpShape *shape, cpSegmentQueryInfo *out)
|
||||
SegmentQueryFirst(struct SegmentQueryContext *context, cpShape *shape, cpSegmentQueryInfo *out)
|
||||
{
|
||||
cpSegmentQueryInfo info;
|
||||
|
||||
|
@ -126,7 +191,7 @@ segQueryFirst(segQueryFirstContext *context, cpShape *shape, cpSegmentQueryInfo
|
|||
cpShapeSegmentQuery(shape, context->start, context->end, &info) &&
|
||||
info.t < out->t
|
||||
){
|
||||
*out = info;
|
||||
(*out) = info;
|
||||
}
|
||||
|
||||
return out->t;
|
||||
|
@ -142,59 +207,60 @@ cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpLayers laye
|
|||
out = &info;
|
||||
}
|
||||
|
||||
segQueryFirstContext context = {
|
||||
struct SegmentQueryContext context = {
|
||||
start, end,
|
||||
layers, group
|
||||
layers, group,
|
||||
NULL
|
||||
};
|
||||
|
||||
cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFirst, out);
|
||||
cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, out->t, (cpSpatialIndexSegmentQueryFunc)segQueryFirst, out);
|
||||
cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQueryFirst, out);
|
||||
cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, out->t, (cpSpatialIndexSegmentQueryFunc)SegmentQueryFirst, out);
|
||||
|
||||
return out->shape;
|
||||
}
|
||||
|
||||
//MARK: BB Query Functions
|
||||
|
||||
typedef struct bbQueryContext {
|
||||
struct BBQueryContext {
|
||||
cpBB bb;
|
||||
cpLayers layers;
|
||||
cpGroup group;
|
||||
cpSpaceBBQueryFunc func;
|
||||
void *data;
|
||||
} bbQueryContext;
|
||||
};
|
||||
|
||||
static void
|
||||
bbQueryHelper(cpBB *bb, cpShape *shape, bbQueryContext *context)
|
||||
BBQuery(struct BBQueryContext *context, cpShape *shape, void *data)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
|
||||
cpBBIntersects(*bb, shape->bb)
|
||||
cpBBIntersects(context->bb, shape->bb)
|
||||
){
|
||||
context->func(shape, context->data);
|
||||
context->func(shape, data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cpSpaceBBQuery(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryFunc func, void *data)
|
||||
{
|
||||
bbQueryContext context = {layers, group, func, data};
|
||||
struct BBQueryContext context = {bb, layers, group, func};
|
||||
|
||||
cpSpaceLock(space); {
|
||||
cpSpatialIndexQuery(space->activeShapes, &bb, bb, (cpSpatialIndexQueryFunc)bbQueryHelper, &context);
|
||||
cpSpatialIndexQuery(space->staticShapes, &bb, bb, (cpSpatialIndexQueryFunc)bbQueryHelper, &context);
|
||||
cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)BBQuery, data);
|
||||
cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)BBQuery, data);
|
||||
} cpSpaceUnlock(space, cpTrue);
|
||||
}
|
||||
|
||||
//MARK: Shape Query Functions
|
||||
|
||||
typedef struct shapeQueryContext {
|
||||
struct ShapeQueryContext {
|
||||
cpSpaceShapeQueryFunc func;
|
||||
void *data;
|
||||
cpBool anyCollision;
|
||||
} shapeQueryContext;
|
||||
};
|
||||
|
||||
// Callback from the spatial hash.
|
||||
static void
|
||||
shapeQueryHelper(cpShape *a, cpShape *b, shapeQueryContext *context)
|
||||
ShapeQuery(cpShape *a, cpShape *b, struct ShapeQueryContext *context)
|
||||
{
|
||||
// Reject any of the simple cases
|
||||
if(
|
||||
|
@ -235,11 +301,11 @@ cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, vo
|
|||
{
|
||||
cpBody *body = shape->body;
|
||||
cpBB bb = (body ? cpShapeUpdate(shape, body->p, body->rot) : shape->bb);
|
||||
shapeQueryContext context = {func, data, cpFalse};
|
||||
struct ShapeQueryContext context = {func, data, cpFalse};
|
||||
|
||||
cpSpaceLock(space); {
|
||||
cpSpatialIndexQuery(space->activeShapes, shape, bb, (cpSpatialIndexQueryFunc)shapeQueryHelper, &context);
|
||||
cpSpatialIndexQuery(space->staticShapes, shape, bb, (cpSpatialIndexQueryFunc)shapeQueryHelper, &context);
|
||||
cpSpatialIndexQuery(space->activeShapes, shape, bb, (cpSpatialIndexQueryFunc)ShapeQuery, &context);
|
||||
cpSpatialIndexQuery(space->staticShapes, shape, bb, (cpSpatialIndexQueryFunc)ShapeQuery, &context);
|
||||
} cpSpaceUnlock(space, cpTrue);
|
||||
|
||||
return context.anyCollision;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue