Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Setting a delay on a "Create an Object"  (Read 1706 times)

0 Members and 1 Guest are viewing this topic.

Dark-Hylian

Silence
Setting a delay on a "Create an Object"
« on: February 04, 2010, 02:25:14 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
Probably really simple, but I've spun my wheels on this for the past two hours with no progress.
It's a simple, if objLink collides with objRing, it creates objBolt, which moves towards objLink, all well and good. However, it shoots WAAAY too many. Is there a way to shoot one every second or two?
Logged
  • Dawning Hour

Xiphirx

wat
Re: Setting a delay on a "Create an Object"
« Reply #1 on: February 04, 2010, 02:36:38 am »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Alarms on your collision event with the linkObj

Need more explaining?
Logged
  • For The Swarm
Re: Setting a delay on a "Create an Object"
« Reply #2 on: February 04, 2010, 07:09:26 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Like Xiphirx said use a delay timer. Either with alarm events or a variable that decreases every step.

In the step event:
Code: [Select]
if( delay_timer ){
     delay_timer -= 1;
}

at the point of collision with Link.
Code: [Select]
if( !delay_timer ){
      //create a bolt towards Link.
      delay_timer = 60; //assuming 30fps
}
Logged

Dark-Hylian

Silence
Re: Setting a delay on a "Create an Object"
« Reply #3 on: February 04, 2010, 11:56:01 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
using those codes in the step and collision events for the boundary (the area where when inside, you get shot at), it will shoot one, then stop. Any help?
Logged
  • Dawning Hour
Re: Setting a delay on a "Create an Object"
« Reply #4 on: February 04, 2010, 01:38:10 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Link is still in the area after getting shot at? And you have reset the delay_timer? And you are decreasing it again?
Logged

Xiphirx

wat
Re: Setting a delay on a "Create an Object"
« Reply #5 on: February 04, 2010, 08:18:25 pm »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Yeah, you sure you included "delay = 60;" after creating the bolt?

Otherwise you might want to try something like

Step:
Code: [Select]
if (delayTimer > 0) { delayTimer -= 1;}
if (delayTimer <= 0 && collidedWLink = 1)
{
//Create bolt
delayTimer = 60;
}

Collision:
Code: [Select]
collidedWLink = 1;

//When link leaves:
collidedWlink = 0;
« Last Edit: February 04, 2010, 08:21:33 pm by Xiphirx »
Logged
  • For The Swarm
Re: Setting a delay on a "Create an Object"
« Reply #6 on: February 04, 2010, 08:58:59 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
I took a look at the Gamemaker help files and found this:

Quote
When the other object is not solid, the instance is not put back. The event is simply executed with the instance at its current position. Also, there is no second check for a collision. If you think about it, this is the logical thing that should happen. Because the object is not solid, we can simply move over it. The event notifies us that this is happening.

I assume that objRing is not a solid object and thus when Link stays collided no collision event is generated again, until they uncollide. Thus the best thing you can do is put this in the objRing step event and dumb the collision event.

Code: [Select]
if( !delayTimer && place_meeting(x,y,objLink){
     //Send the bolt.
     delayTimer =60;
}else if(delayTimer){
     delayTimer -= 1;
}
Logged

Dark-Hylian

Silence
Re: Setting a delay on a "Create an Object"
« Reply #7 on: February 06, 2010, 05:46:37 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 370
Got it to work, thanks all  XD
Logged
  • Dawning Hour
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.63 seconds with 54 queries.

anything