Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 4 of 4

Thread: I need help for my platformer!

  1. #1

    I need help for my platformer!

    Hi,
    i don't know if this has been posted up before (Im new) So I'm posting this anyway.
    I've got my character working fine and everything is but I don't want my character to fall off the stage (I got a scrolling bg) But I don't want a wall, Does anyone know the code for when my character hits 0 on the left hand side of the stage it stops? My friend gave me a code but it didnt work.

    Also could you tell me where it would go?


    Please reply,

    Amy xxx

  2. #2
    if(_root.character_mc._x<=0){
    speed = 0;
    }
    if(_root.character_mc._x<=550){
    speed = 0;
    }
    that ought to work for you there the numbers are just the stage dimensions so you can easily adjust them to make him stop farther away from the edge or accomodate a larger stage and it is made to go on the main timelin e where the rest of your code should be attempted be organized hope that works

  3. #3
    Quote Originally Posted by cooldude88 View Post
    if(_root.character_mc._x<=0){
    speed = 0;
    }
    if(_root.character_mc._x>=550){
    speed = 0;
    }
    There. Fixed that for you, else the character wouldn't ever move.

    You could do it different ways. Basically, what you need to do is check if your character's _x is greater than the width of the stage or less than zero.Depending on the case you either subtract his 'Speed' variable(assuming there's one) from his _x value, or add to it.

    if(char._x>=Stage.width){
    char._x-=Speed;
    }
    if(char._x<=0){
    char._x+=Speed;
    }

    Last edited by zuperxtreme; May 10th, 2008 at 06:20 PM.

  4. #4
    Jephz's Avatar
    106
    posts
    The Penguin n00b
    or you can just draw a rectangle bar, set the alpha to 0, and put the code to push the character away. But I guess zupers way is better ^^.
    Don't you ever, ever, EVER call me a Noob. I mean it!

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012