mirror of https://github.com/axmolengine/axmol.git
Merge pull request #509 from minggo/iss719
fixed #719: update java code to HelloLua & tests
This commit is contained in:
commit
55ab2aa708
|
@ -24,8 +24,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
package org.cocos2dx.lib;
|
package org.cocos2dx.lib;
|
||||||
|
|
||||||
|
import org.cocos2dx.application.R;
|
||||||
import org.cocos2dx.hellolua.R;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
@ -105,6 +104,10 @@ public class Cocos2dxActivity extends Activity{
|
||||||
accelerometer.disable();
|
accelerometer.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void preloadBackgroundMusic(String path){
|
||||||
|
backgroundMusicPlayer.preloadBackgroundMusic(path);
|
||||||
|
}
|
||||||
|
|
||||||
public static void playBackgroundMusic(String path, boolean isLoop){
|
public static void playBackgroundMusic(String path, boolean isLoop){
|
||||||
backgroundMusicPlayer.playBackgroundMusic(path, isLoop);
|
backgroundMusicPlayer.playBackgroundMusic(path, isLoop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,22 @@ public class Cocos2dxMusic {
|
||||||
initData();
|
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){
|
public void playBackgroundMusic(String path, boolean isLoop){
|
||||||
if (mCurrentPath == null){
|
if (mCurrentPath == null){
|
||||||
// it is the first time to play background music
|
// it is the first time to play background music
|
||||||
|
@ -159,8 +175,8 @@ public class Cocos2dxMusic {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBackgroundVolume(float volume){
|
public void setBackgroundVolume(float volume){
|
||||||
|
this.mLeftVolume = this.mRightVolume = volume;
|
||||||
if (this.mBackgroundMediaPlayer != null){
|
if (this.mBackgroundMediaPlayer != null){
|
||||||
this.mLeftVolume = this.mRightVolume = volume;
|
|
||||||
this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume);
|
this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,10 @@ public class Cocos2dxActivity extends Activity{
|
||||||
accelerometer.disable();
|
accelerometer.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void preloadBackgroundMusic(String path){
|
||||||
|
backgroundMusicPlayer.preloadBackgroundMusic(path);
|
||||||
|
}
|
||||||
|
|
||||||
public static void playBackgroundMusic(String path, boolean isLoop){
|
public static void playBackgroundMusic(String path, boolean isLoop){
|
||||||
backgroundMusicPlayer.playBackgroundMusic(path, isLoop);
|
backgroundMusicPlayer.playBackgroundMusic(path, isLoop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,22 @@ public class Cocos2dxMusic {
|
||||||
initData();
|
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){
|
public void playBackgroundMusic(String path, boolean isLoop){
|
||||||
if (mCurrentPath == null){
|
if (mCurrentPath == null){
|
||||||
// it is the first time to play background music
|
// it is the first time to play background music
|
||||||
|
|
Loading…
Reference in New Issue