我目前正在使用
onTouchEvent(MotionEvent event){
}
Run Code Online (Sandbox Code Playgroud)
检测用户何时按下我的glSurfaceView是否有办法检测何时进行长按.我猜我是否在开发文档中找不到多少,那么它将是某种方法的工作.类似于注册ACTION_DOWN并查看ACTION_UP之前的时间.
你如何使用opengl-es检测android上的长按?
当我尝试使用此代码启用我的应用程序的首选项时
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.Preference.OnPreferenceClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class Preferences extends PreferenceActivity {
private RadioButton btn01;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
btn01 = (RadioButton)findViewById(R.id.RadioButton01);
Preference customPref = (Preference) findPreference("customPref");
customPref.setOnPreferenceClickListener(new OnPreferenceClickListener(){
public boolean onPreferenceClick(Preference preference) {
Toast.makeText(getBaseContext(),"The Custom Preference Has Been Clicked",Toast.LENGTH_LONG).show();
SharedPreferences customSharedPreference = getSharedPreferences("myCutomSharedPrefs", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = customSharedPreference.edit();
editor.putString("myCustomPref","The preference has been clicked");
editor.commit();
return true;
}
public …Run Code Online (Sandbox Code Playgroud) 我想利用android xml布局.我在框架布局中放置了一个glSurfaceView,以便与线性布局结合使用......
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.opengl.GLSurfaceView android:id="@+id/surfaceviewclass"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<LinearLayout android:id="@+id/gamecontrolslayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="5"
android:background="@drawable/backdrop">
//some layout stuff
</LinearLayout>
<LinearLayout>
Run Code Online (Sandbox Code Playgroud)
然后我就像这样调用我的布局
setContentView(R.layout.main);
GLSurfaceView glSurfaceView = (GLSurfaceView)findViewById(R.id.surfaceviewclass);
Run Code Online (Sandbox Code Playgroud)
在onCreate();
我怎样才能调用我的glSurfaceView以便我可以使用这样的xml布局并引用我自己的GLSurfaceView类(下面是引用我自己的GLSurfaceView类的代码)...
glSurfaceView = new MyGLSurfaceView(this);
setContentView(glSurfaceView);
Run Code Online (Sandbox Code Playgroud)
无论如何将这两者结合起来?我想这样做因为我在我的glSurfaceView类中有很多东西,比如文件加载和触摸事件.而且我只想到实现这个新布局
我正在为Android制作2D游戏,我最近一直在关注优化.
我查看了设置中的电池使用情况,发现在将我的游戏放在前台(打开屏幕)一个多小时后,我已经耗尽了11%的电量(摩托罗拉Xoom Honeycomb).
这是用户在手机/平板电脑上应该期待的东西吗?
一点信息:
我的游戏使用Opengl-es进行渲染(连续渲染)
Logic在单独的线程中运行以提高性能.
我使用了getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 认为这是必要的,因为游戏需要用户的一些思考时间.
简单的粒子
那么,游戏的电池消耗是否正常?
我可以采取哪些措施来减少电池消耗?
为了启用medailytics插件的日志记录,我需要将其输入到模拟器的终端中
adb shell
setprop log.tag.MMT DEBUG
Run Code Online (Sandbox Code Playgroud)
不幸的是,我不知道如何打开终端,开发人员资源似乎没有提到这个主题.
如果有人告诉我这个任务实际上还有150个步骤,我也不会感到惊讶,因为媒体解析文档确实非常糟糕.
我在IIS上托管了一个网站来进行一些测试.但是每当我更改网站目录中的html文件并在浏览器中引用网页(chrome)时,没有任何变化.我是否必须强制服务器更新并查看新更改,还是还有其他内容?
这是我的选择代码
public static void pick(GL11 gl){
int[] viewport = new int[4];
ByteBuffer pixel = ByteBuffer.allocateDirect(3).order(ByteOrder.nativeOrder());
mColourR = BaseObject.getColourR();
mColourG = BaseObject.getColourG();
mColourB = BaseObject.getColourB();
x = MGLSurfaceView.X();
y = MGLSurfaceView.Y();
gl.glGetIntegerv(GL11.GL_VIEWPORT,viewport,0);
gl.glReadPixels((int)x, (int)(viewport[3] - y), 1, 1, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, pixel);
Log.d(TAG, String.valueOf(gl.glGetError()));
R = pixel.get(0);
G = pixel.get(1);
B = pixel.get(2);
Log.d(TAG, "Colour:" + pixel.get(0) + " " + pixel.get(1) + " " + pixel.get(2));
if (R == mColourR && G == mColourG && B == mColourB){
match = true; …Run Code Online (Sandbox Code Playgroud) android ×6
java ×4
opengl-es ×2
annotations ×1
error-code ×1
glreadpixels ×1
html ×1
iis ×1
long-click ×1
overriding ×1
performance ×1
terminal ×1
touchscreen ×1