GMS 2 [Solved] Problem with surface_getpixel(surface_id, x, y)

Hi everyone

So I'm trying to create a simple colour picker. I'm using surface_getpixel(surface_id, x, y) to get the pixel
colour in the hue strip. This is my code:

Code:
col = surface_getpixel(application_surface,x,y);
And this is my error:


Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object obj_hue_picker:

Trying to use non-existing surface.
 at gml_Object_obj_hue_picker_Create_0 (line 3) - col = surface_getpixel(application_surface,x,y);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_hue_picker_Create_0 (line 3)
As far as I know, I don't need to check for the existence of the application_surface.
Also, I'm not using any other surfaces, at all.

Any help would be appreciated
 

chamaeleon

Member
Hi everyone

So I'm trying to create a simple colour picker. I'm using surface_getpixel(surface_id, x, y) to get the pixel
colour in the hue strip. This is my code:

Code:
col = surface_getpixel(application_surface,x,y);
And this is my error:


Code:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object obj_hue_picker:

Trying to use non-existing surface.
 at gml_Object_obj_hue_picker_Create_0 (line 3) - col = surface_getpixel(application_surface,x,y);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_hue_picker_Create_0 (line 3)
As far as I know, I don't need to check for the existence of the application_surface.
Also, I'm not using any other surfaces, at all.

Any help would be appreciated
Since this code is in the create event, keep in mind that the surface doesn't exist in a room until the first draw event has fired, in case this is a create event that is triggered by entering the room (or it being the first room).
 
Since this code is in the create event, keep in mind that the surface doesn't exist in a room until the first draw event has fired, in case this is a create event that is triggered by entering the room (or it being the first room).
Ok, well this makes sense.
Thank you very much.

Is there a post or something somewhere where I can find in which order things are happening?
 

chamaeleon

Member
Ok, well this makes sense.
Thank you very much.

Is there a post or something somewhere where I can find in which order things are happening?
The official (for lack of a better word) order in which event fire: Events
A thread about event order: https://forum.yoyogames.com/index.p...in-step-step-end-step-treated-time-wise.62682
You won't find one single place that explains the ramifications any given event has on any other thing. Like in the case of the application surface, you'll need to read its documentation as well to find out the reason why it didn't exist when the create event was running.
 
Top