Hi,
I am having issues with touch events on Android and was wondering if anyone had more insight into this (I am still trying to work through it).
In cocos2d-x/cocos2dx/event_dispatcher/CCEventDispatcher.cpp the EventListener instance is being added, which has a bound function for onTouchesBegan
from cocos2d-x/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp::addTouchListener()
I have Amazon GameCircle implemented which adds it’s own HTML toast overlays. When I touch my game layer it crashes on SIGSEGV which I’ve narrowed down to cocos2d-x/cocos2dx/event_dispatcher/CCEventDispatcher.cpp where touchEventListener->onTouchesBegan(mutableTouches, event);
is called for the allInOnelisteners
loop. It seems that the bound function for “onTouchesBegan” has not been retained.
Does anyone have any clue what I am doing wrong? In my Layer instance, I am simply calling setTouchEnabled(true).
The difference is that I have Amazon GameCircle added, which required my subclassing NativeActivity, which I’ve added below:
package com.mygame;
import java.util.EnumSet;
import android.os.Bundle;
import android.app.NativeActivity;
import android.util.Log;
import com.amazon.ags.api.AmazonGamesFeature;
import com.amazon.ags.api.AmazonGamesStatus;
import com.amazon.ags.api.AmazonGamesCallback;
import com.amazon.ags.api.AmazonGamesClient;
public class NativeActivityProxy extends android.app.NativeActivity {
protected AmazonGamesClient agsClient;
protected AmazonGamesCallback agsCallback;
protected EnumSet myGameFeatures;
protected void onCreate(Bundle savedInstanceState){
System.loadLibrary("AmazonGamesJni");
super.onCreate(savedInstanceState);
//reference to the agsClient
agsCallback = new AmazonGamesCallback() {
@Override
public void onServiceNotReady(AmazonGamesStatus status) {
//unable to use service
}
@Override
public void onServiceReady(AmazonGamesClient amazonGamesClient) {
agsClient = amazonGamesClient;
//ready to use GameCircle
}
};
//list of features your game uses (in this example, achievements and leaderboards)
myGameFeatures = EnumSet.of(AmazonGamesFeature.Leaderboards, AmazonGamesFeature.Achievements);
}
@Override
public void onResume() {
super.onResume();
AmazonGamesClient.initialize(this, agsCallback, myGameFeatures);
}
@Override
public void onPause() {
super.onPause();
if (agsClient != null) {
agsClient.release();
}
}
}