androidkotlincmakeandroid-gameactivity

How can I run GameActivity template in Android Studio?


I've found GameActivity template when I create Android Project.

enter image description here

I ran it but

  1. First of all, the minSdk must be over 29(from 30)
  2. Second of all, control part source seems broken.
void Renderer::handleInput() {
    // handle all queued inputs
    for (auto i = 0; i < app_->motionEventsCount; i++) {

        // cache the current event
        auto &motionEvent = app_->motionEvents[i];

        // cache the current action
        auto action = motionEvent.action;

        // Find the pointer index, mask and bitshift to turn it into a readable value
        auto pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)
                >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
        aout << "Pointer " << pointerIndex << ":";

        // get the x and y position of this event
        auto &pointer = motionEvent.pointers[pointerIndex];
        auto x = GameActivityPointerAxes_getX(&pointer);
        auto y = GameActivityPointerAxes_getY(&pointer);
        aout << "(" << x << ", " << y << ") ";

        // Only consider touchscreen events, like touches
        auto actionMasked = action & AINPUT_SOURCE_TOUCHSCREEN;

        // determine the kind of event it is
        switch (actionMasked) {
            case AMOTION_EVENT_ACTION_DOWN:
            case AMOTION_EVENT_ACTION_POINTER_DOWN:
                aout << "Pointer Down";
                break;

            case AMOTION_EVENT_ACTION_UP:
            case AMOTION_EVENT_ACTION_POINTER_UP:
                aout << "Pointer Up";
                break;

            default:
                aout << "Pointer Move";
        }

        aout << std::endl;
    }

    // clear inputs, be careful as this will clear it for anyone listening to these events
    android_app_clear_motion_events(app_);
}

motionEventsCount, motionEvents, etc don't exist.

How can I solve this two issues?


Solution

  • The fix is in: