How to move background image in a loop?

  • #1, by AkcayKaraazmakFriday, 03. October 2014, 22:11 6 years ago
    Hi guys,

    Anyone has an idea for how to move a background image in a loop?

    1-) For example lets say the scene is a car and the background of the car should slide from left to right to give the mood of car is moving. How could we slide a seemles image in a loop?

    2-) And how we could move an object on scene from 1 place to another in a loop. Lets say clouds little moving from left to right and the right to left till the scene changed?


    Thank you smile

    Great Poster

    437 Posts


  • #2, by AlexFriday, 03. October 2014, 22:37 6 years ago
    Hi,

    I'd say 1) and 2) is basically the same problem. you could do something like this (I've not tested this):

    - create an animation (this can also be a single frame animation showing a cloud etc) and set the position on the scene.
    - create a value cloud_anim_counter with initial value 1.
    - create an action called 'move cloud':
    start animation 'cloud'
    wait x msec
    if value cloud_anim_counter = 1000
    set animation 'cloud' to (0,0)
    else
    move animation 'cloud' down/right by (1,0)
    end if
    Value cloud_anim_counter + 1
    jump to action part #2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    - create an action 'at beginning of scene' for the scene where you start your action 'move cloud'
    - create an action 'at end of scene' where you quit the action 'move cloud' and stop the animation

    of course there are lots of other ways to achieve this. You could also attach the animation (or an image) to a scene object and then move the scene object. Or you could do everything in a lua script (which I'd only recommend if you like scripting).

    Great Poster

    378 Posts

  • #3, by afrlmeFriday, 03. October 2014, 23:03 6 years ago
    With the new move object action part, it's pretty easy to move images/animations. You can't move the actual background though.

    Seeing as we don't have an option for tiling images/animations you would need to create the background twice & add them as scene objects, then you would place both objects side by side & have them move left (or right) at the same time/speed & when one image leaves the scene you quickly snap it to the position of the other object + or - an offset value, in this way you get something with a seamless loop.

    Shame we don't have a tile option as it would make things much easier.

    I actually created a demo & script - a while ago - of what I just said. I'll have a look around my hd the morrow & see if I can find it.

    Moving single clouds as objects is pretty easy & you can also dynamically place them with random offset values & randomly generate speed values for them too; using lua, action parts or a combination of both.

    * edit: here is the resource files for the .ved I mentioned. The correct ved is the one with "fog" in the name.

    Imperator

    6816 Posts

  • #4, by AkcayKaraazmakFriday, 03. October 2014, 23:17 6 years ago
    Hi mates,

    I've tried to use move object, which is realy a cool function but it animation stops when it comes to destination coordinates. How I can make it move again after it comes to its cooarditanes?

    Lets say, cloud came to (1000,500) after move obeject. And after that I want to send it to (500,400) and then again use move object to send it to (1000,500)



    @Alex; I used execute script for your code but it didnt work :\

    Great Poster

    437 Posts

  • #5, by AlexFriday, 03. October 2014, 23:24 6 years ago
    this is not a script, my code is pseudo-code for action parts

    Great Poster

    378 Posts

  • #6, by afrlmeFriday, 03. October 2014, 23:29 6 years ago
    with the move object action part you could use the pause action part after the move action with the same value you used in the move part. that way it will move to next coordinates & so so on. If you combine this with the jump to x action part like Alex mentioned in his code block example above then you create a loop that won't end until you quit the action, thus it would be best to add the loop inside of a "called by other action block" or wrap the loop inside of an if query with a condition or something.

    Imperator

    6816 Posts

  • #7, by brut69Saturday, 04. October 2014, 14:33 6 years ago
    I did with with birds
    I used Action areas where when the character (bird) entered the action area (out of screen) it will set the character to original location and make him move again. Hence a look and it gives the feeling that a bird is flying around

    Great Poster

    263 Posts

  • #8, by brut69Saturday, 04. October 2014, 17:22 6 years ago
    You start by creating 2 action Areas.
    Both need to be "Once Character Enters" and you set as character the "bird"
    Then you set the Destination so that it will Set the Character , to the Origin (2nd Action Area points to the 1st)

    This creates a loop since the 1st Action Area will be sending the Character "Bird" towards the 2nd Action Area , once it enters the 2nd Action Area , it will automatically "Set the Character back to the 1st" , which in return will send it again towards the 2nd.

    You can alternatively set it so instead of SET Character is SEND Character so it will be going back/forth instead of jumping to another location depending on what you want.

    Ideally the Action areas are not visible (you can do action areas out of screen) so the character "jumping" will not be visible to the user.

    Great Poster

    263 Posts

  • #9, by AkcayKaraazmakMonday, 06. October 2014, 10:07 6 years ago
    Thank you so much guys, I will try your technics.

    Great Poster

    437 Posts

  • #10, by NigecMonday, 06. October 2014, 10:30 6 years ago
    I;d love to see a working demo of this

    Key Killer

    558 Posts

  • #11, by AkcayKaraazmakMonday, 06. October 2014, 11:18 6 years ago
    Me too smile

    Great Poster

    437 Posts

Write post