Jump to content


Photo

Create Instance Problem


  • Please log in to reply
10 replies to this topic

#1 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 03 January 2008 - 02:52 AM

I've made a button so when you press on it, it makes an object, but when ever i press it it makes more than 1. its always a random number of the object. if your still not understanding what i mean is when i press my button its suppose to make 1 object but instead it makes 34 objects.

heres the code I'm using:

Left Pressed (Mouse)

instance_create(x,y,object)

i hope you can help me


heres the file (.gmk)

Posted Image

its an rts just for your information

Controls:
left click - select unit/buillding (units do not have a select circle)
right click - move selected units to point

note. there is a number below the castle which is the number of people.

Edited by rude guss, 03 January 2008 - 04:13 AM.

  • 0

#2 Lukearentz

Lukearentz

    My Two Cents

  • New Member
  • 2587 posts

Posted 03 January 2008 - 02:54 AM

Put in Stepevent
if mouse_check_button_pressed(mb_left)
{
instance_create(x,y,object)
}


Or Change Left Button to Left Pressed.

Edited by Lukearentz, 03 January 2008 - 02:55 AM.

  • 0

#3 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 03 January 2008 - 03:03 AM

I tried both of those and its still happening.

thanks for the help anyway.
  • 0

#4 templargfx

templargfx

    GMC Member

  • GMC Member
  • 1948 posts

Posted 03 January 2008 - 03:06 AM

//CREATE EVENT
pressed = 0;

//STEP
if (mouse_check_button_pressed(mb_left) == true)
  {
  if (pressed == 0)
    {
    instance_create(x,y,object);
    pressed = 1;
    }
  }
if (mouse_check_button_released(mb_left) == true)
  {
  if (pressed == 1)
    {
    pressed = 0;
    }
  }

that should ensure only 1 is created
  • 0

#5 james mihaly

james mihaly

    GMC Member

  • GMC Member
  • 341 posts

Posted 03 January 2008 - 03:10 AM

Then try the event LEFT RELEASE or LEFT BUTTON.
  • 0

#6 Lukearentz

Lukearentz

    My Two Cents

  • New Member
  • 2587 posts

Posted 03 January 2008 - 03:14 AM

Can you post your Gmk or Gm6. So we can see it not working? Or what your doing
  • 0

#7 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 03 January 2008 - 03:15 AM

//CREATE EVENT
pressed = 0;

//STEP
if (mouse_check_button_pressed(mb_left) == true)
  {
  if (pressed == 0)
    {
    instance_create(x,y,object);
    pressed = 1;
    }
  }
if (mouse_check_button_released(mb_left) == true)
  {
  if (pressed == 1)
    {
    pressed = 0;
    }
  }

that should ensure only 1 is created

<{POST_SNAPBACK}>


i tried that and it still didnt work :lol:


Lukearentz: ill post the file

EDIT: ive posted the file. check the first post.

Edited by rude guss, 03 January 2008 - 03:23 AM.

  • 0

#8 Lukearentz

Lukearentz

    My Two Cents

  • New Member
  • 2587 posts

Posted 03 January 2008 - 04:05 AM

I found it.. uploading now
http://arentzongmc.g...rts_problem.gmk

Should Be Fixed... In the castle step event you made it make heaps of object7 on top of eachother. That means u only see one so when u click it u see one but Gm clicks all of the hundreds at once :lol:.. That is why.

Edited by Lukearentz, 03 January 2008 - 04:07 AM.

  • 0

#9 jzone

jzone

    GMC Member

  • New Member
  • 298 posts

Posted 03 January 2008 - 04:06 AM

Ok I fixed it. Simple. In object6 step even add and if statement before you create instance of object7.
The if statement should be if image_index = 0.
What is happening is when you select the castle, it is constantly greating the object7 (button) so when you click it you are actually clicking several buttons at once.
:lol: Hope that helps you.
  • 0

#10 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 03 January 2008 - 04:09 AM

Thanks Jzone and lukearentz
  • 0

#11 jzone

jzone

    GMC Member

  • New Member
  • 298 posts

Posted 03 January 2008 - 04:10 AM

No problem any time.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users