Jump to content


Photo

View issue


  • Please log in to reply
3 replies to this topic

#1 Rhymer

Rhymer

    GMC Member

  • New Member
  • 2 posts

Posted 24 January 2011 - 09:44 PM

Hi, so yeah, first time poster here. I tried looking through the search bar for this question, but the little I understood was of no real use to me. At least I think not :)

So, this being my first game, it's pretty simple. Press right to move right, release to stop, repeat. The end. I have created a view that should follow the "player", as I don't want the player to be able to see the whole map, only what's right in front of him.

Now that's the problem. The player can't move left, so what's to the left of the main object is not important, and therefore I want it outside of the view.

The view is 300 pixels wide. I want the character to be located about 80 pixels in from the left border and stay in the same position as the object and the view travel right across the room. I tried using the Hbor thing in the Views tab, but it does not work the way I need it to.


I want it to look something like this:

|---X-----------|

x=object/player


I'd be unbelievably grateful if some kind spirit in here would guide me towards how to accomplish this.

Thanks in advance;
//Rhymer
  • 0

#2 Gibraldi

Gibraldi

    GMC Member

  • New Member
  • 340 posts

Posted 24 January 2011 - 09:50 PM

well you could try creating an invisible object which the view follows and in the step event you can do something like this:
x = Player.x + 10 //change Player to the player's object name and 10 to whatever you want
what this does is actually very simple, it keeps the object a set distance away from the player, making it look as if the player is more left in the room.

When using d&d you can put the execute code action in there and put that code there
  • 0

#3 Canite

Canite

    Canigget

  • GMC Member
  • 1358 posts
  • Version:GM8

Posted 24 January 2011 - 09:51 PM

To do this, you will need to either have a fake object that is ahead of the player and have the view follow this, or manually move the view using some code. For the former, just create a blank object, and in its step event, put
x = obj_player.x + (view_wview/2 - 80) // this will place the object so it is in the middle of the view with the player 80 pixels from the left
Then just set the view to follow this object and set the borders to half the views width and height.

The latter would take a minute for me to type out on my phone, so try the first one and if it doesn't work for you, ill help with this solution.

Edit: accidently put +80 when it should be -80

Edited by Canite, 24 January 2011 - 09:53 PM.

  • 0

#4 Rhymer

Rhymer

    GMC Member

  • New Member
  • 2 posts

Posted 24 January 2011 - 10:01 PM

Many thanks to both of you, my view now works wonderfully :)

Cheers;
//Rhymer
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users