Decreasing Var's on hittest

  • Jummm
  • Novice
  • Novice
  • Jummm
  • Posts: 17

Post 3+ Months Ago

Im making a defense game, i have the defense (castle thing) on the right, i have my "enemy" going right, part of the enemys code is the folowing:

onClipEvent (load) {
_root.speed = 3;
}
onClipEvent(enterFrame){
if(this.hitTest(_root.defense))
{ _root.speed -= 2
} }
onClipEvent (enterFrame) {
this._x-=-speed

}

So i got my dude going right at 3 pixals every frame, "defense" is the instance of a movie clip on the main stage, its ment to be a trench to slow down enemys, but the enemys speed doesnt change once it touch's "defense"

Is the actionscript have a mistake init? wrong way round? It doesnt report any mistake when i test the game...

Help please
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

Code: [ Select ]
onClipEvent (enterFrame) {

this._x-=-_root.speed;

}
  1. onClipEvent (enterFrame) {
  2. this._x-=-_root.speed;
  3. }

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 4 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.