mirror of https://github.com/axmolengine/axmol.git
setKeepScreenOn method
This commit is contained in:
parent
18cc62d16d
commit
bfe6513706
|
@ -66,6 +66,8 @@ public:
|
||||||
|
|
||||||
static Data getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha);
|
static Data getTextureDataForText(const char * text, const FontDefinition& textDefinition, TextAlign align, int &width, int &height, bool& hasPremultipliedAlpha);
|
||||||
|
|
||||||
|
static void setKeepScreenOn(bool value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CC_DISALLOW_IMPLICIT_CONSTRUCTORS(Device);
|
CC_DISALLOW_IMPLICIT_CONSTRUCTORS(Device);
|
||||||
};
|
};
|
||||||
|
|
|
@ -202,6 +202,12 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Device::setKeepScreenOn(bool value)
|
||||||
|
{
|
||||||
|
setKeepScreenOnJni(value);
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||||
|
|
|
@ -34,6 +34,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.preference.PreferenceManager.OnActivityResultListener;
|
import android.preference.PreferenceManager.OnActivityResultListener;
|
||||||
|
@ -58,6 +59,16 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
return sContext;
|
return sContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setKeepScreenOn(boolean value) {
|
||||||
|
final boolean newValue = value;
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mGLSurfaceView.setKeepScreenOn(newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected void onLoadNativeLibraries() {
|
protected void onLoadNativeLibraries() {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
|
ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
|
||||||
|
|
|
@ -168,6 +168,10 @@ public class Cocos2dxHelper {
|
||||||
Cocos2dxHelper.sCocos2dxAccelerometer.disable();
|
Cocos2dxHelper.sCocos2dxAccelerometer.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setKeepScreenOn(boolean value) {
|
||||||
|
((Cocos2dxActivity)sActivity).setKeepScreenOn(value);
|
||||||
|
}
|
||||||
|
|
||||||
public static void preloadBackgroundMusic(final String pPath) {
|
public static void preloadBackgroundMusic(final String pPath) {
|
||||||
Cocos2dxHelper.sCocos2dMusic.preloadBackgroundMusic(pPath);
|
Cocos2dxHelper.sCocos2dMusic.preloadBackgroundMusic(pPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,16 @@ void disableAccelerometerJni() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setKeepScreenOnJni(bool value) {
|
||||||
|
JniMethodInfo t;
|
||||||
|
|
||||||
|
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setKeepScreenOn", "(Z)V")) {
|
||||||
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, value);
|
||||||
|
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// functions for UserDefault
|
// functions for UserDefault
|
||||||
bool getBoolForKeyJNI(const char* key, bool defaultValue)
|
bool getBoolForKeyJNI(const char* key, bool defaultValue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern std::string getFileDirectoryJNI();
|
||||||
extern void enableAccelerometerJni();
|
extern void enableAccelerometerJni();
|
||||||
extern void disableAccelerometerJni();
|
extern void disableAccelerometerJni();
|
||||||
extern void setAccelerometerIntervalJni(float interval);
|
extern void setAccelerometerIntervalJni(float interval);
|
||||||
|
extern void setKeepScreenOnJni(bool value);
|
||||||
// functions for UserDefault
|
// functions for UserDefault
|
||||||
extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
|
extern bool getBoolForKeyJNI(const char* key, bool defaultValue);
|
||||||
extern int getIntegerForKeyJNI(const char* key, int defaultValue);
|
extern int getIntegerForKeyJNI(const char* key, int defaultValue);
|
||||||
|
|
|
@ -477,6 +477,11 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::setKeepScreenOn(bool value)
|
||||||
|
{
|
||||||
|
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // CC_PLATFORM_IOS
|
#endif // CC_PLATFORM_IOS
|
||||||
|
|
|
@ -499,6 +499,10 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::setKeepScreenOn(bool value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
|
||||||
|
|
|
@ -247,6 +247,11 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::setKeepScreenOn(bool value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC
|
||||||
|
|
|
@ -451,6 +451,10 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::setKeepScreenOn(bool value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||||
|
|
|
@ -163,6 +163,10 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::setKeepScreenOn(bool value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
|
|
Loading…
Reference in New Issue