Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-12-2009, 03:27 AM   #1
frenzy2
Registered User
 
Join Date: May 2008
Posts: 29
Default [AS3] Platform Game How to create walls and platforms

OK I am trying to make a platform game and so far I have a platform and a character. The character moves left and right and he also jumps. At the moment you can move the character along the platform and if you jump he will fall and land on the platform. If I move the character off the platform he will not fall but if I jump then he will fall so how do I make it so that if I move the character off the platform he will fall. Also how do I make walls? I have tried but I can only get the character to stop when he hits one wall and not multiple walls. How do I create the platforms and the walls? Do I create them as separate movieclips, a separate movieclip for each wall and a separate movieclip for each platform or do I make them al as one movieclip. Could someone help me out please.

I have attached a zip with my flash file in it if someone could take a look at it and help me out that would be great

Cheers,
Frenzy
frenzy2 is offline   Reply With Quote
Old 03-12-2009, 02:55 PM   #2
rrh
throw a trace() in there
 
Join Date: Dec 2006
Posts: 1,982
Default

You could make separate movieclips in an array and loop through and hitTest them all. Or you can use hitTestPoint so you can have complex shapes.
rrh is offline   Reply With Quote
Old 03-13-2009, 12:22 AM   #3
frenzy2
Registered User
 
Join Date: May 2008
Posts: 29
Default

Ok how exactly would I do that? Could you show me an example code. Sorry I havn't used AS3 for a while so Im a little confused

Thanks,
Frenzy
frenzy2 is offline   Reply With Quote
Old 03-14-2009, 12:07 AM   #4
frenzy2
Registered User
 
Join Date: May 2008
Posts: 29
Default

anybody
frenzy2 is offline   Reply With Quote
Old 03-14-2009, 02:45 AM   #5
kkbbcute
Guest
 
Posts: n/a
Default

You could use a while loop to run your hitTest script through several wall mcs, if you name them wall1, wall2, wall3, etc... The while loop will just add 1 to the number at the end and just work the hitTest code that you've put inside.

I'm not into AS3 so I'm not really sure of the actual code, but for a concept idea, I think you should get what I'm saying.
  Reply With Quote
Old 03-15-2009, 12:27 PM   #6
frenzy2
Registered User
 
Join Date: May 2008
Posts: 29
Default

Ok I have tried writing out that code but I cant fiqure out how to do It could you post the code as an example so I can see how I would do it.

Thanks
frenzy2 is offline   Reply With Quote
Old 03-16-2009, 10:55 AM   #7
kkbbcute
Guest
 
Posts: n/a
Default

I'm not into AS3 so I won't know of the code, but hope this helps.

http://www.foundation-flash.com/tuto...as3hittesting/
  Reply With Quote
Old 03-16-2009, 04:08 PM   #8
rrh
throw a trace() in there
 
Join Date: Dec 2006
Posts: 1,982
Default

Rather than name all of them "blah1" "blah2" etc, I'm prone to push them all into an array, using getChildAt and numChildren. That means you need one movieclip that contains only walls, nothing else, or you can selectively pick out the walls using "if (child is WallClass)"
rrh is offline   Reply With Quote
Old 03-16-2009, 11:49 PM   #9
frenzy2
Registered User
 
Join Date: May 2008
Posts: 29
Default

Quote:
Originally Posted by rrh View Post
Rather than name all of them "blah1" "blah2" etc, I'm prone to push them all into an array, using getChildAt and numChildren. That means you need one movieclip that contains only walls, nothing else, or you can selectively pick out the walls using "if (child is WallClass)"

Do you know how to do this? I have never used getChildAt and numChildren before.

Cheers,
frenzy
frenzy2 is offline   Reply With Quote
Old 03-18-2009, 01:32 AM   #10
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

You shouldn't keep bumping, if people don't answer its because there not interested, don't know or you haven't defined the question well and they couldn't be botherd to ask you to explain it clearly.

I'm also working on a platform game and this is my first time in flash. Firstly, yes, all platforms/walls must be a seperate movieclip. You can however put all platforms/walls inside another movieclip and be able to refer to that parent movieclip, this is useful for scrolling (instead of the player moving, the whole world moves).

As for collison detection, yes you can but all the platform instances in an array if you like but its a little time consuming and everytime you add another platform you have to make changes to the code, don't ask me how to do it (because I can't remember for memory), there is enough information on the web with a simple internet search. However, the better way to do it imo is to make a platform class, and make a movieclip in the libary a member of the class, and just put instances of that movieclip on the stage. If you need to refer to a platform inparticular you can give the movieclip instance an instance name and call it by that.

Doing this is like putting code on an object and using the "this" statement in as2 but better.

Ofcourse, the worst way to do it but is still an option for simple games, you detect and react the platforms individually.

So you have player.hitTestObject(platform001), player.hitTestObject(platform002) etc and create a function for each platform collison reaction. This method involves alot of copy/pasting and changing string names and is the way I used to do it until I learn't about how to use classes in ActionScript 3.0. If your serious about your game and want it done properly, you'll uses classes. Once you learn classes, you'll want everything in a class inculding the npcs or "coins" if its that type of platform game etc.

If you have any furthur related to this problem questions ask them in this thread, if nobody else replies including me, then you can email me at [email protected] and I'll get back to ya .
aaron_da_killa is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS3] Platform Game - Horizontal Hit Test Help! Cauterize Gaming and Game Development 0 01-23-2009 05:00 PM
How Can I Make Platforms sNaKe Simple Stuff (Newbies) 3 12-22-2004 09:48 PM


All times are GMT. The time now is 03:42 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.