Guitarmike
Member
Hi,
I'm new to GML but not to programming. I'd like a little advice on best practices. I have a couple of objects in my game for which there is only a single instance and which need to be accessible from many other places around the game. For example, the obj_player and the obj_clock. Currently, to get the player's position in the room from an event in another object, I would do something like this:
Does it make sense, instead, to declare a global variable containing the player object's instance and then access it directly using some thing like
xx = global.player.x
I'm curious how this approach, which feels simpler and more readable, affects things like performance and memory. Or any other things I haven't thought of. Thanks.
I'm new to GML but not to programming. I'd like a little advice on best practices. I have a couple of objects in my game for which there is only a single instance and which need to be accessible from many other places around the game. For example, the obj_player and the obj_clock. Currently, to get the player's position in the room from an event in another object, I would do something like this:
Code:
var xx = 0;
var yy = 0;
with (obj_player)
{
xx = x;
yy = y;
}
...
xx = global.player.x
I'm curious how this approach, which feels simpler and more readable, affects things like performance and memory. Or any other things I haven't thought of. Thanks.