Be a Supporter!

Sniper Game Spawning Error [as2]

  • 224 Views
  • 4 Replies
New Topic Respond to this Topic
JohnCamPro
JohnCamPro
  • Member since: Aug. 29, 2010
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Sniper Game Spawning Error [as2] 2010-12-14 20:58:34 Reply

Below is my script. Unfortunately the random function isn't doing it's job. Instead the variables "SpawnX" and "SpawnY" are staying at 0. Which I set them to a few frames back after declaring, but it never returns to that frame, so I don't get why this is happening. Anyone see anything that jumps out?

onClipEvent (load) {
_root._SpawnX = Math.random()*640+699
_root._SpawnY = Math.random()*6+447
this._x = _root.SpawnX;
trace (_root.SpawnX)
this._y = _root.SpawnY;
trace (_root.SpawnY)
speed = random(8)+1;
}

CyanSandwich
CyanSandwich
  • Member since: Aug. 14, 2009
  • Offline.
Forum Stats
Member
Level 41
Programmer
Response to Sniper Game Spawning Error [as2] 2010-12-14 21:11:27 Reply

I don't see anything wrong there. Give us more code or perhaps a .fla dump


BBS Signature
JohnCamPro
JohnCamPro
  • Member since: Aug. 29, 2010
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to Sniper Game Spawning Error [as2] 2010-12-14 21:26:46 Reply

Sure. This should work. I made a separate FLA with just the actions and just the enemy, for quite obvious reasons.

CyanSandwich
CyanSandwich
  • Member since: Aug. 14, 2009
  • Offline.
Forum Stats
Member
Level 41
Programmer
Response to Sniper Game Spawning Error [as2] 2010-12-14 23:01:26 Reply

Is there a particular reason you declared the variables on the first frame?
I got rid of the first frame actions and the _root's for the spawnX and spawnY variables and it worked.


BBS Signature
JohnCamPro
JohnCamPro
  • Member since: Aug. 29, 2010
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to Sniper Game Spawning Error [as2] 2010-12-14 23:34:54 Reply

Oh, well thanks! I really don't have much knowledge of AS2 I'll be honest but that's what my school's criteria demands. Most of what I know was taught by my brother or read from tutorials. Anyways. Thanks!