How can I make an object being executed on a selfmade surface

R

RealsLife

Guest
Instead of executing the object on the application surface I want to execute the object on my selfmade surface.

So this function for example point_in_rectangle(px, py, x1, y1, x2, y2); who checks for the x1,x2 ect...
I want it to search for coördinates inside the selfmade surface instead of the standard application surface.

How can I achieve this(Keep in mind that "point_in_rectangle(px, py, x1, y1, x2, y2);" could also be used in a step event" that's why I ask for a whole object being executed on another surface

Thanks in advance
~Reals
 

HayManMarc

Member
I don't think that's how surfaces work. All a surface is, is a canvas with stuff drawn on it. There are no objects on a surface.
 
in GML, the upper-left corner of a surface has coordinates (0,0). The bottom-right corner would have coordinates (surface_width, surface_height), where surface_width is the width of the surface, and surface_heigth is the height of the surface. Those two values are the ones you would supply into the surface_create function. If you don't know the size of the surface for some reason, then you can get it with the functions surface_get_width(surface_id) and surface_get_height(surface_id).

So if I wanted to know if a point cooresponds to a location in the upper left quadrant of a surface, i would do

point_in_rectangle(px,py,0,0,surface_width/2,surface_height/2);

You can draw images anywhere upon a surface, so I don't know what you mean by "execute the object on my selfmade surface". Where an image is located on the surface depends on where on the surface you draw it.
 
R

RealsLife

Guest
in GML, the upper-left corner of a surface has coordinates (0,0). The bottom-right corner would have coordinates (surface_width, surface_height), where surface_width is the width of the surface, and surface_heigth is the height of the surface. Those two values are the ones you would supply into the surface_create function. If you don't know the size of the surface for some reason, then you can get it with the functions surface_get_width(surface_id) and surface_get_height(surface_id).

So if I wanted to know if a point cooresponds to a location in the upper left quadrant of a surface, i would do

point_in_rectangle(px,py,0,0,surface_width/2,surface_height/2);

You can draw images anywhere upon a surface, so I don't know what you mean by "execute the object on my selfmade surface". Where an image is located on the surface depends on where on the surface you draw it.
Well let say I create an object without in mind that it would be for a different surface I use x and y coördinates everywhere, it was just a question about how can I use this object on a different surface without that the object looks at the x and y position of my application surface but the x & y of my created surface instead, I didn't want to overthink stuff and needing to change x and y coördinates within an object. For example if I say x = 50 in an object I want it to know that i'm talking about my surface I created and not but the object inside the application surface. On this moment it only draws the object on my application surface.

How do I know that?
My created surface works with a scrollbar so I can scroll a part of the surface and scroll the object content with it, the object content doesn't scroll so, it is probably drawn withing the application surface.

I've a few minutes ago finnaly been able to draw the object on my new surface or at least it's events... because of
event_perform_object(obj_game_controls,ev_create,0);
event_perform_object(obj_game_controls,ev_step,0);
event_perform_object(obj_game_controls,ev_draw,0);

The only thing is that the step event still works with the application surface, maybe surface aren't made with this in mind to be "easy to use & done"

in GML, the upper-left corner of a surface has coordinates (0,0). The bottom-right corner would have coordinates (surface_width, surface_height), where surface_width is the width of the surface, and surface_heigth is the height of the surface. Those two values are the ones you would supply into the surface_create function. If you don't know the size of the surface for some reason, then you can get it with the functions surface_get_width(surface_id) and surface_get_height(surface_id).

So if I wanted to know if a point cooresponds to a location in the upper left quadrant of a surface, i would do

point_in_rectangle(px,py,0,0,surface_width/2,surface_height/2);

You can draw images anywhere upon a surface, so I don't know what you mean by "execute the object on my selfmade surface". Where an image is located on the surface depends on where on the surface you draw it.
EDIT: Still doesn't work... even tried it with your solution.
 
Last edited by a moderator:
Top