How to have game world larger than the winsize?

I have a project using Chipmunk and my intended goal is to have walls on each side and basically drop a PhysicsSprite from the top of the world i’ll call it and have it fall with the camera following it… Kinda like if you went and jumped off a cliff :stuck_out_tongue:

The problem is I have everything working except when the sprite goes outside of the scene/layer bounds the texture disappears. The physics world behaves as expected it seems its just the scene/layer hindering me from doing what I want to do.


|------------------| <------ where i want my scene height to be
|------------------|
|------------------| <------ top of game window (sprite disappears above this point)

------------------
___________

So how do I resize my scene / game world ?

Any help would be greatly appreciated! :smiley: I was thinking that maybe I need to calculate the effect of gravity on the falling object and then adjust the position of my game world we’ll call it based off that… but it seems overkill there has to be a easier solution all I want is just a larger area than the original scene size :frowning:

Hi, @pr4nq
Do you want to implement a camera follow effect in a physical world?
I don’t understand your question, could you make it more clearer?

I handle this sort of thing as follows:

I model EVERYTHING in Physics dimensions. (I use Box2d so I use meters, but that doesn’t matter.

So, I keep a track of the bottom left and top right of my ‘viewing window’, in meters

I then have a function to convert coordinates from ‘world space’ to screen pixels, taking into account the location of my viewing window.

e.g. if my window is currently (0,1000) (32, 1024) (i.e. it is 32 meters wide, and 24 meters high, looking at WorldSpace from 1000m up

So if I have a physics object at (16, 1030) it’s not visible
At (16, 1010) it is towards the bottom of the screen, in the middle.

So your game world stays still, but your window moves - as your player moves down (say past the middle of your window) you move the window down to ‘catch up’ with the player.

I put all of the calculations into functions, so I can play around with the movement - for example I can adjust the window location to keep the player exactly centred, or I can add some ‘lag’ so the window appears more like a camera trying to follow the player.

The important thing (in my mind) is to keep the two (physical world and visible world) separate - model all locations in the physical and translate to visible - so your physics engine can get on with its job while you are just mapping everything onto the screen.

This also makes it easier to map things onto different shape or resolution screens, zoom in or out etc.

1 Like

My buddy was helping me on this before I noticed these responses and he pointed out that somehow my cocos source was < 3.2… I was trying to use CCCamera class which was deprecated I still am dumbfounded of how I got < 3.2 source lol but oh well glad we caught it.

I was thinking you moved the camera around the world but instead I guess your moving the scene so now knowing that I managed to have a little more success with what I was doing :smiley:

I’ve had a rough road diving into cocos the documentation seems like something you have to loosely follow. I guess what can you expect, but one of you coco pro’s write up some good docs for us newbs :smiley: lol… some might say that cocos docs are sufficient… i’ve just ran into one problem after another.

One of the biggest complaints I have and hear is the quality of the documentation.

Unfortunately the Cocos developers keep making improvements (or, at least, changes) to the engine and do little if anything to improve on the documentation - especially for newbs.

yeah i was following the docs and just running into one problem after another… i switched to just reading the source each time i wanna do something new or use a new class and what not and things have went a lot smoother :DDD

hey i just posted another thread with a question and not getting any responses on it? if you’d be kind enough to give it a gander i’d appreciate it ha ha (like how i sneak’d that in there :P)

haha thanks either way :smiley:

Link: Why jitter/jerk when following sprite with layer? (video included)