Jump to content


Photo

[solved]


  • Please log in to reply
5 replies to this topic

#1 SlipknLov

SlipknLov

    GMC Member

  • GMC Member
  • 236 posts
  • Version:GM8

Posted 28 February 2012 - 08:13 AM

object: objRoomMove
[create] event:
wview=480;
hview=360;
zoom=1;

[step] event:
view_wview=wview*zoom;
view_hview=hview*zoom;

if mouse_wheel_down() then
 { if zoom<2 then { zoom+=0.1 } }
if mouse_wheel_up() then
 { if zoom>1 then { zoom-=0.1 } }

It works fine, but my HUD stays the same size..
is there a way to make the HUD's width the same as the view_wview? and same for the HUD's height?

Edited by SlipknLov, 29 February 2012 - 07:59 AM.

  • 0

#2 iam1me

iam1me

    GMC Member

  • GMC Member
  • 380 posts
  • Version:GM8

Posted 28 February 2012 - 09:19 AM

If you want to change the pixel size/position of your HUD on the screen, you need to use view_wport[...], view_hport[...], etc.
  • 0

#3 RangerX

RangerX

    GMC Member

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

Posted 28 February 2012 - 12:54 PM

It works fine, but my HUD stays the same size..
is there a way to make the HUD's width the same as the view_wview? and same for the HUD's height?


How is your hud made? Is it a sprite? If it is, you need that sprite to be the right size and then position it properly or scale your sprite with the variables "image_xscale" and "image_yscale".

Let's say your view_width is 600 pixels. You can have a Hud sprite 600 pixel long. You can also 2x scale a 300 pixel wide Hud sprite... (image_xscale=2)

If this doesn't help you, I will need to know more about your hud. How it is structured, what is supposed to do and see the related code.
  • 0

#4 SlipknLov

SlipknLov

    GMC Member

  • GMC Member
  • 236 posts
  • Version:GM8

Posted 29 February 2012 - 04:25 AM

How is your hud made? Is it a sprite? If it is, you need that sprite to be the right size and then position it properly or scale your sprite with the variables "image_xscale" and "image_yscale".

Let's say your view_width is 600 pixels. You can have a Hud sprite 600 pixel long. You can also 2x scale a 300 pixel wide Hud sprite... (image_xscale=2)

If this doesn't help you, I will need to know more about your hud. How it is structured, what is supposed to do and see the related code.


In my objHud's Draw event:
draw_background_ext(backHud1,view_xview,view_yview,1,1,0,c_white,0.75);

But i foresee a problem.. i wanted buttons to be able to appear on HUD that are able to be clicked on.. and i'm not sure it'll register the same after blowing up the HUD. The standard view-in-room dimensions are 640x480.
  • 0

#5 RangerX

RangerX

    GMC Member

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

Posted 29 February 2012 - 04:49 AM

I think you won't be able to click on a background. Your buttons will need to be objects if you want them clickable. Maybe your hud should be either an object (its sprite being your hud) and buttons either drawn over it or the button being another object. I never make a hud as a background. Seems a bit wierd and unfriendly...
  • 0

#6 SlipknLov

SlipknLov

    GMC Member

  • GMC Member
  • 236 posts
  • Version:GM8

Posted 29 February 2012 - 07:54 AM

I seem to have bypasses all my HUD problems.
Here's how i fixed it:

in my objGlobalController's [Create] event:
global.zoom=1;

objRoomMove's [Step] event:
if mouse_wheel_down() then { if global.zoom<2 then { global.zoom+=0.1 } }
if mouse_wheel_up() then { if global.zoom>1 then { global.zoom-=0.1 } }

objRoomMove's [End Step] event:
view_wview=wview*global.zoom;
view_hview=hview*global.zoom;

in my objHud's [Draw] event:
draw_background_ext(backHud1,view_xview,view_yview,global.zoom,global.zoom,0,c_white,0.75); draw_sprite_ext(sprAddCitizen,0,view_xview+293*global.zoom,view_yview+387*global.zoom,global.zoom,global.zoom,0,c_white,1);

and Lastly, in my objHud's [Step] event:
if selected.class='building' then
  { if mouse_check_button_pressed(mb_left) then
   { if (mouse_y>view_yview+387*global.zoom
     and mouse_y<view_yview+458*global.zoom) then //within Y
    { if mouse_y<view_yview+418*global.zoom then //TOP ROW
     { if (mouse_x>view_xview+293*global.zoom
       and mouse_x<view_xview+324*global.zoom) then //left column
       {
        if place_free(selected.x,selected.y+80) then
         { instance_create(selected.x,selected.y+80,objCitizen1); }
       }
       
     }
    } 
   }
  }

I've gotten it to work for 1 button so far, but i'll continue to see if it leads to bugs. But as of now, if i don't come back, this is solved. Thanks for your help guys.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users