Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Para gerenciar eventos de entrada por toque, leia a matriz
motionEvents no loop de jogo. Ela
contém eventos que ocorreram desde a última vez em que essas matrizes foram apagadas.
O número de eventos contidos é armazenado em motionEventsCount.
Faça a iteração e o processamento de cada evento no seu loop de jogo. Neste exemplo, o
código a seguir faz a iteração de motionEvents e os processa com handle_event:
for(size_ti=0;i < mApp->motionEventsCount;++i){GameActivityMotionEvent*motionEvent=mApp->motionEvents[i];intaction=motionEvent->action;intactionMasked=action & AMOTION_EVENT_ACTION_MASK;intptrIndex=(action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)>>
AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;structCookedEventev;memset(&ev,0,sizeof(ev));if(actionMasked==AMOTION_EVENT_ACTION_DOWN||actionMasked==AMOTION_EVENT_ACTION_POINTER_DOWN){ev.type=COOKED_EVENT_TYPE_POINTER_DOWN;}elseif(actionMasked==AMOTION_EVENT_ACTION_UP||actionMasked==AMOTION_EVENT_ACTION_POINTER_UP){ev.type=COOKED_EVENT_TYPE_POINTER_UP;}else{ev.type=COOKED_EVENT_TYPE_POINTER_MOVE;}ev.motionPointerId=motionEvent->pointers[ptrIndex].id;ev.motionIsOnScreen=motionEvent->source==AINPUT_SOURCE_TOUCHSCREEN;ev.motionX=GameActivityPointerInfo_getX(&motionEvent->pointers[ptrIndex]);ev.motionY=GameActivityPointerInfo_getY(&motionEvent->pointers[ptrIndex]);if(ev.motionIsOnScreen){// Use screen size as the motion range.ev.motionMinX=0.0f;ev.motionMaxX=SceneManager::GetInstance()->GetScreenWidth();ev.motionMinY=0.0f;ev.motionMaxY=SceneManager::GetInstance()->GetScreenHeight();}handle_event(&ev);}
Quando terminar, lembre-se de limpar a fila de eventos que você acabou de
processar:
android_app_clear_motion_events(mApp);
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2024-08-22 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Não contém as informações de que eu preciso"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Muito complicado / etapas demais"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Desatualizado"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"Problema na tradução"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Problema com as amostras / o código"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Outro"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Fácil de entender"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Meu problema foi resolvido"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Outro"
}]
{"lastModified": "\u00daltima atualiza\u00e7\u00e3o 2024-08-22 UTC."}
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2024-08-22 UTC."]]