A Flash Developer Resource Site

Results 1 to 20 of 410

Thread: Optimization Tips

Threaded View

  1. #11
    Amiga freak Ironclaw's Avatar
    Join Date
    Jan 2001
    Location
    Sweden
    Posts
    1,650
    I wish I know as much as all of you do. My game could without doubt be xx% faster. Most of the code I'm using are so clumsy.

    In one of my badguy MCs I have on the first keyframe this code which loops till it hits the "guy" (the hero), when guys is hitted it goes to the labeled frame "random"

    keyframe 1 that loops:
    Code:
    if (_root.guy.hitTest(this)) {
    	gotoAndPlay ("random");
    code on the random labeled frame:

    Code:
    f = [78, 112, 134, 172];
    	r = random(4);
            frame=f[r];
    	      gotoAndPlay(frame);
    78=highkick, 112=highpunch....... (yeah I know, why dont I use labels instead of numbers??... donno )


    I have a little problem which I have solved but I think it can be made much shorter. You see all the keyframes in a row marked green...[attached picture).. All of them are the same, they are just copied. The code on one of them are: (the same for all of them)
    Code:
    if (_root.guy.highkick.highkick.hitTest(this)) {
    	this.scores.gotoAndPlay("score100");
    	scores._xscale=this._xscale;
    	_root.panel.score += 100;
    	gotoAndPlay ("death4");
    	
    } else if (_root.guy.lowkick.lowkick.hitTest(this)) {
    	this.scores.gotoAndPlay("score100");
    	scores._xscale=this._xscale;
    	_root.panel.score += 100;
    	gotoAndPlay ("death3");
    	
    } else if (_root.guy.punch.punch.hitTest(this)) {
    	this.scores.gotoAndPlay("score200");
    	scores._xscale=this._xscale;
    	_root.panel.score += 200;
    	gotoAndPlay ("death1");
    	
    } else if (_root.guy.lowpunch.lowpunch.hitTest(this) and _root.score eq 1000000) {
    	gotoAndPlay ("nutpunch");
    	
    } else if (_root.guy.lowpunch.lowpunch.hitTest(this)) {
    	_root.panel.score -= 100;
    	this.scores.gotoAndPlay("score-100");
    	scores._xscale=this._xscale;
    	gotoAndPlay ("nutpunch");
    	
    } else if (_root.guy.jumpkick.jumpkick.hitTest(this) and _root.bonus eq 12) {
    	this.scores.gotoAndPlay("score5000");
    	scores._xscale=this._xscale;
    	_root.bonusmc.gotoAndPlay(2)
    	_root.bonus = 0
    	_root.panel.score += 5000
    	gotoAndPlay ("death2");
    
    } else if (_root.guy.jumpkick.jumpkick.hitTest(this)) {
    	this.scores.gotoAndPlay("score300");
    	scores._xscale=this._xscale;
    	_root.bonus += 1;
    	_root.panel.score += 300;
    	gotoAndPlay ("death2");
    	
    } else if (_root.killallenemies=="on") {
    	gotoAndStop ("kill");
    }
    I had to put this code on ALL the frames in a row otherwise when guy kicks or punches the badguy, nothing happends.



    If anyone of you understand what I mean (I know I don't), please explain how to only use this code once instead of alot of keyframes in a row..



    ehh, thanks
    Attached Images Attached Images
    Last edited by Ironclaw; 04-27-2003 at 04:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center