Windows why i get different image image_index value by two way

tomlee2020

Member
with(Obj_fen)
{fen=image_index;

}
show_debug_message(string(image_index))
i create OBJECT fen.
in Obj_fen i use draw_text fuctionto get image_index.
this is code :
var cx=camera_get_view_x(view_camera[0]);
var cy=camera_get_view_y(view_camera[0]);
var cw=camera_get_view_width(view_camera[0]);
draw_set_font(fen_ziti);
draw_set_color(c_red);

draw_text(cx+cw/2,cy+25,string(fen));
in output i get image_index.
but i get different image image_index value.

in output i can image_index value is
"
0
0.25
0.50
0.75
1
1.25
1.50
1.75 "
in draw_text i get image_index
{1,2 ,3 4, 5, 6, 7, 8, 9,10..............................
It keeps going on forever
}
who can tell me which one is right?
新.jpg新11.jpg新31.jpg
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
Your "with" is incorrectly formatted. If you want the image_index of the "my_plane" object it should be:

GML:
with (obj_Fen)
{
fen = other.image_index;
}
Using "with" you are changing the scope of the code to the "fen" object, and so you're getting the "fen" image_index and not the "my_plane" one. Using "other" tells GM to use the image_index from the "other" object in the code, the one that is running the "with", not the one targeted by "with". See here for more information: https://manual.yoyogames.com/GameMaker_Language/GML_Overview/Language_Features/with.htm
 
Top