예제 #1
0
    protected void registerClass(String p_name, String[] p_methods) {

      GodotLib.singleton(p_name, this);

      Class clazz = getClass();
      Method[] methods = clazz.getDeclaredMethods();
      for (Method method : methods) {
        boolean found = false;
        System.out.printf("METHOD: %s\n", method.getName());

        for (String s : p_methods) {
          System.out.printf("METHOD CMP WITH: %s\n", s);
          if (s.equals(method.getName())) {
            found = true;
            System.out.printf("METHOD CMP VALID");
            break;
          }
        }
        if (!found) continue;

        System.out.printf("METHOD FOUND: %s\n", method.getName());

        List<String> ptr = new ArrayList<String>();

        Class[] paramTypes = method.getParameterTypes();
        for (Class c : paramTypes) {
          ptr.add(c.getName());
        }

        String[] pt = new String[ptr.size()];
        ptr.toArray(pt);

        GodotLib.method(p_name, method.getName(), method.getReturnType().getName(), pt);
      }
    }
예제 #2
0
  // @Override public boolean dispatchTouchEvent (MotionEvent event) {
  public boolean gotTouchEvent(MotionEvent event) {

    super.onTouchEvent(event);
    int evcount = event.getPointerCount();
    if (evcount == 0) return true;

    int[] arr = new int[event.getPointerCount() * 3];

    for (int i = 0; i < event.getPointerCount(); i++) {

      arr[i * 3 + 0] = (int) event.getPointerId(i);
      arr[i * 3 + 1] = (int) event.getX(i);
      arr[i * 3 + 2] = (int) event.getY(i);
    }

    // System.out.printf("gaction: %d\n",event.getAction());
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        {
          GodotLib.touch(0, 0, evcount, arr);
          // System.out.printf("action down at: %f,%f\n", event.getX(),event.getY());
        }
        break;
      case MotionEvent.ACTION_MOVE:
        {
          GodotLib.touch(1, 0, evcount, arr);
          // for(int i=0;i<event.getPointerCount();i++) {
          //	System.out.printf("%d - moved to: %f,%f\n",i, event.getX(i),event.getY(i));
          // }
        }
        break;
      case MotionEvent.ACTION_POINTER_UP:
        {
          int pointer_idx = event.getActionIndex();
          GodotLib.touch(4, pointer_idx, evcount, arr);
          // System.out.printf("%d - s.up at: %f,%f\n",pointer_idx,
          // event.getX(pointer_idx),event.getY(pointer_idx));
        }
        break;
      case MotionEvent.ACTION_POINTER_DOWN:
        {
          int pointer_idx = event.getActionIndex();
          GodotLib.touch(3, pointer_idx, evcount, arr);
          // System.out.printf("%d - s.down at: %f,%f\n",pointer_idx,
          // event.getX(pointer_idx),event.getY(pointer_idx));
        }
        break;
      case MotionEvent.ACTION_CANCEL:
      case MotionEvent.ACTION_UP:
        {
          GodotLib.touch(2, 0, evcount, arr);
          // for(int i=0;i<event.getPointerCount();i++) {
          //	System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
          // }
        }
        break;
    }
    return true;
  }
예제 #3
0
 @Override
 public void onSensorChanged(SensorEvent event) {
   float x = event.values[0];
   float y = event.values[1];
   float z = event.values[2];
   GodotLib.accelerometer(x, y, z);
 }
예제 #4
0
 @Override
 protected void onPause() {
   super.onPause();
   mView.onPause();
   mSensorManager.unregisterListener(this);
   GodotLib.focusout();
 }
예제 #5
0
 @Override
 protected void onResume() {
   super.onResume();
   mView.onResume();
   mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
   GodotLib.focusin();
 }
예제 #6
0
  @Override
  protected void onPause() {
    super.onPause();
    if (!godot_initialized) {
      if (null != mDownloaderClientStub) {
        mDownloaderClientStub.disconnect(this);
      }
      return;
    }
    mView.onPause();
    mSensorManager.unregisterListener(this);
    GodotLib.focusout();

    for (int i = 0; i < singleton_count; i++) {
      singletons[i].onMainPause();
    }
  }
예제 #7
0
  @Override
  protected void onResume() {
    super.onResume();
    if (!godot_initialized) {
      if (null != mDownloaderClientStub) {
        mDownloaderClientStub.connect(this);
      }
      return;
    }

    mView.onResume();
    mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
    GodotLib.focusin();

    for (int i = 0; i < singleton_count; i++) {

      singletons[i].onMainResume();
    }
  }
예제 #8
0
  private void initializeGodot() {

    if (expansion_pack_path != null) {

      String[] new_cmdline;
      int cll = 0;
      if (command_line != null) {
        Log.d("GODOT", "initializeGodot: command_line: is not null");
        new_cmdline = new String[command_line.length + 2];
        cll = command_line.length;
        for (int i = 0; i < command_line.length; i++) {
          new_cmdline[i] = command_line[i];
        }
      } else {
        Log.d("GODOT", "initializeGodot: command_line: is null");
        new_cmdline = new String[2];
      }

      new_cmdline[cll] = "-main_pack";
      new_cmdline[cll + 1] = expansion_pack_path;
      command_line = new_cmdline;
    }

    io = new GodotIO(this);
    io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
    GodotLib.io = io;
    Log.d("GODOT", "command_line is null? " + ((command_line == null) ? "yes" : "no"));
    /*if(command_line != null){
        Log.d("GODOT", "Command Line:");
        for(int w=0;w <command_line.length;w++){
            Log.d("GODOT","   " + command_line[w]);
        }
    }*/
    GodotLib.initialize(this, io.needsReloadHooks(), command_line);
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);

    result_callback = null;

    mPaymentsManager = PaymentsManager.createManager(this).initService();
    godot_initialized = true;
  }
예제 #9
0
  @Override
  protected void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(
        WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    io = new GodotIO(this);
    io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
    GodotLib.io = io;
    GodotLib.initialize(this, io.needsReloadHooks());
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

    result_callback = null;

    //	instanceSingleton( new GodotFacebook(this) );

  }
예제 #10
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   GodotLib.key(event.getUnicodeChar(0), true);
   return super.onKeyDown(keyCode, event);
 };
예제 #11
0
  @Override
  public void onBackPressed() {

    GodotLib.quit();
  }
예제 #12
0
  @Override
  public void onBackPressed() {

    System.out.printf("** BACK REQUEST!\n");
    GodotLib.quit();
  }