Search code examples
javaandroidxmlhorizontalscrollviewtile

How can I tile an image in X direction while it is scrolling at a velocity?


Hey all i've been scowering the internet for days now, ive also been reading up on this etc and i am in desperate need of help. I am writing a 2D game and I need the background to move and my character will be stationary and he'll jump over stuff.

If anyone can push me in the right direction or even provide a snippet of code i would be more than greatful.


Solution

  • For anyone who is still struggling with this I worked it out:

    Download corona SDK and program with that its so much easier:

    function scrollBackground(self,event)
    if self.x < [Enter Background width in pixels] then
    self.x = [Enter Background width in pixels]
    else
                self.x = self.x - [Speed - low number like 5 is slow scrolling, high number like 18 is fast scrolling]
            end
        end 
    

    Use the above function to for the scrolling background then add this underneath:

    function scene:enterScene(event)
    background.enterFrame = scrollCity
    Runtime:addEventListener("enterFrame", background)