Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.18 / 5.00 3,534 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.80 / 5.00 4,200 ViewsI 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.
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...)