|
Post by thomas on Jan 12, 2006 0:24:56 GMT
Ever had troubles with hitTest?Well ok. First of all,create a MovieClip for your character.Give him whatever movement code you learned somewhere else,I don't care. Now create a separate onClipEvent(enterFrame) in the code to separate your hitTest from the other areas. First of all,use the hitTest 'if'. if(this.hitTest(blah)) Use 'this.' if your referring to your character as hitting something.Otherwise use... if(_root.item.hitTest(this)) There isn't to much difference,and I guess it doesn't matter which you use. Now,maybe your wondering why there are 2 )'s at the end of the hitTest.Well,that's because there is a set of ( ) inside of ( )'s.They both need an ending ). Now,you have an 'if'.You need to complete it with a 'then'. [glow=red,2,300]I was thinking while in my science class today...the AS 'if' is exactly like a simple science problem [/glow] Anyways,to create a 'then',just add { and }... if(_root.item.hitTest(this)){ //actions } There.Now where it says '//actions',retype it into your code.An example code would be... this.clear() ...which will make the MovieClip permanently disappear,unless you use attachMovie,which I will not be explain.So,your full code would be liek this... onClipEvent(enterFrame){ if(this.hitTest(_root.blah)){ this.clear() } } There are also other 'if' functions and other actions you can do with hitTest. Hope this helped
|
|