【cocos2d-x】指定秒ごとに処理を実行
//1秒ごとに処理を実行
void CocosTest::update(float time){
if(isInterval){
intervalTime += time;
if(intervalTime > 1.0f){//一秒よりインターバルがおおきくなったなら
isInterval = false;
intervalTime = 0.0f;
}
}
}
【cocos2d-x】【Android】Android5.0(Lolipop)においてcocos2d-xが動かないときにすること
最初からAndroid5.0(Lolipop)な端末だと、ビルトインメディアプレーヤーがAwsomePlayerではなく、NuPlayerというのが選択されているっぽい、、
で、Music鳴らすときに悪さしている…StartとResetを繰り返してしまう…
今回修正する箇所はCocos2dxMusic.javaで
if (this.mBackgroundMediaPlayer == null) {
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null");
} else {
// if the music is playing or paused, stop it
if (this.mBackgroundMediaPlayer.isPlaying()) {
this.mBackgroundMediaPlayer.pause();
}
this.mBackgroundMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.seekTo(0);
mp.start();
}});
this.mBackgroundMediaPlayer.setLooping(isLoop);
try {
this.mBackgroundMediaPlayer.prepare();
//this.mBackgroundMediaPlayer.seekTo(0);
//this.mBackgroundMediaPlayer.start();
this.mPaused = false;
} catch (final Exception e) {
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state");
}
}private MediaPlayer createMediaplayerFromAssets(final String pPath) {
MediaPlayer mediaPlayer = new MediaPlayer();
try {
if (pPath.startsWith("/")) {
mediaPlayer.setDataSource(pPath);
} else {
final AssetFileDescriptor assetFileDescritor = this.mContext.getAssets().openFd(pPath);
mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), assetFileDescritor.getStartOffset(), assetFileDescritor.getLength());
}
// mediaPlayer.prepare();
mediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume);
} catch (final Exception e) {
mediaPlayer = null;
Log.e(Cocos2dxMusic.TAG, "error: " + e.getMessage(), e);
}
return mediaPlayer;
}こんな感じにすれば動くはず
【cocos2d-x】【Android】setDimensionsで改行する際に1文字抜けてしまうときにすること
Cocos2dxBitmap.java内の300行目くらいにある
while (pString.indexOf(i++) == ' ') {
;
}
↑こんな感じになっているところを↓のように変える
while (pString.indexOf(i) == ' ') {
++i;
}これでなおる…はず。
【Unity】Unity上でUUIDを作る
System.Guid guid = System.Guid.NewGuid ();
uuid = uuid.ToString ();
Debug.Log ("uuid = " + uuid);
*GUIDはUUIDの実装の一つ
【Unity】"count <= std::numeric_limits<UInt16>::max()とか出たら…
作成中のアプリで、GETで取ってきたJSONをローカルに保存し、それを読み込む処理のところでこんなエラーが出て読み込み途中で進まなくなってしまった…
"count <= std::numeric_limits<UInt16>::max()
maxVertices < 65536 && maxIndices < 65536*3
停止しても吐き出され続けるので結構焦っていたのだが、、
まず、ググって出てきた方法はUnityエディタ上でGameSceneをCloseTabして、再度表示させるということだった。使ってるUnityのバージョンはこの記事を書いている現時点で一番新しい物なので、まあそんなことやっても治らないだろうと思ってやってみた。。
やっぱり治らない。
次に、このエラーが出ている直近のソースをきれいにした。特にデバッグログを入念にコメントアウトした。そしたら動いた!!
Debug.Log();がくせ者で、ローカルにあるJsonファイルを読み込んでログに出していたのだが、データ量が多すぎてダメだったぽい。。ログ出すときは気をつけよ。。
確か、Debug.Log();の限界文字数は15000文字までっぽい(確証なし
【Unity】【NGUI】ボタンをクリックする度に選択・非選択を切り替えて色を変える
//NGUIで作成したボタンに付けたスクリプトに書いてるイメージ(適当
//UIButtonのOnClickに自身のオブジェクトぶっこむ
//NGUIのColliderをアタッチすることを忘れない
public void SetSelect(){
isSelectLock = !isSelectLock;
Debug.Log ("isSelectLock = " + isSelectLock);
if (isSelectLock) {
//黒くする
this.GetComponent<UIButton> ().defaultColor = new Color (0.5f, 0.5f, 0.5f);
} else {
//元に色に戻す
this.GetComponent<UIButton> ().defaultColor = new Color (1.0f, 1.0f, 1.0f);
}
}