How to: make background stop when actor stops

Hello!

How can i make my parallax background scrolling stop when my actor is not moving in any direction?
At the moment background works fine but for example if my actor runs against a wall background still continues to move :D

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @fatetaleteller said:
    . . . if my actor runs against a wall background still continues to move

    Why does it continue to move ?

  • fatetaletellerfatetaleteller Member, PRO Posts: 40

    @Socks Oh hello again!
    It moves because at the moment only thing that stops the background is if all keys are not pressed.

  • SocksSocks London, UK.Member Posts: 12,822

    @fatetaleteller said:
    @Socks Oh hello again!
    It moves because at the moment only thing that stops the background is if all keys are not pressed.

    Sounds like another way of saying that pressing a key moves the background ?

  • SocksSocks London, UK.Member Posts: 12,822

    Can you upload a stripped down version of your project, just the main actor and the BG actor ?

  • fatetaletellerfatetaleteller Member, PRO Posts: 40

    @Socks it says "file not allowed" when i try but here is what i did.

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2016

    @fatetaleteller said:
    @Socks it says "file not allowed" when i try . . .

    You need to compress/zip the file before uploading.

  • fatetaletellerfatetaleteller Member, PRO Posts: 40

    @Socks Thanks in advance!

  • SocksSocks London, UK.Member Posts: 12,822

    @fatetaleteller said:
    @Socks Thanks in advance!

    "if my actor runs against a wall background still continues to move"

    I can't see any walls, the hero actor falls off the screen as soon as you start, there are broken references in the hero actor's rules . . . etc etc.

    Maybe someone else will have better luck.

  • fatetaletellerfatetaleteller Member, PRO Posts: 40

    @Socks said:
    Can you upload a stripped down version of your project, just the main actor and the BG actor ?

    Well you just asked for main actor and bg actor xD @Socks

  • FeathersFeathers Member Posts: 31

    Does the background have any behaviors?

  • tout.botout.bo Member Posts: 2

    Hi, its really easy for create parallax effect, you have tutorial here:
    http://www.gamesalad-templates.com/gamesalad-tutorial-parallax/

  • IceboxIcebox Member Posts: 1,484

    I think the method your using is to teach beginners more about gamesalad logic , and it works but it has two flaws :

    1- as you mentioned the background moves when your walking against a wall
    2- If you had a checkpoint at the middle of the level the background will remain the same so it will cause issues.

    The best method to use is this:

    First Create two game attributes make them real attributes call them CAMX , CAMY

    1 - Create an actor call it CameraControl
    2 - Create an actor for your background image

    Place the CameraControl actor on the scene and unlock it to access scene attributes

    Add 2 constrains

    Constrain Game.CAMX to scene.Camera.Origin.X
    Constrain Game.CAMY to scene.Camera.Origin.Y

    thats it for the CameraControl Actor

    Now go to your Background actor create 4 real self attributes
    1- X speed
    2- Y speed
    3- StartX
    4- StartY

    • Change attribute self.StartX to self.position.X
    • Change attribute self.StartY to self.position.Y
    • Constrain attribute self.position.X to self.StartX - ( Game.CAMX / self.X speed)
    • Constrain attribute self.position.Y to self.StartY - ( Game.CAMY / self.Y speed)

    Make sure to tick off scrollable and add these actors to a non scrollable layer

    Now play with the X and Y speed to get the effect you like ..

    Hope this helps

Sign In or Register to comment.