Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

+ Reply to Thread
Results 1 to 6 of 6
  1. #1

    Default Scrolling and Motion Tween

    http://www.youtube.com/watch?v=PsC0zIhWNww
    When mario goes far enough to the right, everything scrolls with it.

    I want to the same effect in my video. When mario motion tweens enough to the right, everything needs to scroll left. What makes it trickier is enemy movement. As Mario moves right and everything scrolls left, that would mean the goomba would end up moving faster left.

    So what's the simpliest way to do this effect?

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    581

    Default

    It takes a few if statements.

    First, you check to see if mario is on the left side of your entire level or the right. When he is close enough to either side, the level needs to stay still and mario needs to move to the left side of the screen or the right side. If he is not near either end, then the level moves with him stationary in the center.

    This is the gist of it:

    Code:
    if ( left button is pressed )
    {
        if ( mario.x < (level.x+screen.width/2) )
        {
            mario moves left
        }
        else
        {
            level moves right
        }
    }
    
    if ( right button is pressed )
    {
        if ( mario.x > (level.x+level.width-screen.width/2) )
        {
            mario moves right
        }
        else
        {
            level moves left
        }
    }
    That's it. You will have to tweak the values depending on how you design your sprites and moving methods. You will also have to check that mario doesn't move off the screen. Enemy movement is not tricky at all. Enemies are part of the level. They should move with the level. For example:

    Let us say that the speed is equal to 10. Press left or right, mario or level moves 10 pixels every frame or whatever. So, mario is moving right at 10 pixel/frame. Goomba is moving left 10 pixel/frame. Whether or not mario is moving or the level is moving, mario and goomba will be colliding moving at 20 pixels/frame relatively to each other. If the player isn't pressing a button, the goomba will seem as though its moving slower than if he were. If the goomba is moving the same direction as mario, what will happen? It will look like mario and goomba are moving at same speed. To remedy this, make goomba slower so mario can catch up.
    Last edited by Vlykarye; 03-31-2012 at 10:05 PM.

  4. #3

    Default

    Let me rephrase a bit. Your script looks like it will work a bit but I'm not making a game. I'm making a flash video.

    Code:
    //if ( left button is pressed ) < need onframe script //{     if ( mario.x < (level.x+screen.width/2) )     {         mario moves left     }     else     {         level moves right     } //}  //if ( right button is pressed ) < need onframe script //{     if ( mario.x > (level.x+level.width-screen.width/2) )     {         mario moves right     }     else     {         level moves left     } //}
    Also, if your going to use scripts, I hope I can just copy and paste them.

    edit: Actually scripting might not even be needed. Just answer this question if you can.
    How do I figure out the speed for the object when using motion tween?
    I'm using 24 fps...if Mario moves 32 pixels in 5 frames...what's his speed?
    I could just use a calculator if scripting is a little too tricky.
    Last edited by KingOfHeart; 04-02-2012 at 08:25 PM.

  5. #4
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    581

    Default

    First off. If you want someone to do your work for you, and I say this as kindly as I can, go hire a ****ing freelancer and get off help sites.

    If you are making an actual flash movie.. Then you better know how to animate or how to code. Since you seem like you know neither, you're pretty much screwed.

    If you want to know how fast something moves, then go measure it. But let me try to explain this to you. You are 'creating,' which means you get to make shit up. Make up the speeds. If you are going to use motion tweening, then you are going to guess a lot. That's art. Motion tweening is art, not code. So go play with it and guess everything you are doing. If you want to know precise measurements, learn to program or be nice enough to ask someone to help you. 32 pixels / 5 frames. Do the math and you get the speed. If you want speed in seconds, then go back to highschool and take a math class to learn about ratios and proportions.

    (32 pixels / 5 frames) X (24 frames / 1 second) = ? // set up the equation.
    (32 pixels / 5) X (24 / 1 second) = ? // cancel units out.
    (32 pixels X 4.8 / 1 second = ? // start solving.
    (153.6 pixels / 1 second) = ? // finish solving.

    153.6 pixels / second

    Very simple math. How old are you? I don't want to sound rude asking, because I of all people believe that age does not equal knowledge. But seriously.

    This is such a trivial problem. Even you should be able to code it. Heck, it can be done in an Excel spreadsheet.

    I seriously suggest you take class before going any further. Take three. Unless you are doing this for a class, in which case... gg.



    But this of course is all very useless if you are using motion tween. You don't even need to worry about how the screen moves on mario. Just move it how you need it to move.

  6. #5

    Default

    I was not asking someone to do the work, just saying if your going to post it in code, make sure it's copy and pastable otherwise I won't understand.
    You could of just gave the formula and some simple advice.

  7. #6
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    581

    Default

    This isn't a code database site. NO ONE in the world can make perfect code that fits your needs with 0 information. Good luck finding someone to do that.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial