-
Limited movement (till certain position only)
Hi, I use standard code for Movie_Clip movement:
onClipEvent (enterFrame) {
if(Key.isDown(Key.RIGHT)) {
_x += 10;
}
}
But in that case, MC can move unlimited and continue to move out of the screenview. Is there some code for limited move, till certain position only? For example, when MC arrives to position _x=200, it can not move any more in that direction, it just can come back. So, it could move in _x(+) direction only when _x<200.
-
Senior Member
_x = Math.min (200, _x + 10);
-
It works nice. Thanks.
onClipEvent (enterFrame) {
if(Key.isDown(Key.RIGHT)) {
_x = Math.min (200, _x + 10);
}
}
-
For limited movement, between point 20 and point 200, code is:
onClipEvent (enterFrame) {
if(Key.isDown(Key.RIGHT)) {
_x = Math.min (200, _x + 10);
}
if(Key.isDown(Key.LEFT)) {
_x = Math.max (20, _x - 10);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|