Sadly this did not help me with my problem, but there is no denying that this is an extremely well made and informative tutorial. I hope you continue making such great videos in the future. 10/10
Yep, perfectly valid. obj_player's Collision Event with obj_bullet: hp -= 5; // player instance's hp with (other) { // other now changes the scope to the colliding bullet instance instance_destroy(); // the bullet instance gets destroyed }
Also, going with his obj_with_statement example: with (my_inst) { // scope is changed to the obj_white_dot instance show_debug_message(object_get_name(object_index)); // from the my_inst scope, this will output "obj_white_dot" show_debug_message(object_get_name(other.object_index)); // from the my_inst scope, other refers back to obj_with_statement and will output that with (other) { // scope is changed further to other ... i.e., scope is changed to obj_with_statement show_debug_message(object_get_name(object_index)); // from the obj_with_statement scope, this will output "obj_with_statement" show_debug_message(object_get_name(other.object_index)); // from the obj_with_statement scope, other refers back to obj_white_dot and will output that } }
I just want to say that this function can be very dangerous... It can cause performance issues really fast , also there are better workarounds for this function, I suggest only to use it when its impossible not to. Simply because it is also very hard to debug if you have lot of objects or running it all the time.
Are you referring to the with statement? The with statement is in general the fastest way to check multiple instance of an object, and in some cases even the fastest way to deal with referencing a single instance of an object (some people who have tested it have reported it as being faster for them even than the dot accessor with an instance id).
It might depend as well on which platform your using, but on PC using the VM with outperforms the . accessor by a fair bit while in the yyc build the . accessor is faster for a single variable and the with statement is faster for multiple using the code here: forum.yoyogames.com/index.php?threads/about-with-statement-performance.48829/
Sadly this did not help me with my problem, but there is no denying that this is an extremely well made and informative tutorial. I hope you continue making such great videos in the future. 10/10
Couldn't find a better tutorial on this topic. Clear points, easy to follow, and with helpful examples. Thank you for this.
These are very high quality. Subscribed.
Great Video
really helpful! thank you!
Worth noting that local variables declared prior to the with statement will still be in scope inside the with statement.
what if i make an object and i wanna add a variable to it
what about with (other)?
Yep, perfectly valid.
obj_player's Collision Event with obj_bullet:
hp -= 5; // player instance's hp
with (other) { // other now changes the scope to the colliding bullet instance
instance_destroy(); // the bullet instance gets destroyed
}
Also, going with his obj_with_statement example:
with (my_inst) { // scope is changed to the obj_white_dot instance
show_debug_message(object_get_name(object_index)); // from the my_inst scope, this will output "obj_white_dot"
show_debug_message(object_get_name(other.object_index)); // from the my_inst scope, other refers back to obj_with_statement and will output that
with (other) { // scope is changed further to other ... i.e., scope is changed to obj_with_statement
show_debug_message(object_get_name(object_index)); // from the obj_with_statement scope, this will output "obj_with_statement"
show_debug_message(object_get_name(other.object_index)); // from the obj_with_statement scope, other refers back to obj_white_dot and will output that
}
}
I just want to say that this function can be very dangerous... It can cause performance issues really fast , also there are better workarounds for this function, I suggest only to use it when its impossible not to. Simply because it is also very hard to debug if you have lot of objects or running it all the time.
Are you referring to the with statement? The with statement is in general the fastest way to check multiple instance of an object, and in some cases even the fastest way to deal with referencing a single instance of an object (some people who have tested it have reported it as being faster for them even than the dot accessor with an instance id).
It might depend as well on which platform your using, but on PC using the VM with outperforms the . accessor by a fair bit while in the yyc build the . accessor is faster for a single variable and the with statement is faster for multiple using the code here: forum.yoyogames.com/index.php?threads/about-with-statement-performance.48829/