(AGK version: 108.13)
Submitted: 2013-06-14 07:01:17
//background infinite scrolling - good for jetpack joyride style of gameplay

//made for iphone resolution - change for your own prefered
SetVirtualResolution(960,640)

//background array
dim BG[2]

//load background image - change to your own background image
LoadImage (1, "Background.png")

//set background sprite
BG[0] = CreateSprite (1)
BG[1] = CloneSprite (BG[0])

//main loop
Do
    //get the region offsetting
    If Mod (GetViewOffsetX (), GetSpriteWidth (BG[0])) = 0
        stage = GetViewOffsetX ()/GetSpriteWidth (BG[0])
        SetSpritePosition (BG[0], GetSpriteWidth (BG[0])*stage, 0)
        SetSpritePosition (BG[1], GetSpriteX (BG[0]) + GetSpriteWidth (BG[0]), 0)
    Endif
    
    //print an information which region you are at
    Print (stage)
    
    //offsetting
    SetViewOffset (x, 0)
    x = x+ 8
Loop
(AGK version: 108.21)
Submitted: 2014-06-24 18:29:42
// Function to Align a point on the world plane with a point on the
// display plane at a given zoom level.
//
// Parameters: 
//   worldX# , worldY#       Point on world plane to align
//   displayX# , displayY#   Point on Display to Align to
//   worldZ#                 Zoom Level to align at
//

function AlignWorld( worldX# , worldY# , displayX# , displayY#, worldZ# )
  setViewZoom( worldZ# )
  setViewOffset( worldX# - ( displayX# / worldZ# ) , worldY# - ( displayY# / worldZ# ) )
endfunction

//
// Example Use - centering the display on a world sprite at zoom 2.0
//
AlignWorld( getSpriteXByOffset( sprite ) , getSpriteXByOffset( sprite ) , getVirtualWidth() * 0.5 , getVirtualHeight() * 0.5 , 2.0 )

Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.