03-07-2010, 02:02 AM
|
#1
|
|
Registered User
Join Date: Mar 2010
Location: I'm not telling!
Posts: 14
|
[AS3] walls and sprites
I haven't coded much in actionscript yet, but anyway, I was wondering about coding walls and sprites.
Walls-how would you make it so that if a character hits a wall, it can't go through it. Would you multiply the walls width and heigth by each other and tell it that it couldn't go inside the boundaries of it or what?
Sprites-If you want it so that a character will have a different appearance when walking left and a different one when walking right or shooting or jumping, how would you do this?
|
|
|
03-07-2010, 02:38 AM
|
#2
|
|
Senior Member
Join Date: Jan 2009
Posts: 163
|
Quote:
Originally Posted by blue969
I haven't coded much in actionscript yet, but anyway, I was wondering about coding walls and sprites.
Walls-how would you make it so that if a character hits a wall, it can't go through it. Would you multiply the walls width and heigth by each other and tell it that it couldn't go inside the boundaries of it or what?
|
Look up hitTestObject and hitTestPoint. These will tell you if two objects are touching, and you can adjust their speed and/or position accordingly.
Quote:
|
Sprites-If you want it so that a character will have a different appearance when walking left and a different one when walking right or shooting or jumping, how would you do this?
|
There are alot of ways to do it, but one common with is to make each frame in the timeline a different sprite. For example, frame one could be standing and frame two could be jumping. If the character jumps, call gotoAndStop(2), when they land, call gotoAndStop(1).
|
|
|
03-07-2010, 04:53 PM
|
#3
|
|
Registered User
Join Date: Mar 2010
Location: I'm not telling!
Posts: 14
|
QOUTE-There are alot of ways to do it, but one common with is to make each frame in the timeline a different sprite. For example, frame one could be standing and frame two could be jumping. If the character jumps, call gotoAndStop(2), when they land, call gotoAndStop(1).
I don't know if what I heard was true, but I heard that that could only be done in as2?
Last edited by blue969; 03-07-2010 at 05:29 PM.
|
|
|
03-07-2010, 07:23 PM
|
#4
|
|
Senior Member
Join Date: Jan 2009
Posts: 163
|
Quote:
|
I don't know if what I heard was true, but I heard that that could only be done in as2?
|
I'm very sure it can be done in AS3. Where did you hear that it couldn't?
|
|
|
03-07-2010, 07:29 PM
|
#5
|
|
Registered User
Join Date: Mar 2010
Location: I'm not telling!
Posts: 14
|
I forgot the exact name of the website, but it was some tutorial website.
|
|
|
03-07-2010, 07:42 PM
|
#6
|
|
Senior Member
Join Date: Jan 2009
Posts: 163
|
Maybe they meant the commands were different or something. You still have a timeline in AS3, and you can still stop it on certain frames.
|
|
|
03-08-2010, 12:15 AM
|
#7
|
|
Registered User
Join Date: Mar 2010
Location: I'm not telling!
Posts: 14
|
Also, another question I have is how would I make a flash game have multiple levels/stages in it?(I have some Ideas but I think there is probably better and easier ways than the idea I have)
|
|
|
03-08-2010, 01:46 AM
|
#8
|
|
Senior Member
Join Date: Jan 2009
Posts: 163
|
I would just make each level a different movieclip.
If you want to make a level editor though, you'd need to write some kind of algorithm to generate the level based on data you provide.
|
|
|
03-09-2010, 04:47 AM
|
#9
|
|
Registered User
Join Date: Mar 2010
Location: I'm not telling!
Posts: 14
|
I actually thought of the movieclip Idea before, but then I noticed that if you press ENTER on the flash player you can start or stop the movie, so doesn't that mean you can skip a level if you press enter?
|
|
|
03-09-2010, 05:38 AM
|
#10
|
|
Senior Member
Join Date: Jan 2009
Posts: 163
|
I assume you mean in the flash testing environment. I don't think you can affects swfs you play in your browser that way.
Also, you're probably thinking of frames, not MovieClips.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 04:39 AM.
///
|
|