Jump to content


Photo

more than one instance in the same room


  • Please log in to reply
3 replies to this topic

#1 trexx

trexx

    GMC Member

  • New Member
  • 151 posts

Posted 03 March 2012 - 06:12 PM

i have a tank game where the tanks are two different objects. the body of the tank and the turret. i have the turret rotate toward the mouse and then i have this code in the end step event to keep the two objects together
o_topplayer.x=o_bottomplayer.x
o_topplayer.y=o_bottomplayer.y
i have the same code for the enemy tanks as well. but if i have two of the same enemy tanks then when i put in this code for them, both of the enemy tanks' turrets are on one tank. do i have to make a separate tank for every enemy i want to put into the room?
  • 0

#2 niiiiick

niiiiick

    GMC Member

  • New Member
  • 35 posts
  • Version:GM:Studio

Posted 03 March 2012 - 06:50 PM

With the current way you have the code set up, you would have to have different objects for each enemy. This can be fixed by trying to combine the two objects into one object instead of placing two objects on top of one another. For example, in the step event you could use draw_sprite_ext to draw the turret on top of the tank and rotate it towards the mouse.
  • 0

#3 trexx

trexx

    GMC Member

  • New Member
  • 151 posts

Posted 03 March 2012 - 08:47 PM

With the current way you have the code set up, you would have to have different objects for each enemy. This can be fixed by trying to combine the two objects into one object instead of placing two objects on top of one another. For example, in the step event you could use draw_sprite_ext to draw the turret on top of the tank and rotate it towards the mouse.

but when i do this it does the same thing and draws both of the turrets ontop of one tank
  • 0

#4 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2297 posts
  • Version:GM7

Posted 03 March 2012 - 09:26 PM

Nope, you don't need a separate tank type. Just use instance_create's id return.

theTurret = instance_create(x,y,o_topplayer) // this is in the o_bottomplayer's create code

and in the o_bottomplayer's endstep

theTurret.x = x
theTurret.x = y

Keep in mind, when the tank explodes, you need to do

with (theTurret)
{
instance_destroy
}

Edited by greep, 03 March 2012 - 09:27 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users