Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Define scrolling position — Gideros Forum

Define scrolling position

Ale72Ale72 Member
edited January 2012 in Suggestions & requests
Hi,
here Ale from Italy... first post :)

I try the Tiled Map Editor (Desert) and It was very usefull for my game idea.

I have a question.
How I can define scrolling so my image in background doesn't scroll outside the screen.

Best
Ale
Tagged:

Comments

  • GregBUGGregBUG Guru
    edited January 2012
    Hi Ale and welcome on board!!!
    hope you'll find Gideros SDK fine!

    i'm italian too (from l'aquila)
    for your scrolling problem (i don't know if i understood correctly your problem, but try this....)
    on desert demo modify function
    (no optimized but works...)

    -- ITALIAN MODE ON -------
    Ciao e benvenuto !
    spero ti piaccia Gideros sdk!

    per il problema che dici dello scroll prova a modificare questa funzione...
    (non so se ho capito bene il tuo problema... non vuoi che lo sfondo della mappa vada al "di fuori" dello schermo (e quindi si veda la parte bianca) ?

    attenzione non è ottimizzata... ma funziona!
    ciao
    -- ITALIAN MODE OFF -------
    local function onMouseMove(event)
    	if dragging then
    		local ScreenTilesW = application:getDeviceWidth() / map.tilewidth
    		local ScreenTilesH = application:getDeviceHeight() / map.tilewidth
    		local dx = event.x - startx
    		local dy = event.y - starty
    		if ((allLayers:getX()+ dx) < 0) and  ((allLayers:getX()+dx) > ((map.width-ScreenTilesW)*map.tilewidth*-1)) then
    			allLayers:setX(allLayers:getX() + dx)
    			startx = event.x
    		end
    		if (allLayers:getY() + dy) < 0 and  ((allLayers:getY()+dy) > ((map.height-ScreenTilesH)*map.tileheight*-1)) then	
    			allLayers:setY(allLayers:getY() + dy)
    			starty = event.y
    		end
    	end
    end
    Hope it helps.

    Ciao Ciao
    Gianluca.

    Likes: MoKaLux

    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Ale72Ale72 Member
    edited January 2012
    Yes, that right and it works,
    but I need for a single image that I use as background.

    This is your code that I modify:

    [code]
    local function onMouseMove(event)
    if dragging then
    local ScreenTilesW = application:getDeviceWidth()
    local ScreenTilesH = application:getDeviceHeight()
    local dx = event.x - startx
    local dy = event.y - starty
    if ((bg:getX()+ dx) < 0) and ((bg:getX()+dx) > ((bg.width-ScreenTilesW)*bg.width*-1)) then
    allLayers:setX(bg:getX() + dx)
    startx = event.x
    end
    if (bg:getY() + dy) < 0 and ((bg:getY()+dy) > ((bg.height-ScreenTilesH)*bg.height*-1)) then
    bg:setY(bg:getY() + dy)
    starty = event.y
    end
    end
    end
    [/code]

    Best

    [ITALIAN]
    Ciao Gianluca,
    si hai centrato il problema,
    solo che a me basta applicarlo ad un immagine.

    Ho la mia immagine di BG
    local bg = Bitmap.new(TextureRegion.new(Texture.new("back.jpg")))
    stage:addChild(bg)

    su cui vorrei attaccare delle immagini.. e mi servirebbe che il bg non scompaia
    dall'area visibile


    Ho modificato la funzione un pò ma mi da errore

    [code]
    local function onMouseMove(event)
    if dragging then
    local ScreenTilesW = application:getDeviceWidth()
    local ScreenTilesH = application:getDeviceHeight()
    local dx = event.x - startx
    local dy = event.y - starty
    if ((bg:getX()+ dx) < 0) and ((bg:getX()+dx) > ((bg.width-ScreenTilesW)*bg.width*-1)) then
    allLayers:setX(bg:getX() + dx)
    startx = event.x
    end
    if (bg:getY() + dy) < 0 and ((bg:getY()+dy) > ((bg.height-ScreenTilesH)*bg.height*-1)) then
    bg:setY(bg:getY() + dy)
    starty = event.y
    end
    end
    end
    [/code]

    PS: tieni presente che ho visto LUA da solo 2 ore.. :)

    Ciao
    Ale
  • Hello Ale72,

    welcome on the forum. And please, speak english so everyone can participate in your discussions.

    Cheers
    Michael
    +1 -1 (+1 / -0 )Share on Facebook
  • Hello MikeHart,
    just translated in english.
    Sorry for the "mistake"

    Ale
Sign In or Register to comment.