HitTest problem

  • perloader
  • Newbie
  • Newbie
  • perloader
  • Posts: 10

Post 3+ Months Ago

i ve tired 2 different codes just making my rock go left to the right either way right to the left when it hit the blackL _mc or blackR_mc bar but doesnt work is there something wrong with my code?PLEASE HELP

1,

var MOVE_LEFT:Number = -5;
var MOVE_RIGHT:Number = 5;
var current_direction:Number = MOVE_LEFT;

function moveRock():Void {
this.rock_mc._x = this.rock_mc._x+current_direction;
if (this.rock_mc_.x<0) {
current_direction = MOVE_RIGHT;
rock_mc.gotoAndStop("right");
} else if (this.rock_mc._x>550) {
current_direction = MOVE_LEFT;
rock_mc.gotoAndStop("left");
}
}

2.This one when hit the movie clip it will turn to the right but not what i want to be , i want hit the bar.

function moveRock():Void {
this.rock_mc._x = this.rock_mc._x-10;
//for(i:Number=0;i<495;i+)
if (this.rock_mc.hitTest(_root.blackL_mc)) {
this.rock_mc._x = 500;

}
}
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • perloader
  • Newbie
  • Newbie
  • perloader
  • Posts: 10

Post 3+ Months Ago

PLEASE HELP !
  • perloader
  • Newbie
  • Newbie
  • perloader
  • Posts: 10

Post 3+ Months Ago

does anyone knows?
  • zhaojany
  • Student
  • Student
  • User avatar
  • Posts: 79

Post 3+ Months Ago

Not so clear about what you said :(
And in the second code block you said "hit the movie clip ". What dose it refer to by the "movie clip"? the rock?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

not exactly sure what you really want, but you may try to chang your code into this:
Code: [ Select ]
if (this.rock_mc.hitTest(_root.blackL_mc)) {
  this.rock_mc._x = _root.blackL_mc._x - this.rock_mc._width; }
  1. if (this.rock_mc.hitTest(_root.blackL_mc)) {
  2.   this.rock_mc._x = _root.blackL_mc._x - this.rock_mc._width; }

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 27 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.