Merge branch 'master' into LinuxPort

This commit is contained in:
root 2011-08-23 11:49:46 +08:00
commit 11679d9723
32 changed files with 610 additions and 108 deletions

View File

@ -198,6 +198,8 @@ public class Cocos2dxActivity extends Activity{
// resume background music
resumeBackgroundMusic();
soundPlayer.resumeAllEffect();
}
@Override
@ -209,6 +211,8 @@ public class Cocos2dxActivity extends Activity{
// pause background music
pauseBackgroundMusic();
soundPlayer.pauseAllEffect();
}
protected void setPackageName(String packageName) {

View File

@ -1,6 +1,8 @@
package org.cocos2dx.lib;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import android.content.Context;
import android.media.AudioManager;
@ -22,7 +24,9 @@ public class Cocos2dxSound {
// sound id and stream id map
private HashMap<Integer,Integer> mSoundIdStreamIdMap;
// sound path and sound id map
private HashMap<String,Integer> mPathSoundIDMap;
private HashMap<String,Integer> mPathSoundIDMap;
// repeat effect's sound id and stream id map
private HashMap<Integer, Integer> mRepeatSoundIdStreamIdMap;
private static final String TAG = "Cocos2dxSound";
private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5;
@ -55,9 +59,7 @@ public class Cocos2dxSound {
this.mPathSoundIDMap.put(path, soundId);
}
}
return soundId;
}
@ -88,6 +90,11 @@ public class Cocos2dxSound {
// record sound id and stream id map
this.mSoundIdStreamIdMap.put(soundId, streamId);
// record sound id and stream id map of the effect that loops for ever
if (isLoop){
this.mRepeatSoundIdStreamIdMap.put(soundId, streamId);
}
} else {
// the effect is not prepared
soundId = preloadEffect(path);
@ -118,9 +125,21 @@ public class Cocos2dxSound {
if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){
this.mSoundPool.stop(streamId.intValue());
this.mPathSoundIDMap.remove(soundId);
this.mRepeatSoundIdStreamIdMap.remove(soundId);
}
}
public void pauseAllEffect(){
// autoPause() is available since level 8
pauseOrResumeAllEffect(true);
}
public void resumeAllEffect(){
// autoResume is available since level 8
pauseOrResumeAllEffect(false);
}
public float getEffectsVolume(){
return (this.mLeftVolume + this.mRightVolume) / 2;
}
@ -133,6 +152,7 @@ public class Cocos2dxSound {
this.mSoundPool.release();
this.mPathSoundIDMap.clear();
this.mSoundIdStreamIdMap.clear();
this.mRepeatSoundIdStreamIdMap.clear();
initData();
}
@ -151,10 +171,25 @@ public class Cocos2dxSound {
private void initData(){
this.mSoundIdStreamIdMap = new HashMap<Integer,Integer>();
this.mRepeatSoundIdStreamIdMap = 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 pauseOrResumeAllEffect(boolean isPause){
Iterator<?> iter = this.mRepeatSoundIdStreamIdMap.entrySet().iterator();
while (iter.hasNext()){
Map.Entry<Integer, Integer> entry = (Map.Entry<Integer, Integer>)iter.next();
int streamId = entry.getValue();
if (isPause) {
this.mSoundPool.pause(streamId);
} else {
this.mSoundPool.resume(streamId);
}
}
}
}

View File

@ -198,6 +198,8 @@ public class Cocos2dxActivity extends Activity{
// resume background music
resumeBackgroundMusic();
soundPlayer.resumeAllEffect();
}
@Override
@ -209,6 +211,8 @@ public class Cocos2dxActivity extends Activity{
// pause background music
pauseBackgroundMusic();
soundPlayer.pauseAllEffect();
}
protected void setPackageName(String packageName) {

View File

@ -1,6 +1,8 @@
package org.cocos2dx.lib;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import android.content.Context;
import android.media.AudioManager;
@ -22,7 +24,9 @@ public class Cocos2dxSound {
// sound id and stream id map
private HashMap<Integer,Integer> mSoundIdStreamIdMap;
// sound path and sound id map
private HashMap<String,Integer> mPathSoundIDMap;
private HashMap<String,Integer> mPathSoundIDMap;
// repeat effect's sound id and stream id map
private HashMap<Integer, Integer> mRepeatSoundIdStreamIdMap;
private static final String TAG = "Cocos2dxSound";
private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5;
@ -55,9 +59,7 @@ public class Cocos2dxSound {
this.mPathSoundIDMap.put(path, soundId);
}
}
return soundId;
}
@ -88,6 +90,11 @@ public class Cocos2dxSound {
// record sound id and stream id map
this.mSoundIdStreamIdMap.put(soundId, streamId);
// record sound id and stream id map of the effect that loops for ever
if (isLoop){
this.mRepeatSoundIdStreamIdMap.put(soundId, streamId);
}
} else {
// the effect is not prepared
soundId = preloadEffect(path);
@ -118,9 +125,21 @@ public class Cocos2dxSound {
if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){
this.mSoundPool.stop(streamId.intValue());
this.mPathSoundIDMap.remove(soundId);
this.mRepeatSoundIdStreamIdMap.remove(soundId);
}
}
public void pauseAllEffect(){
// autoPause() is available since level 8
pauseOrResumeAllEffect(true);
}
public void resumeAllEffect(){
// autoResume is available since level 8
pauseOrResumeAllEffect(false);
}
public float getEffectsVolume(){
return (this.mLeftVolume + this.mRightVolume) / 2;
}
@ -133,6 +152,7 @@ public class Cocos2dxSound {
this.mSoundPool.release();
this.mPathSoundIDMap.clear();
this.mSoundIdStreamIdMap.clear();
this.mRepeatSoundIdStreamIdMap.clear();
initData();
}
@ -151,10 +171,25 @@ public class Cocos2dxSound {
private void initData(){
this.mSoundIdStreamIdMap = new HashMap<Integer,Integer>();
this.mRepeatSoundIdStreamIdMap = 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 pauseOrResumeAllEffect(boolean isPause){
Iterator<?> iter = this.mRepeatSoundIdStreamIdMap.entrySet().iterator();
while (iter.hasNext()){
Map.Entry<Integer, Integer> entry = (Map.Entry<Integer, Integer>)iter.next();
int streamId = entry.getValue();
if (isPause) {
this.mSoundPool.pause(streamId);
} else {
this.mSoundPool.resume(streamId);
}
}
}
}

View File

@ -76,6 +76,9 @@ CCRect::CCRect(void)
CCRect::CCRect(float x, float y, float width, float height)
{
// Only support that, the width and height > 0
assert(width >= 0 && height >= 0);
origin.x = x;
origin.y = y;

View File

@ -95,6 +95,9 @@ public:
public:
ccArray* data;
private:
CCArray() : data(NULL) {};
};
}

View File

@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __COCOA_CC_MUTATLE_ARRAY_H__
#define __COCOA_CC_MUTATLE_ARRAY_H__
#ifndef __COCOA_CC_MUTABLE_ARRAY_H__
#define __COCOA_CC_MUTABLE_ARRAY_H__
#include "CCObject.h"
#include <vector>
@ -44,7 +44,8 @@ public:
public:
CCMutableArray(unsigned int uSize = 0)
{
m_array.resize(uSize);
if (uSize != 0)
m_array.reserve(uSize);
}
virtual ~CCMutableArray(void)
@ -52,25 +53,9 @@ public:
removeAllObjects();
}
unsigned int count(void)
inline unsigned int count(void)
{
unsigned int uCount = 0;
if (!m_array.empty())
{
CCMutableArrayIterator it;
for (it = m_array.begin(); it != m_array.end(); ++it)
{
if (*it == NULL)
{
break;
}
++uCount;
}
}
return uCount;
return (unsigned int)m_array.size();
}
unsigned int getIndexOfObject(T pObject)
@ -82,7 +67,7 @@ public:
CCMutableArrayIterator iter;
unsigned int uRet = 0;
int i;
unsigned int i;
for (iter = m_array.begin(), i = 0; iter != m_array.end(); ++iter, ++i)
{
if (*iter == pObject)
@ -118,15 +103,12 @@ public:
T getLastObject(void)
{
T pObject = NULL;
int count = this->count();
CCMutableArrayRevIterator iter = rbegin();
if (count > 0)
{
pObject = m_array[count - 1];
}
if (iter != m_array.rend())
return *iter;
return pObject;
return NULL;
}
T getObjectAtIndex(unsigned int uIndex)
@ -153,28 +135,6 @@ public:
// add the refrence
pObject->retain();
// if the vector is empty, push back
if (m_array.empty())
{
m_array.push_back(pObject);
return;
}
// find a position to store
int count = 0;;
CCMutableArrayIterator it;
for (it = m_array.begin(); it != m_array.end(); ++it)
{
if (*it == NULL)
{
m_array[count] = pObject;
return;
}
++count;
}
// the array is full, push back
m_array.push_back(pObject);
}
@ -182,47 +142,48 @@ public:
{
if (pArray && pArray->count() > 0)
{
m_array.reserve(count() + pArray->count());
CCMutableArrayIterator iter;
for (iter = pArray->begin(); iter != pArray->end(); ++iter)
{
if (*iter)
{
(*iter)->retain();
m_array.push_back(*iter);
}
m_array.push_back(*iter);
}
}
}
void insertObjectAtIndex(T pObject, unsigned int uIndex)
{
assert(uIndex <= count());
// make sure the object is not null
if (pObject == NULL)
{
return;
}
// add the refrence of the object
// add the reference of the object
pObject->retain();
// resize the capacity if the index out of it
if (uIndex >= m_array.capacity())
{
m_array.resize(uIndex + 4);
m_array.reserve(uIndex + 1);
m_array.push_back(pObject);
}
// insert the object
m_array.insert(m_array.begin() + uIndex, pObject);
else // insert the object
m_array.insert(m_array.begin() + uIndex, pObject);
}
// Removing objects
void removeLastObject(bool bDeleteObject = true)
{
int count = this->count();
if (count > 0)
CCMutableArrayRevIterator it = m_array.rbegin();
if (it != m_array.rend())
{
removeObjectAtIndex(count - 1, bDeleteObject);
if (bDeleteObject)
(*it)->release();
m_array.pop_back();
}
}
@ -288,12 +249,7 @@ public:
{
CCMutableArrayIterator iter;
for (iter = m_array.begin(); iter != m_array.end(); ++iter)
{
if (*iter)
{
(*iter)->release();
}
}
(*iter)->release();
}
m_array.clear();
@ -301,7 +257,7 @@ public:
void replaceObjectAtIndex(unsigned int uIndex, T pObject, bool bDeleteObject = true)
{
if (m_array[uIndex] && bDeleteObject)
if (bDeleteObject && m_array[uIndex])
{
m_array[uIndex]->release();
}
@ -315,47 +271,31 @@ public:
}
}
CCMutableArrayIterator begin(void)
inline CCMutableArrayIterator begin(void)
{
return m_array.begin();
}
CCMutableArrayRevIterator rbegin(void)
inline CCMutableArrayRevIterator rbegin(void)
{
return m_array.rbegin();
}
CCMutableArrayIterator getLastValidIterator(void)
{
CCMutableArrayIterator iter;
CCMutableArrayIterator ret;
for (iter = m_array.begin(); iter != m_array.end(); ++iter)
{
ret = iter;
if (! (*iter))
{
break;
}
}
return ret;
}
/*
* end is a keyword of lua, so should use other name
* to export to lua
*/
CCMutableArrayIterator endToLua(void)
inline CCMutableArrayIterator endToLua(void)
{
return m_array.end();
}
CCMutableArrayIterator end(void)
inline CCMutableArrayIterator end(void)
{
return m_array.end();
}
CCMutableArrayRevIterator rend(void)
inline CCMutableArrayRevIterator rend(void)
{
return m_array.rend();
}
@ -426,4 +366,4 @@ private:
}//namespace cocos2d
#endif // __COCOA_CC_MUTATLE_ARRAY_H__
#endif // __COCOA_CC_MUTABLE_ARRAY_H__

View File

@ -264,7 +264,7 @@ CCTouchHandler* CCTouchDispatcher::findHandler(CCTouchDelegate *pDelegate)
void CCTouchDispatcher::rearrangeHandlers(CCMutableArray<CCTouchHandler*> *pArray)
{
std::sort(pArray->begin(), pArray->getLastValidIterator(), less);
std::sort(pArray->begin(), pArray->end(), less);
}
void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate)

View File

@ -0,0 +1,79 @@
FontLabel
---------
Copyright © 2009 Zynga Game Networks.
License
-------
Apache License, Version 2.0
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
2. You must cause any modified files to carry prominent notices stating that You changed the files; and
3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@ -0,0 +1,23 @@
cocos2d for iPhone: http://www.cocos2d-iphone.org
Copyright (c) 2011 - Zynga Inc. and contributors
(see each file to see the different copyright owners)
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.

View File

@ -1,6 +1,7 @@
cocos2d-x http://www.cocos2d-x.org
Copyright (c) 2008-2010 - (see each file to see the different copyright owners)
Copyright (c) 2010-2011 - cocos2d-x community
(see each file to see the different copyright owners)
Permission is hereby granted, free of charge, to any person obtaining a copy

View File

@ -0,0 +1,21 @@
CocosDenshion Sound Engine
Copyright (c) 2010 Steve Oldmeadow
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.

21
licenses/LICENSE_curl.txt Normal file
View File

@ -0,0 +1,21 @@
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1996 - 2011, Daniel Stenberg, <daniel@haxx.se>.
All rights reserved.
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies.
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 OF THIRD PARTY RIGHTS. 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.
Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.

View File

@ -0,0 +1,16 @@
Copyright (C) 1999-2003 Free Software Foundation, Inc.
The GNU LIBICONV Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
The GNU LIBICONV Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU LIBICONV Library; see the file COPYING.LIB.
If not, write to the Free Software Foundation, Inc., 59 Temple Place -
Suite 330, Boston, MA 02111-1307, USA.

View File

@ -0,0 +1,48 @@
LEGAL ISSUES
============
In plain English:
1. We don't promise that this software works. (But if you find any bugs,
please let us know!)
2. You can use this software for whatever you want. You don't have to pay us.
3. You may not pretend that you wrote this software. If you use it in a
program, you must acknowledge somewhere in your documentation that
you've used the IJG code.
In legalese:
The authors make NO WARRANTY or representation, either express or implied,
with respect to this software, its quality, accuracy, merchantability, or
fitness for a particular purpose. This software is provided "AS IS", and you,
its user, assume the entire risk as to its quality and accuracy.
This software is copyright (C) 1991-2011, Thomas G. Lane, Guido Vollbeding.
All Rights Reserved except as specified below.
Permission is hereby granted to use, copy, modify, and distribute this
software (or portions thereof) for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code for this software is distributed, then this
README file must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original files
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must state that "this software is based in part on the work of
the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.
These conditions apply to any software derived from or based on the IJG code,
not just to the unmodified library. If you use our work, you ought to
acknowledge us.
Permission is NOT granted for the use of any IJG author's name or company name
in advertising or publicity relating to this software or products derived from
it. This software may be referred to only as "the Independent JPEG Group's
software".
We specifically permit and encourage the use of this software as the basis of
commercial products, provided that all warranty or liability claims are
assumed by the product vendor.

110
licenses/LICENSE_libpng.txt Normal file
View File

@ -0,0 +1,110 @@
This copy of the libpng notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.2.38, July 16, 2009, are
Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
Simon-Pierre Cadieux
Eric S. Raymond
Gilles Vollant
and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
John Bowler
Kevin Bracey
Sam Bushell
Magnus Holmgren
Greg Roelofs
Tom Tanner
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
Andreas Dilger
Dave Martindale
Guy Eric Schalnat
Paul Schmidt
Tim Wegner
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
printf("%s",png_get_copyright(NULL));
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
July 16, 2009

View File

@ -0,0 +1,27 @@
Except where otherwise noted in the source code (e.g. the files hash.c,
list.c and the trio files, which are covered by a similar licence but
with different Copyright notices) all the files are:
Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved.
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 fur-
nished 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, FIT-
NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Daniel Veillard shall not
be used in advertising or otherwise to promote the sale, use or other deal-
ings in this Software without prior written authorization from him.

20
licenses/LICENSE_zlib.txt Normal file
View File

@ -0,0 +1,20 @@
Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly
Mark Adler

View File

@ -47,6 +47,7 @@ LOCAL_SRC_FILES := main.cpp \
../../../tests/CocosDenshionTest/CocosDenshionTest.cpp \
../../../tests/CocosNodeTest/CocosNodeTest.cpp \
../../../tests/CurlTest/CurlTest.cpp \
../../../tests/CurrentLanguageTest/CurrentLanguageTest.cpp \
../../../tests/DirectorTest/DirectorTest.cpp \
../../../tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp \
../../../tests/EaseActionsTest/EaseActionsTest.cpp \

View File

@ -198,6 +198,8 @@ public class Cocos2dxActivity extends Activity{
// resume background music
resumeBackgroundMusic();
soundPlayer.resumeAllEffect();
}
@Override
@ -209,6 +211,8 @@ public class Cocos2dxActivity extends Activity{
// pause background music
pauseBackgroundMusic();
soundPlayer.pauseAllEffect();
}
protected void setPackageName(String packageName) {

View File

@ -1,6 +1,8 @@
package org.cocos2dx.lib;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import android.content.Context;
import android.media.AudioManager;
@ -22,7 +24,9 @@ public class Cocos2dxSound {
// sound id and stream id map
private HashMap<Integer,Integer> mSoundIdStreamIdMap;
// sound path and sound id map
private HashMap<String,Integer> mPathSoundIDMap;
private HashMap<String,Integer> mPathSoundIDMap;
// repeat effect's sound id and stream id map
private HashMap<Integer, Integer> mRepeatSoundIdStreamIdMap;
private static final String TAG = "Cocos2dxSound";
private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5;
@ -55,9 +59,7 @@ public class Cocos2dxSound {
this.mPathSoundIDMap.put(path, soundId);
}
}
return soundId;
}
@ -88,6 +90,11 @@ public class Cocos2dxSound {
// record sound id and stream id map
this.mSoundIdStreamIdMap.put(soundId, streamId);
// record sound id and stream id map of the effect that loops for ever
if (isLoop){
this.mRepeatSoundIdStreamIdMap.put(soundId, streamId);
}
} else {
// the effect is not prepared
soundId = preloadEffect(path);
@ -118,9 +125,21 @@ public class Cocos2dxSound {
if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){
this.mSoundPool.stop(streamId.intValue());
this.mPathSoundIDMap.remove(soundId);
this.mRepeatSoundIdStreamIdMap.remove(soundId);
}
}
public void pauseAllEffect(){
// autoPause() is available since level 8
pauseOrResumeAllEffect(true);
}
public void resumeAllEffect(){
// autoResume is available since level 8
pauseOrResumeAllEffect(false);
}
public float getEffectsVolume(){
return (this.mLeftVolume + this.mRightVolume) / 2;
}
@ -133,6 +152,7 @@ public class Cocos2dxSound {
this.mSoundPool.release();
this.mPathSoundIDMap.clear();
this.mSoundIdStreamIdMap.clear();
this.mRepeatSoundIdStreamIdMap.clear();
initData();
}
@ -151,10 +171,25 @@ public class Cocos2dxSound {
private void initData(){
this.mSoundIdStreamIdMap = new HashMap<Integer,Integer>();
this.mRepeatSoundIdStreamIdMap = 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 pauseOrResumeAllEffect(boolean isPause){
Iterator<?> iter = this.mRepeatSoundIdStreamIdMap.entrySet().iterator();
while (iter.hasNext()){
Map.Entry<Integer, Integer> entry = (Map.Entry<Integer, Integer>)iter.next();
int streamId = entry.getValue();
if (isPause) {
this.mSoundPool.pause(streamId);
} else {
this.mSoundPool.resume(streamId);
}
}
}
}

View File

@ -1 +1 @@
fa974c372696579504a900225f2af800777e7b5f
7f6876c61c14e898650f3d05e393ca501a0f86f0

View File

@ -1095,6 +1095,18 @@
>
</File>
</Filter>
<Filter
Name="CurrentLanguageTest"
>
<File
RelativePath="..\tests\CurrentLanguageTest\CurrentLanguageTest.cpp"
>
</File>
<File
RelativePath="..\tests\CurrentLanguageTest\CurrentLanguageTest.h"
>
</File>
</Filter>
</Filter>
</Filter>
</Files>

View File

@ -0,0 +1,34 @@
#include "CurrentLanguageTest.h"
CurrentLanguageTest::CurrentLanguageTest()
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLabelTTF* label = CCLabelTTF::labelWithString("Current language Test", "Arial", 28);
addChild(label, 0);
label->setPosition( ccp(s.width/2, s.height-50) );
CCLabelTTF *labelLanguage = CCLabelTTF::labelWithString("", "Arial", 20);
labelLanguage->setPosition(ccp(s.width/2, s.height/2));
ccLanguageType currentLanguageType = CCApplication::sharedApplication().getCurrentLanguage();
switch (currentLanguageType)
{
case kLanguageEnglish:
labelLanguage->setString("current language is English");
break;
case kLanguageChinese:
labelLanguage->setString("current language is Chinese");
break;
}
addChild(labelLanguage);
}
void CurrentLanguageTestScene::runThisTest()
{
CCLayer* pLayer = new CurrentLanguageTest();
addChild(pLayer);
CCDirector::sharedDirector()->replaceScene(this);
pLayer->release();
}

View File

@ -0,0 +1,19 @@
#ifndef _CURRENT_LANGUAGE_TEST_H_
#define _CURRENT_LANGUAGE_TEST_H_
#include "cocos2d.h"
#include "../testBasic.h"
class CurrentLanguageTest : public CCLayer
{
public:
CurrentLanguageTest();
};
class CurrentLanguageTestScene : public TestScene
{
public:
virtual void runThisTest();
};
#endif // _CURRENT_LANGUAGE_TEST_H_

View File

@ -109,7 +109,11 @@ static TestScene* CreateTestScene(int nIdx)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)
case TEST_FONTS:
pScene = new FontTestScene(); break;
case TEST_CURRENT_LANGUAGE:
pScene = new CurrentLanguageTestScene(); break;
break;
#endif
default:
break;
}

View File

@ -43,6 +43,7 @@
#include "BugsTest/BugsTest.h"
#include "Texture2dTest/Texture2dTest.h"
#include "FontTest/FontTest.h"
#include "CurrentLanguageTest/CurrentLanguageTest.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_AIRPLAY)
// #include "ChipmunkTest/cocos2dChipmunkDemo.h"
@ -96,6 +97,7 @@ enum
TEST_DIRECTOR,
TEST_BUGS,
TEST_FONTS,
TEST_CURRENT_LANGUAGE,
TESTS_COUNT,
};
@ -140,7 +142,8 @@ const std::string g_aTestNames[TESTS_COUNT] = {
"UserDefaultTest",
"DirectorTest",
"BugsTest",
"FontTest"
"FontTest",
"CurrentLanguageTest",
};
#endif