Be a Supporter!

enemy gone wierd!

  • 257 Views
  • 1 Reply
New Topic Respond to this Topic
flailthefox
flailthefox
  • Member since: Aug. 30, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
enemy gone wierd! 2009-04-21 12:38:35 Reply

I made a simple enemy. 1 frame was him walkin, 1 frame was it attackin, and 1 was blank for when he died. In theory it ooked fine :S, but it wasn't.

Heres my code:

onClipEvent (load) {
speed = 0
movespeed = 1
damagenumber = 1
grav = 0
dead:Boolean = false
scale = _xscale;
}
onClipEvent (enterFrame) {
_x += speed
_y += grav
grav++
if (dead == true) {
this.gotoAndStop(3)
_y += 100
}
while (_root.ground.hitTest(_x, _y, true)) {
grav = 0
_y--
}
while (_root.ground.hitTest(_x+12, _y-18, true)) {
speed = 0
_x--
}
while (_root.ground.hitTest(_x-12, _y-18, true)) {
speed = 0
_x++
}
if (_root.guy._x > _x) {
        speed += 0.1
_x += movespeed
_xscale=+scale;
}
if (_root.guy._x < _x) {
        speed -= .1
_x -= movespeed
_xscale=-scale;
}
if (_root.guy.hitTest(_x, _y, true)) {
this.gotoAndStop(2)
_root.health -= damagenumber
} else {
this.gotoAndStop(1)
}
if (this.hitTest(_root.guy.att1)) {
this.gotoAndStop(3)
dead = true
}
if (this.hitTest(_root.guy.att2)) {
this.gotoAndStop(3)
dead = true
}
}

I got 3 errors:

Error 1: Syntax error on dead:Boolean = false
Error 2: "Statement must appear within on/ClipEvent handler" with scale - _xscale;
Error 3: "unexpected } encoiuntered" at the last line.

maybe i got the boolean wrong. :/
do i move the line with the error 2 up?
do i get rid of the }?

your input, please.


Destroyed.

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to enemy gone wierd! 2009-04-21 13:55:56 Reply

the only reason your getting the last to errors is because of your variable error. When declairing variables always add var to the start of it. ie:

var dead:Boolean = false
instead of
dead:Boolean = false

the reason you didint get a error with the others is because you need to 'make' the variable to assign it a value type (ie: Boolean, Number, String etc...)


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature