• About WordPress
    • WordPress.org
    • Documentation
    • Learn WordPress
    • Support
    • Feedback
  • Log In
Skip to content

MonoFlauta

Indie Game Developer

Menu
  • Blog
  • Portfolio
    • Games
      • Happy Ghost Studio
      • Etermax
      • Silky Smooth Studio
      • Fun+Mono
    • Frameworks & Tools
      • Framework Goat
      • Twitch Mono Integration
      • Framework Mono
      • Narwhal Engine
    • Others
  • Store
  • About Me

Framework Mono – Visual/LoopingBackground.as

cropped-icono.jpgThe LoopingBackground.as script will help you to make a looping background in a easily and fast way. You will just need to have a tilable background, that can go in any direction, and with that you will be able to do it. Note: You will need to have a public static instance of Mono in the Main.as. and the Update Manager instantiated.


How to use LoopingBackground.as

First of all, you will need to have a public static instance of Mono.as in the Main.as. Also, you will need to have initialized the UpdateManager.as before using this script since it is needed to make the movement of it.

Once you have all the requeriments of the class, you will need to create an instance of LoopingBackground.as. For the constructor you will need to send two sprites of the looping background (they can be different as long as they loop in the desired direction), the sprite where they are going to be attached and the direction you want them to move.

For example:

background = new LoopingBackground(new MCBackground(), new MCBackground(), camera.view, new Point(0, 10));
background.play();

In this case, we have a var called background of type LoopingBackground.as. When we create it, the first two parameters are the sprites we are going to loop. In this case they are the same one and are movieclips of type MCBackground. As third parameter we are sending the container were the sprites are going to be added as childs, in this case we are using the view of the Camera.as, also from Framework Mono. For last, we create a new point that will be the direction and speed where the backgrounds move. In this case, the background will move down at 10 pixels per frame.

Once we created the instance, we just give it play(); and will start playing and looping itself.

Also, if needed, you can stop it called the stop() function and when you want to remove it, just call the remove() function.

For last, you can easily change the direction or speed of the looping background by just calling changeDirection function and sending by parameter the new direction that contains the speed.

 background.changeDirection(new Point(0, -5);

In this example we are making now that the background moves upwards at 5 pixels per second.


Public Functions

  • play():void
  • changeDirection(direction:Point):void
  • function stop():void
  • remove():void

Private Functions

  • update():void

Private Vars

  • _firstBackground:Sprite;
  • _secondBackground:Sprite;
  • _movement:Point;
  • _stageWidth:int;
  • _stageHeight:int;
  • _placingSecond:Boolean;
  • _reproducing:Boolean;

Powered by WordPress MonoFlauta 2025 | All Rights Reserved.

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}