PDA

View Full Version : Help adding enemies to tile based game "Jungle Adventure"


annieberry6
02-05-2007, 04:38 PM
Hi, I am in desperate need of help. I am trying to make my own "Mario Style" game with the help of Glen Rhodes book, "Macromedia Flash Professional 8 Game Development." Has anyone read this book? I am having trouble adding enemies to the game world. When I create a movie clip for the enemies the enemy shows up on screen but it stays in the same position on screen as the game scrolls. It does not stay where it needs to in the "game world." Do I need to create and place the enemies in the level editor. If so, how to you make the enemies move. I have attatched a copy of the actionscript in a text file. I tried to attatch a zip file of the .fla but it was too large to upload. Please, please can someone help. I hope I am working my question correctly that makes sense. Thank you in advance.
Annie:confused:

oNdizZ
02-05-2007, 04:51 PM
When you're referring to "Mario Style" I'm guessing you are talking about a side-scrolling game. Anyways, it sounds like you have forgotten to loop through your enemies and move them when you move the enviromental background.

annieberry6
02-05-2007, 05:02 PM
Yes, I am creating a "side-scrolling game." I don't know how to move them independantly of the enviromental background. Can someone help?

oNdizZ
02-05-2007, 08:39 PM
when you move the background (when walking) you are probably doing something like:
background._x += speedx
background._y += speedy
when moving the background, loop through all enemies (dunno how you store them, in an array perhaps?) and do something like:
_root["enemy_"+i]._x -= speedx
_root["enemy_"+i]._y -= speedy

rrh
02-05-2007, 08:45 PM
Or place all the enemies inside of the background movie clip.

annieberry6
02-07-2007, 08:44 PM
I have tried your suggestions but I need help still. The background is not a movie clip.
I am stuck because of how this game was created using a level editor. I tried to place the enemies with the level editor but it wouldn't work since I needed to place the enemy "movie clip" and not just a picture of the enemy.

I am back to trying to place the enemy movie clip in the game code but I can't get the enemies to stay where I put them rather than how they are staying on the same spot on the viewers screen as the game scrolls.

There has got to be a away.
Please, please, please someone help. I don't know much and I know there are people out there than know a lot!
Thank you.
annie

rrh
02-07-2007, 11:26 PM
If the background is not a movie clip, then how do you make it scroll?

annieberry6
02-08-2007, 12:43 AM
Well, I tried to upload my .fla zipped file to this forum but it was too big. So, I uploaded the code that I copied to a text file and the .swf so you can play the game.

I have tried so many things but I can't place objects in the world.
Help.
Annie

rrh
02-08-2007, 10:30 PM
I looked through that. The scrolling is being done by what, copying the pixels to the side? I presume the distance to the side is based on the value of dx, but I couldn't find the specific code that does the copying.

So make the enemies move based on the value of dx. Since the enemies will also move of their own accord, you might want to give them their own onEnterFrame functions, and move them in there, instead of relying on the bitmap copying used to scroll the background.