Hi everyone,
I am currently trying to do a simple side scroller in an infinite level by scrolling the items through the screen and respawning them on the right. The player basically only moves up and down. This seems a lot harder than I thought. FYI: Im a rather experienced programmer (mostly not in gaming) and new to Construct2. Now sidescrolling is a pretty simple thing, or so I thought, thus I am rather disappointed on how difficult it proves to be. The way I tried it, it breaks some profound assumptions of the physics behaviour, and I am very much interested to hear what others have to say to my current approach:
I have solid physics objects, some immovable ones (ground+platforms) and other movable ones (player sprite+items). Whenever the player "moves", all non-player objects move to the left while the player remains stationary in X. I just used set object.x = object.x-velocityX for all of them. This "simple" position change of movable physics objects breaks the physics behaviour completely, they wobble around and motion after collision is completely wild. So instead of assigning the items' x positions I now disable the items' physics until a collision occurs, so they are glued to the platforms and bumped away on collision by physics.
This looks reasonably well, but I face the next problem: When the items are bumped away and remain within the view, they should come to rest on the ground or a platform, and then of course move to the left again if the player continues to move. Now when they come to rest on a platform (solid and immovable) and the platform is moved away to the left due to the player moving forward, the items remain floating in mid-air. Probably the physics engine (rightfully) assumes that collisions need not be updated for an immovable object. So I triggered a "refresh" by enabling and disabling the physics behaviour of the platforms. You really shouldnt have to do that, should you? And of course, still, the items do not move with the platform to the left.
Of course these are just hacks around the basic problem which is: How can I tell the physics engine that its "world" is moving to the left? Or cant I use the physics behaviour at all? I did some other experiments, such as using the physics properties to move the items instead of setting x positions directly, but without much success.
Best regards,
Marc