The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Needs some help with Flash (CS4)

MNC DoverMNC Dover Full-time Voice ActorKirkland, WARegistered User regular
edited April 2011 in Help / Advice Forum
Hello everyone!

I'm currently at SCAD (the Savannah College of Art and Design) with a major in video game design. As I prefer a shotgun approach to game creation, I've decided to learn how to program in Flash as well as the usual 3D stuff.

My current project is that we have to move a movieclip around the stage without using any user inputs or tween animations. In addition, we have to have the values of the movieclip be affected in some form or fashion (the x/y co-ordinates, alpha levels, scale, etc).

To give you an idea, I've created a little robot sprite that dashes megaman style from left to right across the stage. He starts in the middle of the stage and has solid platforms above and below him, making the layout three total tiers. When he reaches the end of the stage, he then backdashes from right to left. Wash, rinse, repeat.

Currently, I have a separate rock shape movieclip that travels left to right across the stage. When the robot comes within a certain distance of the rock, I programmed the robot to move up to avoid the rock. What I want to happen is that the robot will always move down to avoid a rock on the top level, up or down in the middle level, and up on the bottom level.

Any advice on what I should do? Code can be posted to clear things up.

Thanks!

Also, if you are terribly interested in helping, I may bend your ear some more if further lingering questions should arise. Again, I'm new at this and can definitely use the help. :D

Need a voice actor? Hire me at bengrayVO.com
Legends of Runeterra: MNCdover #moc
Switch ID: MNC Dover SW-1154-3107-1051
Steam ID
Twitch Page
MNC Dover on

Posts

  • tuxkamentuxkamen really took this picture. Registered User regular
    edited April 2011
    I'm a little rusty at ActionScript, but if that's what you're using, I think the solution's pretty straightforward:

    Since you have three 'levels' on your stage and you spawn rocks in one of three discrete locations rolling horizontally, you should add variables that indicate the levels of your rock and your sprite. Assuming you have one rock at a time, you set the rockLevel (example) when the animation begins and clear it when it ends. You start your spriteLevel (example) at whatever middle is, and change it whenever it successfully changes levels.

    Whenever the x of the rock is within (dangerDistance, or whatever) of the sprite, you compare the rockLevel and spriteLevel to see if the sprite needs to move. If he does, you look at the spriteLevel and decide to start a down transition if he's at the top, an up transition if he's at the bottom, or random(2) (or whatever you do to coin-flip it) if in the middle.

    Does that help you out, conceptually?

    tuxkamen on

    Games: Ad Astra Per Phalla | Choose Your Own Phalla
    Thus, the others all die before tuxkamen dies to the vote. Hence, tuxkamen survives, village victory.
    3DS: 2406-5451-5770
  • MNC DoverMNC Dover Full-time Voice Actor Kirkland, WARegistered User regular
    edited April 2011
    Yeah, actually that helps out quite a bit. I've got the robot moving and dodging great now, but only in on direction. Do you by chance know how to do a random check? That's something we haven't gotten to yet. :)

    MNC Dover on
    Need a voice actor? Hire me at bengrayVO.com
    Legends of Runeterra: MNCdover #moc
    Switch ID: MNC Dover SW-1154-3107-1051
    Steam ID
    Twitch Page
  • kedinikkedinik Registered User regular
    edited April 2011
    MNC Dover wrote: »
    Yeah, actually that helps out quite a bit. I've got the robot moving and dodging great now, but only in on direction. Do you by chance know how to do a random check? That's something we haven't gotten to yet. :)

    I do a lot of work with ActionScript 3; you can PM me with pretty much any questions.

    Math.ceil(Math.random()*n)) produces an integer between 1 and n.

    So for instance:
    var rand:uint = Math.ceil(Math.random()*3);
    
    if(rand == 1) {
    
    //Handle case 1
    
    }
    else if(rand == 2) {
    
    //Handle case 2
    
    }
    else {
    
    //Handle case 3
    
    }
    

    kedinik on
  • MNC DoverMNC Dover Full-time Voice Actor Kirkland, WARegistered User regular
    edited April 2011
    kedinik wrote: »
    MNC Dover wrote: »
    Yeah, actually that helps out quite a bit. I've got the robot moving and dodging great now, but only in on direction. Do you by chance know how to do a random check? That's something we haven't gotten to yet. :)

    I do a lot of work with ActionScript 3; you can PM me with pretty much any questions.

    Math.ceil(Math.random()*n)) produces an integer between 1 and n.

    So for instance:
    var rand:uint = Math.ceil(Math.random()*3);
    
    if(rand == 1) {
    
    //Handle case 1
    
    }
    else if(rand == 2) {
    
    //Handle case 2
    
    }
    else {
    
    //Handle case 3
    
    }
    

    Oh man, that's exactly what I needed. Prepare to have your PM box get hit up quite a bit. Not that I'm completely clueless, I just don't know the actual AC3 commands or prompts.

    Thanks again guys!

    MNC Dover on
    Need a voice actor? Hire me at bengrayVO.com
    Legends of Runeterra: MNCdover #moc
    Switch ID: MNC Dover SW-1154-3107-1051
    Steam ID
    Twitch Page
  • zatarzatar Registered User regular
    edited April 2011
    This page is quite helpful with as3 commands: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
    :)

    zatar on
    Playing as Tvisling Draygo on Europa-Farstar
Sign In or Register to comment.