Scroll to the right and center on the player

I'm making a platform game. My game level is very large and I'd like to make the gameLevel scroll when the player is walking.
So far it's scrolling, but the scrolling speed is not fast enough and when the player is walking to the right, he goes out of the screen.
Do you know how I can speed up the scrolling in order to prevent the character to exceed the middle of the screen ?
Here's my code for the scrolling screen :
public function scrollWithHero() {
   var stagePosition:Number = gamelevel.x+hero.mc.x;
   var rightEdge:Number = 400-edgeDistance;
   var leftEdge:Number = edgeDistance;
   if (stagePosition > rightEdge) {
  gamelevel.x -= (stagePosition-rightEdge);
   if (gamelevel.x < -(gamelevel.width-stage.stageWidth)) gamelevel.x = -(gamelevel.width-stage.stageWidth);
   if (stagePosition < leftEdge) {
  gamelevel.x += (leftEdge-stagePosition);
   if (gamelevel.x > 0) gamelevel.x = 0;
I could put something like this
if (hero.mc.x > 300){
//What should I put here ?
(x=300 is the position of my player when he is in the center of the screen)
Thank you for your help

it looks like you want easing so scrolling slows as stagePosition nears an edge.  if so, you can use:
var speed:Number = something between 0 and 1 (closer to 1 is slower, closer to 0 is faster)
gamelevel.x = speed*gamelevel.x+(1-speed)*an edge;

Similar Messages

  • My apple wireless mouse scrolls in the opposite direction. When I scroll up, down, right and left it always scrolls the opposite direction. Can anyone help?

    My apple wireless mouse scrolls in the opposite direction. When I scroll up, down, right and left it always scrolls the opposite direction. Can anyone help?

    Hi Malky H.,
    Thanks for visiting Apple Support Communities.
    If your mouse is not scrolling in the direction you are expecting, check this Mouse setting in System Preferences:
    Choose Apple menu > System Preferences, then click Mouse.
    Scroll direction: natural: Select this option to move the contents of a window in the same direction as your fingers.
    You can find this information here:
    OS X Yosemite: Use an Apple Magic Mouse
    Note that these steps apply to previous versions of Mac OS X as well.
    Best Regards,
    Jeremy

  • Can no longer play KCRW Left, Right and Center

    Since upgrading my 5G ipod to latest version. It will no longer play certain podcasts. The one listed above is one nbut there are others. Buzzcast from CNET is one it stopped playing for a time but then after teh latest itunes update it now plays it again. They all play fine on my PC through itunes. But when I try to play them on my ipod I just get the Apple logo and then it reboots.
    Anyone having this problem? Or even better, can anyone on using the new update play a show mentioned on their ipod?
    Thanks,
    Bill
    PC   Windows XP Pro  

    One thing that may help those experiencing similar problems is that I have discovered that by turning off the "EQ" on my ipod allows the podcasts to play on my ipod in most cases. So this is one workaround until a fix appears.
    Best,
    Bill

  • Lower scroll bar stays right, won't let me scroll left and stay there

    I can't keep the bottom scroll bar, which shows up when pages are too big, to the left where is belongs, it automatically will scroll my page right and although I can try to drag the scroll back left it's difficult to grab and do and it won't stay there at all.

    This issue can be caused by an extension that isn't working properly.
    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • How can I see the entire mail message without making it smaller font and not having to scroll to the right?

    when i open a message in hotmail i have to scroll to the right to see the entire sentence. I did not have to do this before what has changed? Me or you?
    Thanks

    You can use an extension to set a default font size and page zoom on web pages.
    *Default FullZoom Level: https://addons.mozilla.org/firefox/addon/default-fullzoom-level/
    *NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/
    If you have increased the minimum font size then try the default setting "none" as a high value can cause such issues.
    *Tools > Options > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    Make sure that you allow websites to choose their fonts.
    *Tools > Options > Content : Fonts & Colors > Advanced > [X] "Allow pages to choose their own fonts, instead of my selections above"

  • TS3276 Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Having trouble sending jpeg images as attachments in Mac email.....they go thru as images and PC users can't see the SAVE or QUICK LOOK boxes that Mac mail has.  One friend scrolled over the image, right clicked on it and saved as a PNG file.

    Apple Mail isn't going to change the format of any of your attachments. it isn't going to corrupt them either.
    Exchange is a transport protocol and server. The issue you describe is not related to Exchange.
    There are many different versions of Microsoft Outlook in use and they all have e-mail bugs. Different versions have different bugs. Some Apple Mail hack to get around a bug in Outlook 2003 may cause the same message to be problematic in Outlook 2000. Fix them both and another issue will cause trouble in Outlook 2007. You can't fix this. Apple can't fix this. Microsoft can and has but that is irrelevant if your recipients are using older versions.
    One specific problem is that Apple Mail always sends image attachments inline, as images, not as iconized files. You can change this with Attachment Tamer. Just be aware that use of this software will break other things such as Stationery. E-mail is just a disaster. To date, no one outside of Apple has ever implemented the e-mail standards from 1993. Apple has continually changed its e-mail software to be more compatible with the de-facto standards that Netscape and Microsoft have unilaterally defined and people documented as "standards" after the fact. The e-mail messages that Apple Mail sends are 100% correct and do not violate any of the original standards from 1993 or the Microsoft/Netscape modifications. The problem is entirely bugs and limitations in various versions of Outlook.

  • When you scroll to the bottom of the list of files in Finder, the left to right scrollbar doesn't let you click the last file and it covers the file for a while until it disappears. Is this a bug? How do I not make that happen?

    When you scroll to the bottom of the list of files in Finder, the left to right scrollbar doesn't let you click the last file and it covers the file for a while until it disappears. Is this a bug? How do I not make that happen?

    An odd workaround: click "Always" in System Preferences/General/Show scroll bars. The scroll bars will always show, but they won't cover your last file.
    See this other post: https://discussions.apple.com/message/20572471#20572471

  • I'm trying to mix a guitar track so it is heard in the right and left ear and not in the center

    I'm trying to mix a guitar track in GarageBand.  I'd like to have the same guitar track heard in the right and left ear.  When I mix it that way, the guitar comes from the center.  Is there a way to place this track so that it appears to come from both the left and right side?

    Mr. Snook wrote:
    If my finger picked guitar track is doubled and pasted slightly ahead or behind, the guitars will be out of sync, I think, and sound off in mix.
    emphasis on "tiny amount"
    TINY fractions of a second. this is how you get the "full sound"
    zoom in as far as you can, and make sure the "snap to grid" and "alignment guides" menuItems are not checked.

  • The accursed little dark gray ball with white in the center and white arrows, either two or four, which seize control of the screen and move the text or pictures up, down, left, right and can be stopped only by finding the ball and clicking it. I want to

    The accursed little dark gray ball with white in the center and white arrows, either two or four, which seize control of the screen and move the text or pictures up, down, left, right and can be stopped only by finding the ball and clicking it. I want to stop the thing permanently. Firefox 3.6 and 3.64
    == This happened ==
    Every time Firefox opened
    == with 3.60

    The accursed little dark gray ball with white in the center and white arrows, either two or four, which seize control of the screen and move the text or pictures up, down, left, right and can be stopped only by finding the ball and clicking it. I want to stop the thing permanently. Firefox 3.6 and 3.64
    == This happened ==
    Every time Firefox opened
    == with 3.60

  • I used to be able to scroll with the button on my laptop (between left and right-click buttons) and now I can't

    there's a square button on my laptop between the right and left-click buttons which is meant to use to scroll down pages with. it worked before I upgraded, and now id doesn't. how can I change that? my laptop is an Acer from e-machines
    thanks!

    You may have switched on [http://kb.mozillazine.org/accessibility.browsewithcaret caret browsing].
    You can press press F7 (on Mac: fn + F7) to toggle caret browsing on/off.
    * Tools > Options > Advanced : General: Accessibility: [ ] "Always use the cursor keys to navigate within pages"
    * http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works

  • I have a new IMAC. My mouse (very sensible) gave me the possibility to move left to right and right to left and also to scroll on the vertical way also on my page word. I like the vertical way, it is ok, but is it possible to block the vertical move only

    Hi, I have a new IMAC. Only by touch, my mouse (very sensible) gave me the possibility to move left to right and right to left on my pages word and also to scroll on the vertical way. I am ok with the vertical way, but I don't like the very sensible horizontal way. Do someone know a way to block the vertical move only and keep the move of the horizontal way? The only way I found blocked all the moves.
    I hope my descripion is understandable... English is not my habitual language.
    Danielle

    Merci Éric de me revenir en français, je l'apprécie beaucoup. Je ne veux conserver que le mouvement de haut en bas et de bas en haut. Je ne vois pas l'utilité du mouvement horizontale (gauche-droite, droite-gauche) et pire encore, par mégarde je fais trop souvent bouger ainsi mon texte et cela m'embête, même me dérange  beaucoup. Même que cela me donne même mal au coeur hahahahahaha!
    Par contre, ma souris précédente avait le mouvement de défilement du haut en bas et bas en haut et cela par contre m'est très utile. Je voudrais donc savoir s'il existe un moyen de stopper le mouvement de côté mais conserver tout de même la fonction du mouvement haut-bas et bas-haut avec le simple toucher de la souris. Suis-je plus clair? Disons que c'est plus aisé pour moi en français. merci à toi
    Danielle

  • How do I configure Firefox to autofit webpages (i.e. so I don't have to scroll to the right to see everything) and display all webpage content?

    I'm doing some maintenance on an old Dell Dimension 1100 (service tag: JGFN291, all drivers updated) for a friend, and I installed the new version of Firefox. Webpage graphics / backgrounds will not display, and the text on all webpages displays too large; I have to scroll to the left to see everything. How do I configure Firefox to automatically display all webpage content properly? It's probably due to the age of the PC and monitor (I think Noah took a pair of these on the ark with him back in the day), but I was hoping there was some other workaround for it. Any and all help is appreciated!

    there is no replay for the problem ?? mozillas's stuff doesnt work as good as their web browser...

  • TS5362 My scroller on the right hand side of my screen is missing and I have to use my arrow buttons to navigate through the page with my update. Please help:-)

    Since my update, I cannot scroll using the scroller option that slides down the page and my iTune downloaded podcasts will not sync to my apple tv. Any ideas?

    Hello there, breezyandrade.
    The following Knowledge Base article offers up some great information on setting your scroll bar preferences. Although written for Mountain Lion it provides accurate location for this preference in Mavericks as well:
    OS X Mountain Lion: Change how scroll bars work
    http://support.apple.com/kb/PH10895
    Use General Preferences to customize scroll bars in windows.
    Choose Apple menu > System Preferences, and then click General.
    Set the scrolling options. For more information about the scrolling options, click the Help button.
    Some apps let you scroll through a document in other ways, such as by dragging in the document, using arrow keys, or pressing the Space bar.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • I have added/embedded four videos on my website, but when I scroll down, the videos scroll in front of the top menu instead of behind as it should. I have tried changing layers, etc., and nothing works. Can you help?

    I have embedded 4 videos on my website. It is a single page, scrolling site. When I scroll down, the videos scroll in front of the top menu bar, instead of behind it. I have tried changing layers, etc., and nothing works. Please help.
    Thanks.
    Paul W. Norman

    Hi,
    Kindly create a new layer, via the Layers panel:
    Then, right click on the navigation bar, and choose Move to Layer > Layer 2
    Ensure that Layer 2 is on top of the other layers.
    Hope it helps,
    Sonam

  • Text does not move to a new line, I have to scroll to the right???

    In Safari and Firefox browsers when looking at some webpages the text is one long line and I have to scroll to the right to read everything. How do I restore the text so it goes down instead of across?
    I searched for wrap text but could not find anything.
    Thank You

    Hi M'Q', Welcome Back.
    It seems to be site formatting. I get it all the time in these forums when someone posts a crash log. The lines don't wrap and spread it out sideways.
    My WAG; we just have to live with it. :~(

Maybe you are looking for

  • New Customer Very Slow BB Speed

    Hi, Im looking for some help with my broadband speed, the technical help in India don't seem to be very knowledgeable. When signing to BT I asked what speeds I could hope to achieve, I was told between 5-8 which I was very happy about as iv just move

  • Problem while passing parameter between forms

    Hi, I am tring to call a form from another form using the code fnd_function.EXECUTE (function_name => 'TABFORMFUN', open_flag => 'Y', session_flag => 'Y', other_params => 'EMPNO="' ||'paramvalue'||'"'); in WHEN-MOUSE-CLICK trigger. when I deployed it

  • Multi-Master Replication Limits

    I'm starting new project and would like ask your opinion. They like to have multi-master replication of a single table between Chicago and Denver. A record could be written in Denver, then same row read in Chicago. The opposite is also true. Replicat

  • WAAS Email Alerting

    Is there a way to set up e-mail alerting for when the central manager shows an alert.  For instance recently one of our appliances show that a power supply is bad and needs to be replaced.  I see in the central manager that there is a section for SMT

  • SCCM Client push or manual installation does not complete

    Hi All, I have deployed SCCM 2012 R2 in my lab environment. It has been deployed successfully. I have a issue in which the clients are not getting installed both manually and by pushing the agents via the console.  My servers are as follows: SCCMSVR.