我在游戏中使用cocos denshion来播放音乐.我正在播放带有代码的背景音乐:
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"backSong.mp3"];
然而,当游戏结束时,我需要背景音乐逐渐淡出.如何淡出背景音乐,有没有办法做到这一点?提前致谢!另外,ObjectAL是否比CocosDenshion更好?如果是这样,有什么区别/优势?
我有一个等待摇动的前台服务.当它收到该动作时,会发出一个广播:
Intent i = new Intent("com.company.app.shakeDetectedMessage");
sendBroadcast(i);
Run Code Online (Sandbox Code Playgroud)
我的主要活动是通过广播接收器实现这个方法:
@Override
public void onReceive(Context context, Intent intent)
{
MainActivity.this.turnOnScreen();
Toast.makeText(getApplicationContext(), "Screen ON", Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
我开启了屏幕方法:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Run Code Online (Sandbox Code Playgroud)
我有一个部分唤醒锁定
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
PowerManager.WakeLock mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SensorRead");
mWakeLock.acquire();
Run Code Online (Sandbox Code Playgroud)
在服务中声明
然而,当我关闭屏幕并摇动时,屏幕无法开启!我验证了每种方法都在使用日志.即使屏幕关闭,onReceive也能正常工作.广播正在发挥作用.只是屏幕无法开启!
在使用Android Studio的AndEngine创建游戏时,我将我的资源文件夹放在项目的根级别.我还在它下面创建了一个名为gfx的文件夹,并将我的splash.png放在那里.
当我调用启动画面时:
public void loadSplashScreen()
{
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
splashTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 390, 534, TextureOptions.BILINEAR);
splash_region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashTextureAtlas, activity, "splash.png", 0, 0);
splashTextureAtlas.load();
}
Run Code Online (Sandbox Code Playgroud)
这是产生的错误
我把东西放在错误的地方吗?资产应该在哪里?
E/AndEngine? Failed loading Bitmap in AssetBitmapTextureAtlasSource. AssetPath: gfx/splash.png
java.io.FileNotFoundException: gfx/splash.png
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:316)
at android.content.res.AssetManager.open(AssetManager.java:290)
at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.create(AssetBitmapTextureAtlasSource.java:52)
at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.create(AssetBitmapTextureAtlasSource.java:43)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:86)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:82)
at com.waylonhuang.game.ResourcesManager.loadSplashScreen(ResourcesManager.java:68)
at com.waylonhuang.game.SceneManager.createSplashScene(SceneManager.java:93)
at com.waylonhuang.game.GameActivity.onCreateScene(GameActivity.java:62)
at org.andengine.ui.activity.BaseGameActivity$3.onCreateResourcesFinished(BaseGameActivity.java:171)
at com.waylonhuang.game.GameActivity.onCreateResources(GameActivity.java:45)
at org.andengine.ui.activity.BaseGameActivity.onCreateGame(BaseGameActivity.java:183)
at org.andengine.ui.activity.BaseGameActivity.onSurfaceCreated(BaseGameActivity.java:112)
at org.andengine.opengl.view.EngineRenderer.onSurfaceCreated(EngineRenderer.java:80)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
01-17 16:48:21.329 30718-30749/com.waylonhuang.game E/AndEngine? Failed loading Bitmap in AssetBitmapTextureAtlasSource. …Run Code Online (Sandbox Code Playgroud) 如何在设置超时值时获取进程的输出?
我目前正在使用 apache commons io utils 从进程的标准和错误输出创建一个字符串。
下面的代码按原样(带有注释)适用于终止的进程。但是,如果进程没有终止,主线程也不会终止!
如果我取消注释掉已注释的代码,而是注释掉 process.waitfor(),该方法将正确销毁非终止进程。但是,对于终止进程,无法正确获得输出。似乎一旦 waitfor() 完成,我就无法获得进程的输入和错误流?
最后,如果我尝试将注释部分移动到 process.waitfor() 当前所在的位置,删除 process.waitfor() 并取消注释注释部分,那么对于非终止进程,主线程也不会停止。这是因为 process.waitfor(15, ...) 永远不会到达。
private static Outputs runProcess(String command) throws Exception {
Process process = Runtime.getRuntime().exec(command);
// if (!process.waitFor(15, TimeUnit.SECONDS)) {
// System.out.println("Destroy");
// process.destroy();
// }
// Run and collect the results from the standard output and error output
String stdStr = IOUtils.toString(process.getInputStream());
String errStr = IOUtils.toString(process.getErrorStream());
process.waitFor();
return new Outputs(stdStr, errStr);
}
Run Code Online (Sandbox Code Playgroud) 如何将日语激进角色转换为"常规"汉字角色?
例如,激进之火的角色是⽕(Unicode值为12117)
常规字符是火(Unicode值为28779)
编辑:
为了澄清,我认为我需要这个的原因是因为我想通过使用kanjivg数据集获得每个部首的笔划信息.但是,(我需要进一步研究),我不确定kanjivg是否有激进角色的笔画数据,但它肯定有常规汉字字符的笔画数据.
我正在使用的语言是Java - 但我认为任何语言的转换都是类似的.
我有一个说"完整"的UIButton.我的UIButton驻留在UIView中,我将其插入到tableview中.但是,当用户点击按钮时,我还想更新UIButton的标签以说"不完整".按钮标签不会更新!如何设置按钮的标签?谢谢!
鉴于我有一个存储在局部变量中的UIImage:
UIImage *myImage = (Some image extracted somewhere)
Run Code Online (Sandbox Code Playgroud)
如何通过MFMailComposeViewController将此图像添加为附件?
图像不存储在用户设备上,只是在运行时可用.
所以我无法通过文件名访问此图像,正如其他问题/示例所示.
谢谢!
假设我有一个名为BugException的类,该类从扩展而来,RuntimeException
并且BugException具有一个采用Throwable的副本构造函数。
这段代码编译和类型检查:
Throwable e = ...;
if (e instanceof BugException) {
throw new BugException(e);
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样:
Throwable e = ...;
if (e instanceof BugException) {
throw e;
}
Run Code Online (Sandbox Code Playgroud)
不编译并给出错误消息:未处理的异常。java.lang.Throwable。?
为什么需要这种不必要的包装来满足类型检查器?
Type从呼叫返回哪种类型的游戏对象
GetComponent<Type>();
Run Code Online (Sandbox Code Playgroud)
如果调用游戏对象附加了多个该类型的对象?
此函数的文档仅说明如果游戏对象存在则返回游标对象,否则返回null.
我有一个带有多个Collider2Ds 的游戏对象,想要知道哪一个会被返回,以及它是否一致.
我有一个NSArray,.count我存储在一个名为的整数中arrayCount
我需要从0生成一个随机数,arrayCount但是当我使用arc4random()时,它会生成一个非常大的整数.
我一直这样做: int randomInt = arc4random()*arrayCount;
哪个给了我随机数,如12309120等.