How to split screen or have variable layer size

How to split screen or have variable layer size
0.0 0



I see. Thanks. What is the name of the file that the TMX needs? Edit, i see you uploaded again above. Thanks.




I had to edit the TMX file to change the path it was looking for Objects.png, but this is what I see.


This is from SFML. This is what I want to achieve. Notice the tilemap getting clipped near the HUD.


You see correctly. And this is the problem. The player and the strange purple sign near the Cocos-Shut-Down Icon should have been clipped.


Add this in your code too. (818.8 KB)

        auto HUDBanner = Sprite::create("F:/DEN Games/Bang Bang/Game/Images/HUDBanner.png");
	HUDBanner->setAnchorPoint(Vec2(0, 1));
	HUDBanner->setPosition(0, HUDBanner->getContentSize().height);


ok. I have to step out of the office for a bit, but I will play with this when I get back.


Ok, and thanks a lot for helping me so much, and being so patient with me. :smiley:


So basically it is the getting clipped on the right side that is your issue.


Left and right is fine, I want it to be clipped at the bottom. I want it take only 80% of the screen height. It shouldn’t draw itself below that. HUD is drawn there.


oh, your TMX you want drawn starting at the height of your HUD.


Yes, and then as my player moves, the TMX should move too, but it still shouldn’t draw behind or on top of HUD.


If you look at the SFML picture, you will see what I want to achieve. The Game Screen follows the player, but always draw within its limits. Anything outside that gets clipped. All I want is a method which clips a layer to a size different than the default window size.


It looks to me that this has to do with how you are positioning all these layers. As I start to adjust anchor points and setPosition calls then it starts to start lining up.


Now what code do you write to move the Game Layer as the player move?


You could use Actions/Sequences to move the Layers position, you could let the Parallax node take care of moving, I think this depends upon the game play feel you want. Do you want the character left behind and die if they don’t play fast enough or do you want the players moves to determine how much the layer moves. If they play slower, the layers move slower, etc.

Edit: I changed your anchor points to 0,0 and some of your set position calls didn’t make sense to me why, so I changed a few of those as well.


I want the second part. The layer moves as the player moves. And if a player moves up, he can also come down, and the layer moves accordingly. Its basically a world, where the player and aliens can freely roam. But since the world is too big, we display only a part of it, and display it on 80% of the screen.

I tried using the parallax node and set position method as the player moves, but when I do that, it starts drawing on the entire screen. I think you are still not getting what I want to do!!


I get what you are trying to do just fine. There are a number of ways to attack this. Maybe use update() on the Player sprite to move the layer as the position of the Sprite changes. You could ditch Parallax completely and just use normal layers.


And to move the layer will you use setPosition method? because if you do that, you are basically drawing it behind HUD too. There is no clipping. I tried that too!