Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error?! duplicating and hittest

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi everyone................


On the stage there are two MC`s.
One is called user
The other one is called block
If user intersect with the block, it should stop!

The script is in a third MC off stage!

I think there is a syntax problem in the hittest line!


--------------------------------------------------------------------------------
onClipEvent (load) {
while (d<3) {
d = d+1;
duplicateMovieClip (&quot;_root.block&quot;, &quot;block_new&quot; + d, d);
with (&quot;block_new&quot; + d) {
setProperty (&quot;_root.block_new1&quot;, _x, 400);
setProperty (&quot;_root.block_new1&quot;, _y, 100);
setProperty (&quot;_root.block_new2&quot;, _x, 500);
setProperty (&quot;_root.block_new2&quot;, _y, 250);
setProperty (&quot;_root.block_new3&quot;, _x, 200);
setProperty (&quot;_root.block_new3&quot;, _y, 250);
}
}
}
---------------------------Duplicating block and contolling User works fine



onClipEvent (load) {
while (d<3) {
d = d+1;
duplicateMovieClip (&quot;_root.block&quot;, &quot;block_new&quot; + d, d);
with (&quot;block_new&quot; + d) {
setProperty (&quot;_root.block_new1&quot;, _x, 400);
setProperty (&quot;_root.block_new1&quot;, _y, 100);
setProperty (&quot;_root.block_new2&quot;, _x, 500);
setProperty (&quot;_root.block_new2&quot;, _y, 250);
setProperty (&quot;_root.block_new3&quot;, _x, 200);
setProperty (&quot;_root.block_new3&quot;, _y, 250);
}
}
}


onClipEvent (enterFrame) {
if (key.isDown(Key.DOWN)) {
if (_root.block_new + d.hitTest(_root.user._x, (_root.user._y+50), true) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _y, (getProperty(_root.user, _y))+50);
}
}
if (key.isDown(Key.UP)) {
if (_root.block_new + d.hitTest(_root.user._x, (_root.user._y-50), true) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _y, (getProperty(_root.user, _y))-50);
}
}
if (key.isDown(Key.LEFT)) {
if (_root.block_new + d.hitTest((_root.user._x-50), _root.user._y, true) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _x, (getProperty(_root.user, _x))-50);
}
}
if (key.isDown(Key.RIGHT)) {
if (_root.block_new + d.hitTest((_root.user._x+50), _root.user._y, true) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _x, (getProperty(_root.user, _x))+50);
}
}
}


thanks
Marc
 
hi

what's in the user mc? davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
ahah, am I right in thinking that you forgot to mention that you have the mc &quot;user&quot; controlled by the arrow keys and you're using the above as collision detection? davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
maybe not then davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
got it now davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
very long winded, but it works

if (key.isDown(Key.DOWN)) {
if (((_root.block_new1.hitTest(_root.user._x, (_root.user._y+50), true))or(_root.block_new2.hitTest(_root.user._x, (_root.user._y+50), true)) or(_root.block_new3.hitTest(_root.user._x, (_root.user._y+50), true)) ) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _y, (getProperty(_root.user, _y))+50);
}
}
if (key.isDown(Key.UP)) {
if (((_root.block_new1.hitTest(_root.user._x, (_root.user._y-50), true))or(_root.block_new2.hitTest(_root.user._x, (_root.user._y-50), true)) or(_root.block_new3.hitTest(_root.user._x, (_root.user._y-50), true)) ) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _y, (getProperty(_root.user, _y))-50);
}
}
if (key.isDown(Key.LEFT)) {
if (((_root.block_new1.hitTest(_root.user._x-50, (_root.user._y), true))or(_root.block_new2.hitTest(_root.user._x-50, (_root.user._y), true)) or(_root.block_new3.hitTest(_root.user._x-50, (_root.user._y), true)) ) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _x, (getProperty(_root.user, _x))-50);
}
}
if (key.isDown(Key.RIGHT)) {
if (((_root.block_new1.hitTest(_root.user._x+50, (_root.user._y), true))or(_root.block_new2.hitTest(_root.user._x+50, (_root.user._y), true)) or(_root.block_new3.hitTest(_root.user._x+50, (_root.user._y), true)) ) ne &quot;true&quot;) {
setProperty (&quot;_root.user&quot;, _x, (getProperty(_root.user, _x))+50);
}
}

dave davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
hi dave,

thanks for your help!
but in the real game i have to place 33 blocks!! :(
I have to find a solution with +d

mt
 
LOL nice one, I was hoping you wouldn't say that! I'll have a look at it further after work.

How about registering with tek-tips? davdesign@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top