In Cocos2d iphone: Tiledmap showing blank display - cocos2d-iphone

In my cocos2d iphone project , I am trying to add tiled map. Tiled map has only one image layer.I am trying to add this tiledMap by below code.
-(id) init
{
if( (self=[super init])) {
theMape = [CCTMXTiledMap tiledMapWithTMXFile:#"demomap.tmx"];
[self addChild:theMape z:1];
}
return self;
}
and source of my tile map is:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="20" height="180" tilewidth="32" tileheight="32">
<tileset firstgid="1" name="block" tilewidth="32" tileheight="32">
<image source="block.png" width="90" height="34"/>
<tile id="0">
<properties>
<property name="type" value="base"/>
</properties>
</tile>
</tileset>
<imagelayer name="backgorund" width="20" height="180">
<image source="bgimage.png"/>
</imagelayer>
</map>
And i have bgimage.png file in my resource folder.
when it contains only tile layer than it will display that layer. I don't know what is wrong with this?

cocos2d-iphone does not support Tiled's image layer, only tile layers.

Related

Android Navigation Component multiple NavHost implementation

I have a simple single Activity app, the activity has only a toolbar and a FragmentContainerView that acts as the NaHost.
In one of my main screens, I have a Fragment that contains a BottomNavigationView that should toggle between 3 child Fragments. This parent fragment has also a FragmentContainerView that is also defined as a NavHost for the child fragments.
Can this setup work by just using one NavGraph? How can I tell the the navigation component which NavHost to use when switching between main screens which is different to when clicking on the BottomNavigationView items?
Activity XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="#+id/app_bar_container"
layout="#layout/app_bar" />
<androidx.fragment.app.FragmentContainerView
android:id="#+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:defaultNavHost="true"
app:navGraph="#navigation/nav_graph" />
</LinearLayout>
Parent Fragment:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="#+id/fragment_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="#id/tab_navigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="#navigation/nav_graph" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/tab_navigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/bottom_navigation_items" />
</androidx.constraintlayout.widget.ConstraintLayout>

Cocos2d-x TiledMap, return a nullptr when invoking getLayer() to get the collision layer?

I have been struggling with the null pointer for hours! It happened when I used the getLayer() method to get a layer from the tiled map in cocos2d-x (the tailed map is edited using the Tailed Map Editor).
map = TMXTiledMap::create("map/map1.tmx");
map->setAnchorPoint(Vec2(0.5, 0.5));
map->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 - 40));
this->addChild(map, 0, 100);
collidable = map->getLayer("collide")
collidable->setVisible(false);
The program didn't find the "collide" layer (it's a tiled layer) in my tailed map. However, it indeed exists in the TMX file :
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.1.5" orientation="orthogonal" renderorder="right-down" width="24" height="18" tilewidth="40" tileheight="40" infinite="0" nextlayerid="14" nextobjectid="2">
<tileset firstgid="1" name="Background" tilewidth="40" tileheight="40" tilecount="7" columns="7">
<image source="mapItems/background.png" width="280" height="40"/>
</tileset>
<tileset firstgid="8" name="tiles" tilewidth="40" tileheight="40" tilecount="16" columns="8">
<image source="mapItems/tiles.png" width="320" height="80"/>
</tileset>
<tileset firstgid="24" source="mapItems/collide.tsx"/>
<layer id="5" name="background" width="24" height="18">
<data encoding="base64" compression="zlib">
...(some code)
</layer>
<layer id="11" name="collide" width="24" height="18">
<properties>
<property name="collidable" value="true"/>
</properties>
<data encoding="base64" compression="zlib">
...
</data>
</layer>
<layer id="6" name="bricks" width="24" height="18">
<data encoding="base64" compression="zlib">
...
</data>
</layer>
<layer id="7" name="tops" width="24" height="18">
<data encoding="base64" compression="zlib">
...
</data>
</layer>
</map>
Moreover, I set breakpoint in the getLayer() method, and the program traverses and find all layers except the collide layer. Anyone can show me how to deal with this issue?
Okay, finally I solve this problem (4 hours since it occurred)... Despite I don't even know why.
The solution is editing the collide.tsx file. I tried to read it and found a sentence:
<image source="collide.png" trans=ff00ff width="40" height="40"/>
And this "trans=" seemed quite weird... So I deleted it. Then the issue was resolved.

How can we solve the null excaption in actionbar getactionbar function?

First I want to say that I am new in android, I have a lot of troubles with android action bar I am trying to not getting null on this line:
ActionBar actionBar = getActionBar();
I tried everything. I understand that it's returning null because the theme is not suitable to the theme of the activity. I don't know how to set a different theme to each one, but after I found a way to avoid this problem I got another problem. What I am trying to do is actionbar, and a tab bar, now I can't see the icons in the action bar, I see them in the overflow.
onCreate:
public class MainViewActivity extends Activity implements RoutesFragment.OnFragmentInteractionListener ,GroupsFragment.OnFragmentInteractionListener
,VideosFragment.OnFragmentInteractionListener,PhotosFragment.OnFragmentInteractionListener
{
private final CharSequence charSequence[] = {"Profile", "New route", "My route", "Liked route", "GroupsFragment", "Settings", "About CTwalk"};
private String charSequence2;
#Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_view);
getOverflowMenu();
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
Tab tab = actionBar.newTab()
.setText(R.string.tabs_Routes)
.setTabListener(new TabListener<RoutesFragment>(this, "Routes", RoutesFragment.class));
actionBar.addTab(tab);
tab = actionBar.newTab()
.setText(R.string.tabs_Groups)
.setTabListener(new TabListener<GroupsFragment>(
this, "GroupsFragment", GroupsFragment.class));
actionBar.addTab(tab);
tab = actionBar.newTab()
.setText(R.string.tabs_Photos)
.setTabListener(new TabListener<PhotosFragment>(
this, "PhotosFragment", PhotosFragment.class));
actionBar.addTab(tab);
tab = actionBar.newTab()
.setText(R.string.tabs_Videos)
.setTabListener(new TabListener<VideosFragment>(
this, "VideosFragment", VideosFragment.class));
actionBar.addTab(tab);
}
Android manidest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ctwalkapp.ctwalk" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/title_activity_login" >
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/facebook_app_id" />
<activity
android:name=".MainViewActivity"
android:label="#string/title_activity_main_view"
android:parentActivityName=".LoginActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".LoginActivity" />
</activity>
</application>
</manifest>
styles.xml:
<resources>
<style name="AppTheme" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:windowActionBar">true</item>
</style>
<style name= "MyCustomTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#3f51b5</item>
</style>
</resources>

Google Glass: Card not being displayed

Need help to display a sample card in the glass timeline(refer image). All i need is to launch the card when one taps when "ok glass" is displayed and scroll to view the card(image 2), the same via voice command also does not work.
I tried launching the same activity via adb shell it works perfectly fine, also i added an intent filter with MAIN/LAUNCHER category to the activity - it runs. I referred this link for this POC but nothing like the image is being displayed. Please help as to where am i going wrong - TIA
Activity:
package de.androidzeitgeist.glass.helloworld.immersion;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.glass.app.Card;
public class HelloWorldActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Card card = new Card(this);
card.setText("Hello world!");
card.setFootnote("android.com");
setContentView(cardroid.getView());
}
}
Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.androidzeitgeist.glass.helloworld.immersion"
android:versionCode="1"
android:versionName="1.0" >
<application
android:allowBackup="true"
android:icon="#drawable/helloworld_icon"
android:label="#string/app_name" >
<activity
android:name="de.androidzeitgeist.glass.helloworld.immersion.HelloWorldActivity"
android:icon="#drawable/helloworld_icon"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger" />
</activity>
</application>
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
</manifest>
voice_trigger.xml
<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="#string/show_hello_word" />
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloWorldImmersion</string>
<string name="hello_world"></string>
<string name="show_hello_word">show hello world</string>
</resources>
If you are using an unregistered voice command, your manifest.xml must include
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
See https://developers.google.com/glass/develop/gdk/starting-glassware for more details about using registered commands and unlisted commands and Why is my voice command missing from the ok glass menu in XE16? for some clarification and examples.

How to align Spinner in Actionbar to left

I want to align the spinner to left. spinner is not used for navigation here
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:textColor="#color/white"
android:textStyle="bold"/>
how to do it.
Grab the actionbar, then:
actionbar.setDisplayShowTitleEnabled(false);