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 on the random labeled frame:Code:if (_root.guy.hitTest(this)) { gotoAndPlay ("random");
78=highkick, 112=highpunch....... (yeah I know, why dont I use labels instead of numbers??... donnoCode:f = [78, 112, 134, 172]; r = random(4); frame=f[r]; gotoAndPlay(frame);)
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)
I had to put this code on ALL the frames in a row otherwise when guy kicks or punches the badguy, nothing happends.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"); }
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




)
Reply With Quote