Groups | Blog | Home
all groups > flash actionscript > august 2006 >

flash actionscript : Need help with RPG


RDG10
8/4/2006 11:17:37 PM
Hi, I'm developing an RPG in Flash 8 Professional. It's from bird's eye view,
the character only rotates, background is the one that moves (the character is
always centered). I've designed the backgrounds but the character walks through
the walls, I've gone through a lot of tutorials but all of them are the same
(your character decreases its _xscale). I don't want that because my character
is always centered. Can anyone tell me how to do this? And how to make my
character not go through other stuff like desks?

Thanks in advance
kglad
8/4/2006 11:35:51 PM
RDG10
8/5/2006 12:00:45 AM
kglad
8/5/2006 12:08:45 AM
using a loop in computer programming is fundamental. loops allow you to
execute code repeatedly (usually changing one or more parameters with each loop
iteration) in a succinct manner.

now, you probably are already using a loop to repeatededly check for a user's
keyboard input to determine whether you character should walk left or right, up
or down. in that loop you should execute another loop that checks if contact
is made with an object.

in your situation of a character (with instance name, say characterMC) and
walls (with instance name, say wall1,wall2,...,wallN), you could use:



for(var i=1;i<=N;i++){
if(characterMC.hitTest(_root["wall"+i])){
// do something, you're about to hit a wall
} else {
// do something else, no contact with a wall
}
}
RDG10
8/5/2006 12:20:02 AM
kglad
8/5/2006 4:13:38 AM
i don't know what you're seeing that would cause you to say, "Yea, that's the
problem. ..."

if a positive hitTest() will result from the movement of your walls, don't
allow that movement. if you want your character to rebound, then code that
rebound (of the walls).
AddThis Social Bookmark Button