为了理解blender python游戏脚本,我目前尝试使用此链接中的FPSController结构构建一个可以围绕球体行走的场景.对于重力和FPSController方向,我尝试构造一个python控制器,目前看起来像这样:
def main():
print("Started")
controller = bge.logic.getCurrentController()
me = controller.owner
distance, loc, glob = me.getVectTo((0,0,0))
grav = controller.actuators['Gravity']
strength = me['Gravity']
force = strength*(distance*distance)*glob
grav.force = force
try:
rot = Vector((0,0,-1)).rotation_difference(glob).to_matrix()
except Exception as E:
print(E)
rot = (0,0,0)
rotZ = me.orientation
me.orientation = rot*rotZ
controller.activate(grav)
main()
Run Code Online (Sandbox Code Playgroud)
大致工作,直到任何角度超过180度,然后看起来不连续.我假设这来自rotate_difference是不连续的 - 关于数学类型和实用程序的blender文档没有说什么,我还没有想到四元数表示还没有看到连续映射是否可行 - 我想有更优雅的方式实现局部Z方向是连续的鼠标依赖,而局部X和Y方向依赖于某些给定的向量,但如何?
更新到Google Play Services 6.5.87后,由于缺少LocationCLient类,我的应用程序无法编译.
的文档链接 是在瞬间损坏(404未找到)
我该如何解决?我想收到位置更新,使用地理围栏等.
android location google-play-services android-geofence fusedlocationproviderapi
在onCreate方法中,我正在利用它SupportMapFragment来显示地图.
SupportMapFragment fragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, fragment).commit();
Run Code Online (Sandbox Code Playgroud)
与此相关,我想添加一个标记.问题是当调用getMap为null时,我什么时候可以再试一次?是否有我可以注册的事件或我的方法本身是错的?
mMap = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
if(mMap == null)
//what do I do here?
Run Code Online (Sandbox Code Playgroud)
事实上,地图显示在手机上,但我似乎没有运气获得添加标记的参考.
更新:
我SupportMapFragment通过构造函数创建的原因是因为典型的setContentView崩溃并且无法正常工作.这让我处于困境,在那里我无法获得我在onCreate方法中的参考,因为我当时正在创建SupportMapFragment它.在进一步调查中,似乎我的setContentView问题是没有将Google-play-services jar和module/src设置为整个项目的一部分的副产品.完成这些后,setContentView现在可以工作,我可以getMap()像我期望的那样获得参考.
lots.xml ...
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)
LotsActivity.java ...
public class LotsActivity extends FragmentActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lots);
GoogleMap mMap;
mMap = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
if(mMap == null) …Run Code Online (Sandbox Code Playgroud) 如何从多个地理位置(长,纬度值)创建多边形地理围栏.此外,如何跟踪用户进入此地理围栏区域或从android上的此区域退出.
我这样做是为了MapView类之前,这是非常简单的czuse有像预定义的方法onInterceptTouchEvent或GestureListeners等.
有没有人在地图片段中尝试这种双击或双击缩放功能.我谷歌但仍然无法找到任何解决方案.
我只是通过添加UiSettings来启动它 getMap().getUiSettings().setZoomGesturesEnabled(true);
是否可以通过帮助实现setOnMapClickListener()地图片段的双击事件处理手势?
注意:这个问题纯粹是关于MapFragment并且与已经回答的MapView无关的问题双击:放大Android MapView?
编辑 我在布局中使用的MapFragment:
<ViewFlipper
android:id="@+id/viewFlipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/noItemsText"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:addStatesFromChildren="true"
android:background="@android:color/transparent"
android:gravity="center">
<ListView
android:id="@+id/storesListView"
style="@style/Fill"
android:background="@android:color/transparent"
android:cacheColorHint="#00000000" />
<fragment
android:id="@+id/mapview"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ViewFlipper>
Run Code Online (Sandbox Code Playgroud)
该类是一个控制器,它正在为Activity扩展Activity而不是AppCompactActivity.
我还在地图中添加了标记聚类.
班级方面:
public class StoreFinderController extends BeeonicsControllerBase implements OnMapReadyCallback,
ClusterManager.OnClusterItemInfoWindowClickListener<AllClusterItems>,ClusterManager.OnClusterClickListener<AllClusterItems> {
Run Code Online (Sandbox Code Playgroud)
onMapReady:
@Override
public void onMapReady(GoogleMap googleMap) {
/*better to work with our map :)*/
this.googleMap = googleMap;
mClusterManager = new CustomClusterManager<AllClusterItems>(getActivity(), getMap());
getMap().setOnCameraIdleListener(mClusterManager);
getMap().setOnInfoWindowClickListener(mClusterManager);
getMap().setOnMarkerClickListener(mClusterManager);
mClusterManager.setOnClusterItemInfoWindowClickListener(this);
mClusterManager.setOnClusterClickListener(this);
/*map additional …Run Code Online (Sandbox Code Playgroud) 我使用了一些处理程序
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
try{
Messages.onAcknowledgeReceived();
}catch(Exception e){
e.printStackTrace();
}
}
});
Run Code Online (Sandbox Code Playgroud)
它每15秒执行一次,有时它开始抛出一些警告
The Looper class instance count has over a limit(100). There should be some leakage of Looper or HandlerThread.
12-16 12:16:11.357: E/Looper(4647): Looper class instance count = 221
12-16 12:16:11.357: E/Looper(4647): Current Thread Name: IntentService[AppService]
12-16 12:16:12.316: E/Looper(4647): WARNING: The Looper class instance count has over a limit(100). There should be some leakage of Looper or HandlerThread.
12-16 12:16:12.318: E/Looper(4647): Looper class …Run Code Online (Sandbox Code Playgroud) 我正在通过网络获取纬度和经度
它给了我纬度和经度,但如果我NETWORK LOCATION PROVIDER的未经检查怎么办
它永远不会为我提供当前位置的纬度和经度。
我想要的是,如何NETWORK LOCATION PROVIDER在不知道用户已打开的情况下启用手机,
我怎样才能做到这一点?
我尝试过的是:
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(intent, 1);
But this will open the page in my phone to check it i want to check AUTOMATICALLY
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.phone", "com.android.phone.Settings");
startActivity(intent);
Run Code Online (Sandbox Code Playgroud) 假设电子邮件ID是abc@xyz.com,我需要从中提取域名(即xyz).我是正则表达式的新手.通过谷歌搜索,我发现了这个对话可能的解决方案.并试过类似的东西:
if("abc@xyz.com".matches(".*\\xyz\\b.*")){
//true
}
Run Code Online (Sandbox Code Playgroud)
但它对我不起作用.对此有什么解决方案吗?
开发我的第一个应用程序我正在尝试在列表视图中向我的元素添加部分.所有项目都有一个日期,我希望每次日期更改时返回一个包含日期的简单布局.在我的适配器中,我有以下内容:
public View getView(int position, View convertView, ViewGroup parent) {
Match match = matchArrayList.get(position);
Calendar matchTime = match.getDate();
SimpleDateFormat date = new SimpleDateFormat("dd-MM-yyyy");
SimpleDateFormat time = new SimpleDateFormat("HH:mm");
String sDate = date.format(matchTime.getTime());
SeparatorHolder separatorHolder = null;
MatchHolder matchHolder = null;
if (convertView == null) {
if (!sDate.equals(_lastDate)) {
convertView = inflator.inflate(R.layout.date_separator, null);
separatorHolder = new SeparatorHolder();
separatorHolder.Date = (TextView) convertView.findViewById(R.id.date);
convertView.setTag(separatorHolder);
} else {
convertView = inflator.inflate(R.layout.match_layout, null);
matchHolder = new MatchHolder();
matchHolder.Time = (TextView) convertView.findViewById(R.id.time);
matchHolder.HomeTeam = (TextView) convertView.findViewById(R.id.homeTeam); …Run Code Online (Sandbox Code Playgroud) 我无法显示对话框,我尝试但返回空指针.问题,我认为是上下文,我已尝试过这个但获得相同的结果......我认为另一种可能性是打开一个线程并在Main Activity中显示AlertDialog,这是我的代码:
文件 Sector1.java公共类Sector1扩展Fragment {
private Button btnNew_order,btnAggiungi;
private Spinner spin_prodotto, spin_tipo;
private EditText EtQta;
ListView userList;
static UserCustomAdapter userAdapter;
ArrayList<User> userArray = new ArrayList<User>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.sector1, container, false);
userAdapter = new UserCustomAdapter(getActivity().getBaseContext(), R.layout.row, userArray);
userList = (ListView) rootView.findViewById(R.id.listView);
userList.setItemsCanFocus(false);
userAdapter.notifyDataSetChanged();
userList.setAdapter(userAdapter);
Run Code Online (Sandbox Code Playgroud)
UserCustomAdapter.java
public class UserCustomAdapter extends ArrayAdapter<User> {
private static final int INVISIBLE = 4;
private static final int VISIBLE = 0;
Context context;
int layoutResourceId;
ArrayList<User> …Run Code Online (Sandbox Code Playgroud) android ×8
java ×2
blender ×1
geofencing ×1
geolocation ×1
google-maps ×1
location ×1
python ×1
regex ×1