Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 11-19-2009, 01:45 AM   #1
luekil
Registered User
 
luekil's Avatar
Adding delay to actions

Hi everyone, I am making a platformer game and I would be really thankful if someone could tell me how to add a delay to the attack button of the character. Right now you are able to leave the button pressed and the character stays on the attacking animation and you can simply do that to destroy everything, so at least having to press again to make the attack animation happen again would also be perfect.

Thanks for your time and sorry for such probably simple question....

~~

__________________
Enjoy life ~~~~
luekil is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-19-2009, 01:51 AM   #2
adBuryD
Registered User
Hi
you can use set interval for an action to be performed every defined interval. or create a number var, increment it and say onenterframe if the var == 3,6,9 and so on perform the action.
but i dont think this is how you want the script to be so if you could post the part of onpress of the movieclip and function it call i might be able to help
adBuryD is offline   Reply With Quote
Old 11-19-2009, 08:51 AM   #3
luekil
Registered User
 
luekil's Avatar
Well what I want to add the delay to is this:

if (Key.isDown(65)){
this.gotoAndStop("attack");

Dunno if thats what you meant that I posted or you need more info .
And thanks for your reply

__________________
Enjoy life ~~~~
luekil is offline   Reply With Quote
Old 11-19-2009, 09:52 AM   #4
Swooter
Swooter - AS/JS/HTML/CSS
 
Swooter's Avatar
Try this code:

ActionScript Code:
var $interval = 500; // 0.5 seconds
var $timer = 0;
var $canShoot = true;

if (Key.isDown(65)) {
  if ( $canShoot ) {
    this.gotoAndStop("attack");
    $canShoot = false;

    clearTimeout($timer);
    $timer = setTimeout(function() {
      $canShoot = true;
    }, $interval);
  }
}

__________________

AS / JS / HTML / CSS / PHP
Swooter is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:32 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com