Recommended Posts

Hello! I'm not well versed in game development but I write a lot of JS for my classes and my job, so I'd like to think I have some semblance of knowing what I'm doing, but the issue I'm having with Phaser right now is completely beyond me.

It's hard to accurately describe my problem in words, so I've left the entire project as an attachment for you to see for yourself. (Cursor keys to control.) Essentially, I'm trying to write a simple platformer using a tilemap larger than the screen. However, when the camera is set to follow an object, and that object crosses the center of the window in a given direction on either axis, the camera slides in that direction at high speed - it seems to depend on how far you've crossed the threshold - until it reaches the stage boundary. The most difficult part is that the object seems to move properly relative to the camera - meaning it moves across the stage itself at very high speeds, confusing the arcade physics system and causing clips and zips galore if you're in the wrong places (try jumping under the spawn platform, for instance - you'll zip to the left or right)

The problem doesn't happen at all when the stage size is equal to the game window size, nor does it happen if the camera is not following an object.

Here are some things I've tried to resolve the issue:

Removing game window scaling code

Rewriting of Tilemap import code & use of different maps and tilesets

Refactoring/simplification of the Player object (as well as forgoing the use of a class and extending Phaser.Sprite)

Restarting the project and rewriting all code (this happened on a prior test project as well)

Rolling back to some prior versions of Phaser

I'm not certain whether the issue is with my Tilemap setup, my use of the camera, the general jankiness of the arcade physics system, or maybe something else I haven't taken into account, but given half of my Google searches lead here, I'm sure someone's got some kind of answer for me.

For convenience, here's the important bits of my code, in case anything looks off at first glance: