HitTest problem

  • perloader
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Oct 28, 2007
  • Posts: 10
  • Status: Offline

Post October 28th, 2007, 7:23 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 28th, 2007, 7:23 am

  • perloader
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Oct 28, 2007
  • Posts: 10
  • Status: Offline

Post October 29th, 2007, 12:35 am

PLEASE HELP !
  • perloader
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Oct 28, 2007
  • Posts: 10
  • Status: Offline

Post October 29th, 2007, 7:32 am

does anyone knows?
  • zhaojany
  • Student
  • Student
  • User avatar
  • Joined: Aug 03, 2006
  • Posts: 78
  • Status: Offline

Post November 3rd, 2007, 7:32 pm

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
  • Joined: Nov 05, 2004
  • Posts: 1254
  • Loc: Ro
  • Status: Offline

Post November 5th, 2007, 10:52 pm

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; }
“True mastery transcede any particular art. It stems from mastery of oneself - the ability, developed throgh self-discipline, to be calm, fully aware, and complety in tune with oneself and the surroundings. Then, and only then, can a person know himself. ”

Post Information

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

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.