I made a game using Visual studio c++ with a windows PC, and now I am trying to copy the code over to Android Studio to make the mobile app version.
At first I pasted the whole template.cpp file into the android template folder, but the problem is the app would just dump immediately (with an android error message saying "The app keeps stopping"). So I decided to try copy and paste small bits of the code at a time to see where the problem might be.
After pasting a few functions including the app::Begin (void), I ran jniCompile.bat, which worked fine, and I successfully ran the app -- the media loaded up, music started, etc...
The next function I pasted seemed to cause an issue, I noticed that jniCompile.bat didn't run as long, it only showed one line:
"[armeabi-v7a] Compile++ arm : android_player <= template.cpp"
Normally it spits out these 6 lines:
[armeabi-v7a] Compile++ arm : android_player <= template.cpp
[armeabi-v7a] SharedLibrary : libandroid_player.so
[armeabi-v7a] Install : libandroid_player.so => jniLibs/armeabi-v7a/libandroid_player.so
[arm64-v8a] Compile++ : android_player <= template.cpp
[arm64-v8a] SharedLibrary : libandroid_player.so
[arm64-v8a] Install : libandroid_player.so => jniLibs/arm64-v8a/libandroid_player.so
Now running the app with that next function pasted in causes it to dump again. The problem is that there is no indicator of what the error is, so I have no idea what to do to fix the issue. I have tried commenting out certain lines to see if I can narrow it down but that hasn't worked so far.
Oddly enough I am not even calling the function from the main loop (or anywhere in the code), it's causing the issue simply by being there.. Which makes no sense to me.
Here is the function causing the issue:
void SpawnThings(void)
{
if (spawns_made < Level[current_level].number_of_spawns)
{
SpawnTimer += 1;
if (SpawnTimer > Level[current_level].delay_between_spawns)
{
Spawns.push_back({ agk::CloneObject(Level[current_level].spawn_model) });
Spawns.back().hp = Level[current_level].hp_per_spawn;
Spawns.back().move_speed = Level[current_level].spawn_speed;
Spawns.back().hp_bar_sprite = agk::CreateSprite(0);
Spawns.back().current_waypoint = 0;
agk::SetObjectVisible(Spawns.back().object, 1);
agk::SetObjectScale(Spawns.back().object, Level[current_level].spawn_scale, Level[current_level].spawn_scale, Level[current_level].spawn_scale);
agk::SetObjectPosition(Spawns.back().object, -60, 13, 50);
agk::PlaySound(spawn_sound, 60);
SpawnTimer = 0;
spawns_made++;
// DO SPAWN EFFECT SPRITE
if (!agk::GetSpritePlaying(spawn_effect_sprite))
{
agk::SetSpritePositionByOffset(spawn_effect_sprite, agk::GetScreenXFrom3D(-60, 13, 50), agk::GetScreenYFrom3D(-60, 13, 50));
agk::PlaySprite(spawn_effect_sprite, 20, 0);
}
}
}
// MOVE SPAWN EFFECT SPRITE OFF SCREEN IF FINISHED PLAYING
if (!agk::GetSpritePlaying(spawn_effect_sprite)) { agk::SetSpritePosition(spawn_effect_sprite, -1000, -1000); }
else { agk::SetSpritePositionByOffset(spawn_effect_sprite, agk::GetScreenXFrom3D(-60, 13, 50), agk::GetScreenYFrom3D(-60, 13, 50)); }
}