Resources > Coding

GM7/8 Problem with surfaces and views

<< < (2/2)

Martijn dh:
Is your view 1:1 with the screen? If your view has a different size (for example a view of 240:320 is fitted to your larger monitor screen or visa versa) then you may need to determine the factor between both and then multiple (objLink - _x) by that amount.

Beyond that I'd need some screenshots to better understand your issue.

Yeah, view is fitted to the screen. I'll try and take a little video when I get home from work.
EDIT: ok here it is

Martijn dh:
Looks very similar to the problem I was thinking of: whenever your view moves then the light moves a constant factor extra on top of the view's movement itself.

I encountered a similar issue when drawing in the GUI draw event. My view of 320x240 was draw on screen as 640x480 pixels and I had to multiply all positions by the factor between that view and screen size. The reason is that a normal draw event will draw everything on a viewsurface of 320x240 (=the view settings) and gamemaker automatically resizes it for you. But if you draw directly to a surface that is screen sized (640x480) it will not. Also, if you draw in the GUI event you are also actually drawing to a screensized surface (640x480) so the same applies.

I solved my problem by calculating and applying the factor between the screen and view in order to adjust my draw function xposition, yposition, widthFactor and heightFactor. In GM:Studio I was able to calculate the factor with something like this:

--- Code: ---var factorW = display_get_gui_width()/view_wview[0];
--- End code ---

Edit: Solved.

--- Code: ---draw_circle(objLink.x+12/2-view_xview,objLink.y+27/2-view_yview,16,false);
--- End code ---
Thanks for taking the time to help, I really appreciate it!
Keep an eye out for a demo coming up.


[0] Message Index

[*] Previous page

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved

Go to full version