View screen at middle.

7 replies to this topic

#1 GrayCircle

GrayCircle

GMC Member

• New Member
• 21 posts
• Version:GM8

Posted 15 February 2012 - 03:08 AM

I want to view the screen in the middle of a room in particular of an object but it goes way off from me to see it at this view:
```x = (room_height*view_xview)/35
y = (room_height*view_yview)/35
```
How can I fix this?
• 0

#2 greep

greep

Menaces with Spikes

• GMC Member
• 2398 posts
• Version:GM7

Posted 15 February 2012 - 03:26 AM

Hrm, could you clarify what you want to do?

This takes the current object, moves it to the heoght of the room multiplied by the upperleft corner of the view, then divides it by 35.

if you just want to move the view to the middle of the room, just do

view_xview[0] = room_width/2 - view_wview[0]/2
view_yview[0] = room_height/2 - view_hview[0]/2

Edited by greep, 15 February 2012 - 03:27 AM.

• 0

#3 GrayCircle

GrayCircle

GMC Member

• New Member
• 21 posts
• Version:GM8

Posted 15 February 2012 - 11:13 PM

Hrm, could you clarify what you want to do?

This takes the current object, moves it to the heoght of the room multiplied by the upperleft corner of the view, then divides it by 35.

if you just want to move the view to the middle of the room, just do

view_xview[0] = room_width/2 - view_wview[0]/2
view_yview[0] = room_height/2 - view_hview[0]/2

I don't want to view it on the middle of the room! When paused object appears, I want to draw the text to the middle of the view of the main object. Any ides?
• 0

#4 greep

greep

Menaces with Spikes

• GMC Member
• 2398 posts
• Version:GM7

Posted 15 February 2012 - 11:20 PM

Edit: oh wait what, that isn't anything like what you said in the topic creation. Hold on I can do that.

x = view_xview[0] + view_wview[0]/2 ;
y = view_yview[0] + view_hview[0]/2 ;

edit: Although if the view just follows the object, just to x = yourobject.x; y = yourobject.y. Also sorry for getting annoyed, it's just sometimes newbies think helpers can read minds I should've figured out that by room you just meant screen. I take words too literally sometimes

Edited by greep, 16 February 2012 - 12:49 AM.

• 0

#5 GrayCircle

GrayCircle

GMC Member

• New Member
• 21 posts
• Version:GM8

Posted 16 February 2012 - 02:08 PM

I did exactly what you told me to do.
```execute code:

x = (view_xview[0]/2 + view_wview[0]/2)-130
y = (view_yview[0]/2 + view_hview[0]/2)+120

Destroy Event:

Unknown Action
Draw Event:

execute code:

for (l=1; l <= pauseText[pausePage,0]; l+=1)
{
if (pauseSelected = l)
{
draw_set_color(c_red)
}
else
{
draw_set_color(c_black)
}
draw_text(x,y+(l*16)-16,pauseText[pausePage,l]);
}
if pausePage = 2
{
draw_text(obj_pause.x-15,obj_pause.y-45,"Are you sure you want to the Main Menu?")
}
if pausePage = 0
{
draw_text(obj_pause.x+5,obj_pause.y-25,"Paused!")
}
```
It draw the whole text not in the the player's position but in terms of the room. How can I fix this?
• 0

#6 greep

greep

Menaces with Spikes

• GMC Member
• 2398 posts
• Version:GM7

Posted 16 February 2012 - 09:49 PM

Bah you said to "the middle of the view of the main object". If you just want the players position do

x = YourPlayerObject.x
y = YourPlayerObject.y

put it in the end step so it doesn't ;ag behind the player.

Edited by greep, 16 February 2012 - 09:49 PM.

• 0

#7 GrayCircle

GrayCircle

GMC Member

• New Member
• 21 posts
• Version:GM8

Posted 17 February 2012 - 12:23 PM

Bah you said to "the middle of the view of the main object". If you just want the players position do

x = YourPlayerObject.x
y = YourPlayerObject.y

put it in the end step so it doesn't ;ag behind the player.

```___________________________________________
ERROR in
action number 1
of End Step Event
for object obj_pause:

Error in code at line 1:
x = GrayCircle.x
^
at position 16: Unknown variable x
```
```Information about object: GrayCircle //player object
Create Event:
execute code:

x = x
y = y
```
What's wrong?
• 0

#8 greep

greep

Menaces with Spikes

• GMC Member
• 2398 posts
• Version:GM7

Posted 17 February 2012 - 12:47 PM

4 things I can think of:

A) Graycircle might be the name of your sprite or something as well as your object. Duplicate names are a nono

Somehow the pause object is being created before the main character.

C) The main character is killed or maybe deactivated during a pause

D) Misspelled your own object Although I'm guessing by now you know if you type the object correctly it changes color.

try

if (instance_exists(GrayCircle))
{
x = GrayCircle.x
y = GrayCircle.y

}

Edited by greep, 17 February 2012 - 12:50 PM.

• 0

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users