Jump to content


Photo

2d platformer locking the camera help


  • Please log in to reply
7 replies to this topic

#1 thehuntsmen5434

thehuntsmen5434

    GMC Member

  • New Member
  • 28 posts
  • Version:GM8

Posted 30 April 2012 - 03:52 PM

I will probably fail at explaining this, but...

I'm trying to make the camera lock to center screen. The camera will still follow the player throughout the level, but when he starts reaching a stage border (either ceiling, wall, or floor) the camera won't keep him centered. Similar to the way Megaman and Castlevania games work.

Is there maybe a Camera_obj block i can make around the level that will restrict the room "view" from ever going beyond it?

Edited by thehuntsmen5434, 30 April 2012 - 03:53 PM.

  • 0

#2 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 30 April 2012 - 07:37 PM

Just use views in the room options. And if views isn't there, go to file and select advanced mode. That should help.
  • 0

#3 C_Pike

C_Pike

    GMC Member

  • GMC Member
  • 565 posts
  • Version:GM8.1

Posted 30 April 2012 - 08:01 PM

I will probably fail at explaining this, but...

I'm trying to make the camera lock to center screen. The camera will still follow the player throughout the level, but when he starts reaching a stage border (either ceiling, wall, or floor) the camera won't keep him centered. Similar to the way Megaman and Castlevania games work.

Is there maybe a Camera_obj block i can make around the level that will restrict the room "view" from ever going beyond it?


Like theepicgeno says, just use the room -> views -> object following

Here is the tech way (from smart codes)
(you can put it in the create event)
2. Automatic adjusting screen
view_hborder=view_wview/2 -obj_player.sprite_width
view_vborder=view_hview/2 -obj_player.sprite_height
This is probably one of the best "smart codes" I know. It resets your view so that "obj_player" is always perfectly in the middle. If you have a game where the player's sprite changes sizes or shapes, all you gotta do is run this code once after it changes sprites and it is perfect every time! Just make sure you have views turned on.
  • 0

#4 thehuntsmen5434

thehuntsmen5434

    GMC Member

  • New Member
  • 28 posts
  • Version:GM8

Posted 30 April 2012 - 08:07 PM

Oh sorry I messed up the question. I already have the player_obj centered and the camera following him. What I want is when he hits a border of a level that he isn't centered anymore. So when he's standing against a wall he can't see everything beyond it, and he's at the far right, or left of the screen. He'll just see the wall and that's it. Same would go for floors and the ceiling.
  • 0

#5 C_Pike

C_Pike

    GMC Member

  • GMC Member
  • 565 posts
  • Version:GM8.1

Posted 30 April 2012 - 08:12 PM

?? that should already be happening. Do you have mini-rooms in your game room?
  • 0

#6 thehuntsmen5434

thehuntsmen5434

    GMC Member

  • New Member
  • 28 posts
  • Version:GM8

Posted 30 April 2012 - 08:25 PM

?? that should already be happening. Do you have mini-rooms in your game room?


How I made my room was I just made a complete map in a editor called "tiled" saved the image as a png, then in Game maker made a block_obj and used that to keep the player within the confines of the picture. So there's all this extra space on all the sides.

I've never heard of mini-rooms. I'm assuming you mean I should break up my level into small chunks so when my character reaches the end of one it goes into another?

And if so would i have to literally break up my level image. Or could game maker designate what part of the map becomes its own room.

Edited by thehuntsmen5434, 30 April 2012 - 08:27 PM.

  • 0

#7 C_Pike

C_Pike

    GMC Member

  • GMC Member
  • 565 posts
  • Version:GM8.1

Posted 30 April 2012 - 08:30 PM


?? that should already be happening. Do you have mini-rooms in your game room?


How I made my room was I just made a complete map in a editor called "tiled" saved the image as a png, then in Game maker made a block_obj and used that to keep the player within the confines of the picture. So there's all this extra space on all the sides.

I've never heard of mini-rooms. I'm assuming you mean I should break up my level into small chunks so when my character reaches the end of one it goes into another?

And if so would i have to literally break up my level image. Or could game maker designate what part of the map becomes its own room.


I should have said "mini-room". Its what you have. Its just a confined area in the actual game room.
I don't know how to confine your view to a region, sorry.
  • 0

#8 thehuntsmen5434

thehuntsmen5434

    GMC Member

  • New Member
  • 28 posts
  • Version:GM8

Posted 30 April 2012 - 08:37 PM

Well either way just saying mini-rooms helped. That would work. Just have my level broken down into smaller rooms that only contained parts of the map. That transition to the next part when you hit the end. That way the camera can't go past the borders of the level since they don't exist. Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users