with statement

  1. T

    SOLVED using 'with' to grab child objects

    Hello all, I'm attempting to put all 'Event Cards' into one randomized list. each Event Card is a manually created object. From reading the help on 'with' statements, as well as googling around, this is what I came up with: I made an object 'oEventCardParent,' and made it the parent of all...
  2. S

    GMS 2 Placing game piece in relation to game board

    I'm trying to build a board based game where you move pieces around on a board. I want the piece to be locked to a grid based on the board. In the current version of the game, it crashed as soon as it loads up. Here's the error: ___________________________________________...
  3. A

    Legacy GM with (other) not working properly

    I have an projectile and I have an enemy in the enemy's step event I try to make it so that if it touches a projectile it supposed to: -lose a point of health -destroy the instance of the projectile var hit = place_meeting (x,y,obj_player_projectile) if (hit) { enemyhealth -=1; with...
  4. atmobeat

    What exactly is the With-statement doing behind the scenes?

    Greetings GameMakers! I'm curious what exactly the with statement is doing behind the scenes. Is what is going on behind the scenes in GMS2 when we use "with(obj_pushable)" amount to looping through all instances and checking if object_index == obj_pushable? Then how does it make each instance...
  5. P

    GML SOLVED: Drawing A Surface Onto Another Surface From Another Object

    Hi all, I know it's possible to create a surface in an object and then use the with() function to draw multiple other objects onto that surface whilst it's targeted, and have managed to use this successfully. However, in an attempt to optimise my draw pipeline I was hoping I could do the...
  6. KPJ

    GMS 2 With statement help (GMS2)

    Hi everyone! I need help with the "with" statement in gms2. I am making a top down game, and I want it to be so that if the player gets in the enemies field of view, the enemy's state will be "alerted". However, I also wanted all other enemies that were within clear view to be "alerted" as well...
  7. foreverisbetter

    Question - Code anyone has problems with variables in a with statement?

    I've come across a strange bug - at least it seems to be a bug - in which the x and y variables of an instance within a with statement return the values of the actual current instance - not the instance the with statement refers to. Has anyone else had the same experience? My IDE is...
  8. G

    GMS 2 [Solved] - how to set new object variables using with statement

    Player creates an enemy seeking bullet that tracks down an enemy. The code to choose a target enemy is within the player object. I want to set the bullet's target (enemy id) when the bullet is created from within the player object. From within the player object, if I use something like this...
  9. kjagrpk908

    GMS 2 About with() statement performance

    I hope to know with() statement performance. Whitch should I use case1 or case2? (for performance up) Case1: //---------------------------------------- oOBJ.x = oOBJ.x + 1; //--------------------------------------- Case2: //--------------------------------------- with(oOBJ) { x = x +...
  10. Y

    Shaders How to/ is it possible to temporarily apply a shader to an object through a with statement?

    So I have a cursor object and when it hovers over any object that is a child of "selectable" I want the object to have a outline around it. The way I would like to accomplish this is through a with statement located in the cursor object that applies a shader to the object it is hovering over...
  11. Le Slo

    GMS 2 With statement and child objects

    Hello! I've been having troubles I don't really understand with the with statement and object parenting. Here is what I have: -An obj_laser. -An obj_laserAttack (child object of obj_laser). So, I need to save the positions of those objects, and for that I use the following to save the...
  12. N

    Legacy GM With but not self.

    Hi, this doesn't work: with (obj_projectile(not self)) instance_destroy(); Can someone please give advise?? Thank you!
  13. RyanC

    Legacy GM Question about the with() statment

    Hi Guys, I often use the with(obj_something) statement and was wondering if anyone knows what kind of performance hit there is if the obj_something does not exists in the game. for example lets say obj_enemy_1 does not exist in the game yet. would these two functions have the same performance...
  14. D

    GML "With" priority?

    Hello. I have a question regarding the with construction. When you create an object with the with construction, does the code within the with construction or the objects create event code occur first? An example would be if there was an object named objThing. This is the create event code of...
  15. T

    GML "with()" exits while loop

    Good evening. I have a while loop, supposed to generate a specified amount of objects. It runs fine unless i try to pass in a property with the with() method. If i do so, there is just one object created, and the while loop seems to be stopped. here is my code: particleAmount = 50; this runs...
  16. kraifpatrik

    Shaders Depth ordered with statement

    Hey everyone, throughout the time working with shaders in GM, I've found it convenient to set the visible property of all objects that I want to apply a shader on to false and then simply draw the objects in a single renderer object with shader_set(myShader); with (myObject) { // draw...
  17. R

    Instance create layer issue

    Hello, I'm new to Game Maker and I'm trying to figure out how to create an attack. I have it set so that when the F key is pressed there is a new instance of the attack object. But when this happens there are two attack objects that are formed. One is in the correct place and goes through the...
  18. Paskaler

    GML Strange behaviour with "with" statement

    I've been messing about trying to implement a spin-off of entity component system inside of game maker. A strange bug started appearing which didn't exist before, even tough I haven't touched any of the code, which I believe is relevant, in quite a while. Anyway, here's the error: It's...
  19. S

    With statement not working? (SOLVED)

    Hello everyone, I had this one issue for a while and can not figure out what the problem is. if txt == Answer { with (Targeted object) { destroy = true } } I insert this into a "Press Enter" event and nothing happens. I have tested to see if all the variables are the correct values and they...
Top