我正在制作一个多个玩家应该能够一次玩的游戏.这是一个2D游戏,所有角色应该能够看到对方在屏幕上移动.就像游戏一样,现在所有的设备都只是发布并将其他人提取coordinates到服务器.这是通过运行到线程来完成的:
public void StartCoordinatorFetcherThread(final Sprite Object)
{
Thread CoordinateStarter = new Thread()
{
public void run()
{
while(true)
{
Object.testing = Object.InternetObject.GetMessages();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
CoordinateStarter.start();
}
public void StartCoordinatorPosterThread(final Sprite Object)
{
Thread CoordinatePoster = new Thread()
{
public void run()
{
while(true)
{
Object.InternetObject.PostCoordinates(Object.x,Object.y);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
CoordinatePoster.start();
}
Run Code Online (Sandbox Code Playgroud)
无论如何,我希望角色能够更顺利地移动,因为它可以"laggy"像这样做.有人知道如何实现这个目标吗?
也许我应该有一种坐标堆栈,它只是一直推动坐标,然后在游戏运行时弹出值?
任何帮助将受到高度赞赏. …
我正在构建 Android 应用程序,但我厌倦了每次设计应用程序时甚至更改字体大小时我都必须等待重新安装有什么方法可以加快这种设计方式吗?另外,如果我每次都必须调试时更改代码,是否有任何方法可以加快此任务的速度?
我的主要问题是,如果我导航到 10 个活动,而更改在 11 个活动中,那么每次我很忙时我都必须重新导航。我无法直接进入第 11 个活动,因为我需要上一个活动的一些值以及另外一件事
something like on-web page we do just refresh that particular page and see changes
Run Code Online (Sandbox Code Playgroud)
##注意:这个问题会对您解决这个问题有很大帮助,请参阅此处
我已经构建了一个应用程序,现在我想使用我的新备份应用程序复制正在运行的应用程序的数据库.我通过DB_PATH + DB_NAME使用以下值创建数据库路径:
DB_PATH = "/data/data/iCam.Cam/";
DB_NAME = "testdb.db";
Run Code Online (Sandbox Code Playgroud)
我有代码将数据库从给定路径复制到SD卡.但是,当我最初使用以下方法检查数据库时,它返回false:
public boolean checkDataBase() {
SQLiteDatabase checkDB = null;
try {
String myPath = DB_PATH + DB_NAME;
checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
} catch (SQLiteException e) {
e.fillInStackTrace();
// database does't exist yet.
}
if (checkDB != null) {
checkDB.close();
}
return checkDB != null ? true : false;
}
Run Code Online (Sandbox Code Playgroud)
有关如何实现这一目标的任何建议?
我对包含文件及其管理方式有以下好奇心GCC:
假设我有一个源文件foo.c和三个头文件foo.h,foo_cfg.h和foo_int.h.
在foo.c中:
#include "foo.h"
#include "foo_int.h"
Run Code Online (Sandbox Code Playgroud)
在foo.h中:
#include "foo_cfg.h"
Run Code Online (Sandbox Code Playgroud)
在foo_cfg.h中:
/* no inclusions */
#define FOO BAR
Run Code Online (Sandbox Code Playgroud)
在foo_int.h中:
/* no inclusions */
#define BAR 0U
Run Code Online (Sandbox Code Playgroud)
我想知道为什么编译成功.foo_cfg.h文件不应该抱怨它不知道BAR符号吗?
此外,我有另一个源文件bar.c,它只包含foo.h文件,仍然有效.
备注:这是我正在处理的一个项目,我正在处理一个复杂的构建环境,其中我没有太多细节.可能是构建环境对此有影响,而不是指定header files?的位置?
可能是这个问题真的很愚蠢,或者我忽略了一些事情,如果是这样我会道歉.
我宣布String:
<string name="Please">Please Select</string>
Run Code Online (Sandbox Code Playgroud)
在res/values/Strings.xml.现在我想要访问这个String值,但我能得到的东西可以直到id不值如下:
int i = findViewById(R.string.Please);
Run Code Online (Sandbox Code Playgroud)
但我想要的只是字符串的值Please.
谢谢你的所有答案,但我的问题有点大
我想做的只是用app_name显示日期
从你的所有答案我可以得到app_name字符串,但我是否可以设置此app_name与当前日期
<string name="app_name">My app</string>
Run Code Online (Sandbox Code Playgroud)
而且我也是这样设置我的
My app(in Left alignment) Date (in right aligment)
Run Code Online (Sandbox Code Playgroud)
并且在第一个活动开始时我想设置app_name而不是每个活动;
我认为这可能有用,让我尝试一下
setResource().setString(R.string.Please);
Run Code Online (Sandbox Code Playgroud)
但没有setResource()方法对不起.
在我的短信应用程序中,我发送短信使用SmsManager.之后,我想要显示一个Toast说"Message sent"或"Message not sent".我如何检查邮件是否实际发送?可能就像一个没有连接的问题?还是没有SIM卡?我怎么能发现这些?
代码中缺少什么?
我这里有问题.我这里有2个edittext.一个用于金额,一个用于密码.我的应用程序就像一个魅力,除非我在edittexts上输入NONE,IT CRASHES(不幸的是停止).我错过了活动的任何代码吗?请帮忙.这是我的代码.
public class MainActivity extends Activity {
Button REDIRECT;
private EditText txtbox1,txtbox2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
REDIRECT = (Button) findViewById(R.id.button1);
txtbox1= (EditText) findViewById(R.id.editText1);
txtbox2= (EditText) findViewById(R.id.editText2);
REDIRECT.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int Amount = Integer.parseInt(txtbox1.getText().toString());
String Password = txtbox2.getText().toString();
if(Amount<=50&&Amount>=1 & Password.equals("TUBOL"))
{
final Intent i = new Intent(MainActivity.this, Redirect.class);
startActivity(i);
}
else
{
Toast.makeText(MainActivity.this, "INVALID", Toast.LENGTH_LONG).show();
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是我的logcat:
09-15 01:46:34.641: E/AndroidRuntime(30540): FATAL EXCEPTION: main
09-15 01:46:34.641: …Run Code Online (Sandbox Code Playgroud) 我是从youtube API请求获取此数组,但在我看来,持续时间格式非常少见.他们为什么不在那里扔几秒钟?无论如何,这是阵列
[duration] => PT2M3S
[dimension] => 2d
[definition] => sd
[caption] => false
Run Code Online (Sandbox Code Playgroud)
有没有办法在PHP中将此持续时间转换为"H:i:s"格式?
在此先感谢您的帮助
我的App.config如下.该文件与调用的项目相同:
log4net.Config.XmlConfigurator.Configure();
private static log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
Run Code Online (Sandbox Code Playgroud)
但是我收到了:
Log4net:ERROR XmlConfigurator无法在应用程序的.config文件中找到配置节'log4net'.检查.config文件中的
<log4net>和<configSections>元素.配置部分应如下所示:<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /
因为我刚开始使用log4net,我觉得我犯了一个愚蠢的错误.对此有何帮助?
<!-- language: xml -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\log-file.txt" />
<appendToFile value="true"/>
<rollingStyle value="Size" />
<maximumFileSize value="1MB" />
<staticLogFileName value="true" />
<maxSizeRollBackups value="10" />
<conversionPattern value="%date [%thread] %-5level %location %logger - %message%newline" />
<layout type="log4net.Layout.SimpleLayout" />
</appender>
<root>
<level value="ALL" />
<appender-ref ref="RollingFileAppender" />
</root>
</log4net>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我一直在尝试在我的程序中使用Intent方法,当我使用myactivity时,代码显示没有错误.当我使用其他两个(myactivity.class或者这个)时,eclipse显示错误.
Intent i = new Intent(myActivity.this,myActivity2.class);
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
当我在第一个参数中使用myactivity.class或者这个时,
Eclipse显示未定义的Constructor Intent错误.为什么这样,有人可以解释一下吗?