06-22-2006, 01:54 AM
Welcome back to the Continued Tutorial How to make Movable items
in this tutorial ill give 2 examples of moving items,
1 Moving a item by htting it(like in in RAX II)
2 Moving a item with the mouse by "dragging it" (just the basics)
we'll start with the first one
first of all you must of done the 2 previous tutorials
which can be found here:
first one:
http://graphicsfans.createmybb.com/showt...php?tid=23
Second one:
http://graphicsfans.createmybb.com/showt...php?tid=44
then (if u didnt do this yet) give the character a name (same as the wall thing)
lets call it "char" to keep things simple
then draw a box or something thats looks like an item
also give it a name, also to keep it simple name it: "box"
and now on the box: right click->actions
put in:
now this is kindof buggy cause u can push your item out of a wall so we'll
handle that right now:
same as in the character, give these actions also to the box
under
and above
put this:
so the complete code of the box will be:
thats Tutorial 1
Will be continiued, have to eat for a sec(ill edit the post)
in this tutorial ill give 2 examples of moving items,
1 Moving a item by htting it(like in in RAX II)
2 Moving a item with the mouse by "dragging it" (just the basics)
we'll start with the first one
first of all you must of done the 2 previous tutorials
which can be found here:
first one:
http://graphicsfans.createmybb.com/showt...php?tid=23
Second one:
http://graphicsfans.createmybb.com/showt...php?tid=44
then (if u didnt do this yet) give the character a name (same as the wall thing)
lets call it "char" to keep things simple
then draw a box or something thats looks like an item
also give it a name, also to keep it simple name it: "box"
and now on the box: right click->actions
put in:
Code:
onClipEvent (enterFrame) {
while (_root.char.hitTest(getBounds(_root).xMax, this._y, true)) {
this._x--;
}
while (_root.char.hitTest(getBounds(_root).xMin, this._y, true)) {
this._x++;
}
while (_root.char.hitTest(this._x, getBounds(_root).yMax, true)) {
this._y--;
}
while (_root.char.hitTest(this._x, getBounds(_root).yMin, true)) {
this._y++;
}
}
now this is kindof buggy cause u can push your item out of a wall so we'll
handle that right now:
same as in the character, give these actions also to the box
under
Code:
while (_root.char.hitTest(this._x, getBounds(_root).yMin, true)) {
this._y++;
}
and above
Code:
}
put this:
Code:
while (_root.wall.hitTest(getBounds(_root).xMax, this._y, true)) {
this._x--;
}
while (_root.wall.hitTest(getBounds(_root).xMin, this._y, true)) {
this._x++;
}
while (_root.wall.hitTest(this._x, getBounds(_root).yMax, true)) {
this._y--;
}
while (_root.wall.hitTest(this._x, getBounds(_root).yMin, true)) {
this._y++;
}
so the complete code of the box will be:
Code:
onClipEvent (enterFrame) {
while (_root.char.hitTest(getBounds(_root).xMax, this._y, true)) {
this._x--;
}
while (_root.char.hitTest(getBounds(_root).xMin, this._y, true)) {
this._x++;
}
while (_root.char.hitTest(this._x, getBounds(_root).yMax, true)) {
this._y--;
}
while (_root.char.hitTest(this._x, getBounds(_root).yMin, true)) {
this._y++;
}
while (_root.wall.hitTest(getBounds(_root).xMax, this._y, true)) {
this._x--;
}
while (_root.wall.hitTest(getBounds(_root).xMin, this._y, true)) {
this._x++;
}
while (_root.wall.hitTest(this._x, getBounds(_root).yMax, true)) {
this._y--;
}
while (_root.wall.hitTest(this._x, getBounds(_root).yMin, true)) {
this._y++;
}
}
thats Tutorial 1
Will be continiued, have to eat for a sec(ill edit the post)