Open paulocoutinhox opened 11 months ago
Based on the GL verts count there may be a partial issue related to hitting the max vertex limit(s)? Potentially it'd be less severe if you hide or disable the rendering of the physics shapes (to reduce vertex draw count). https://discuss.cocos2d-x.org/t/tilemap-max-tiles-to-load-problem/25557
However, this may or may not have anything to do with your issue.
It's also possible there's mismatch between the camera coordinates and the culling frustum / rectangle, such that moving the camera or the tilemap is not also changing the GL Viewport (or something like that).
How are you "moving" the camera?
One thing I'm pretty sure I do in all games is I create a "Game Camera" manager or system such that when the camera is supposed to move, it is actually the entire world that is moved (in your case the tilemap). So panning the camera to the right actually instead moves the tilemap to the left. Does that make sense?
You should be able to "move" the camera, but it might require not using the Cocos2d Camera class, or might require at least fully understanding the cocos2d::Camera class. (note I am assuming, maybe wrongly, that Axmol is a large % the same code as cocos2d-x)
Anyway, just some thoughts for now, off the top of my head, based only on this screenshot and a quick search through some older cocos2d forum posts.
I should be able to get a chance to test out your demo before the new year starts.
Hi @stevetranby,
I make a copy of your classes here: https://github.com/paulocoutinhox/axmol-extensions
I will use that repository to store all extensions.
There is a sample there using WASM. And there is a sample that use your class.
We can continue there. What you think?
Thanks.
I finally set up AXMOL on my new Apple Silicon (arm64) laptop, so I am able to finally move forward with testing your issue (as well as working on updating and porting my cocos2d work over to axmol)
I downloaded your demo game and the initial thing I noticed is that the game tilemap is culled due to your using the custom camera replacing the "default camera". If I comment out the code in the GameScene::setupCamera() function then I am able to move around the tilemap and it fills out the screen.
I'm not sure what the issue is that you're trying to fix?
I think you're trying to support the ability to pinch to zoom in and out so that you can see more or less of the tilemap?
Do you have a demo where you're using the extensions, and thus the STPanAndZoom class?
I tried out this repo: https://github.com/paulocoutinhox/axmol-game-demo/
I will try out your extension project next, here: https://github.com/paulocoutinhox/axmol-extensions/
Have you had a chance to figure this out on your own? Or are you still having issues?
[moved this comment to other discussion]
One other thing. I know it's just a demo, but an enhancement in how I prefer controls work (at least for testing) are that movement and rotation are separated actions so that I can both move forward while rotating, and if I stop rotating I keep moving.
Your preference may be that you don't like how this changes input behavior.
void Player::updateAll(float dt)
{
if (moveDirection == 1)
{
moveForward(dt);
}
else if (moveDirection == 2)
{
moveBackward(dt);
}
// separate rotation from movement to allow moving while rotating
if (rotateSide == 1)
{
rotate(angle - rotateSpeed * dt);
}
else if (rotateSide == 2)
{
rotate(angle + rotateSpeed * dt);
}
}
void GameScene::onKeyReleased(EventKeyboard::KeyCode keyCode, Event *event)
{
if (keyCode == EventKeyboard::KeyCode::KEY_W)
{
player->stopMoving();
//player->stopRotatingSide(); // Don't stop rotating just because they stop moving
}
else if (keyCode == EventKeyboard::KeyCode::KEY_S)
{
player->stopMoving();
//player->stopRotatingSide(); // Don't stop rotating just because they stop moving
}
// separate if-else logic for rotation from movement
if (keyCode == EventKeyboard::KeyCode::KEY_A)
{
//player->stopMoving(); // Don't stop moving just because they stop rotating
player->stopRotatingSide();
}
else if (keyCode == EventKeyboard::KeyCode::KEY_D)
{
//player->stopMoving(); // Don't stop moving just because they stop rotating
player->stopRotatingSide();
}
}
Hi,
For each device i need set a "magic" number to zoom: https://github.com/paulocoutinhox/axmol-game-demo/blob/main/Source/scenes/GameScene.cpp#L107-L127
How can i create a camera that has the size of game? It is following the player, because i update it position on scene update, but it don't show full game.
Thanks.