Posted: 19th Aug 2011 3:57
Hey guys,

Does anybody know how to do this?

I have one idea of the background being made up of several images and having them set up as sprites and when the screen is far enough tan image moves in place.

Does anyone else have an idea on how to do this?
Thanks.


Cheers.
Posted: 19th Aug 2011 5:45
The technique is sound. Check out the Santa's Bad Elf example from the AppGameKit projects folder, which does a great job of scrolling background sprites to create the effect of an infinite scroll.
Posted: 19th Aug 2011 6:14
Here's a way to do this with UV scrolling. You can then bring in more images for variety/scene changes and move the sprites around to transition from one to another.

+ Code Snippet
LoadImage ( 8, "yourimage.png" )
` configure for tiling
SetImageWrapU(8,1)
SetImageWrapV(8,1)
CreateSprite(8,8)
` change these values for the virtual screen size you are using, or however big you want the sprite to be
SetSpriteSize(8,screensizeX,screensizeY)
` put it in the background
SetSpriteDepth(8,1000)


do
    ` during your loop, scroll the texture with the UV offsets, range is from 0-1.0
    ` test value
    moveu#=moveu#+0.01:if moveu#>1.0 then moveu#=moveu#-1.0
    SetSpriteUVOffset(8,moveu#,movev#)
    sync()
loop
Posted: 19th Aug 2011 6:28
My first project is a scrolling shooter. I have 10 levels of parallax scrolling, which is overkill, I was just testing the performance. It's no harder to do than in DB Pro. Just odd to use sprites, rather than image commands for the backdrop.
The technique works, as I have a demo (work in progress) running using it. Although I confess to not reading the examples, and diving straight in myself. I have made my scroll loopable, which has presented more problems than I anticipated, although I knew having a looping level would make things a little more difficult.
My only gripe with it is the odd glitch, which shouldn't be there, in the scroll. I have since loaded the elf demo and noticed it in that too. Although the scroll is perfect, it occasionally jitters. I wonder why, although this is not a new thing for me. Many languages have had this issue, AMOS, DB, DB Pro, and now AppGameKit have all had this untreatable glitch with scrolls.
But I am waffling, my scroll involves 2 sprites. I change the images as I move along them. So I start on sprite 1, and when I get to sprite 2, I change the images and move back to sprite 1. As long as you shuffle the images correctly you have a scroll.
Posted: 19th Aug 2011 14:07
is scroll glitch dependent on the fps set by SetSyncRate() ?
Posted: 19th Aug 2011 18:16
I am unsure. I have it set at 60 fps at the moment. I haven't looked into setting the framerate to 0 and using timer to update as yet. I'm not even sure if it is needed with AppGameKit, as it may work differently to DB Pro.
It would be worth knowing if AppGameKit actually pauses to get the correct fps in the same way DB does or not.
Posted: 19th Aug 2011 18:44
timer based movement is essential.

i noticed some jitter in scrolling when using 60fps. setting fps to 200 seems to have solved the problem for now!
Posted: 20th Aug 2011 0:46
A higher fps will reduce the jitter as it becomes imperceptible to the human eye. However mobile devices usually aren't able to go over 60fps. I never found the source of the jitter although it's a lot better than when we tried using vsync. I can only guess that it is some occasional delay in the GPU flipping the backbuffer.

It would be worth knowing if AppGameKit actually pauses to get the correct fps


Yes, the AppGameKit has two options, a sleep (default) or a busy wait loop (may be more accurate), controlled with the second parameter to SetSyncRate().