06-21-2006, 04:16 AM
Here's the Second tutorial that follows on from the How to Walk Tutorial:
Step 1: read and do the tutorial from this link:
http://graphicsfans.createmybb.com/showt...php?tid=23
Step 2: when you've done that draw a wall (keep it simple to practise a little)
Step 3: Convert the drawn wall to a Movie clip
Step 4: add these actions to your character:
under
and above
so the Complete code of the char will be:
Step 5: call the drawing of the wall "wall"
example:
Be Sure you Selected the Movie Clip!
Step 6: Test your Game.
thats it
Have Fun!
//Rochy (and DarkstaR for the layout idea's of the tutorial)
Step 1: read and do the tutorial from this link:
http://graphicsfans.createmybb.com/showt...php?tid=23
Step 2: when you've done that draw a wall (keep it simple to practise a little)
Step 3: Convert the drawn wall to a Movie clip
Step 4: add these actions to your character:
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++;
}
under
Code:
_rotation = 90;
}
and above
Code:
}
so the Complete code of the char will be:
Code:
onClipEvent(load){
speed = 8;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.UP)){
this._y -= speed;
_rotation = 0;
}
if (Key.isDown(Key.DOWN)){
this._y += speed;
_rotation = 180;
}
if (Key.isDown(Key.LEFT)){
this._x -= speed;
_rotation = 270;
}
if (Key.isDown(Key.RIGHT)){
this._x += speed;
_rotation = 90;
}
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++;
}
}
Step 5: call the drawing of the wall "wall"
example:
Be Sure you Selected the Movie Clip!
Step 6: Test your Game.
thats it
Have Fun!
//Rochy (and DarkstaR for the layout idea's of the tutorial)