Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
viewing outside of the player — Gideros Forum

viewing outside of the player

is there a way to view (gideros player) outside of the frame where we define our logical width and height? like the box2d collision example, where the box is created outside of the frame with the value -ve i would like the option to see it, as i want to make a platformer type game where the "stage" is bigger then the screen size, i hope i'am making myself clear
Hello everyone, my name is Tulip, nice to meet you.

Comments

  • SinisterSoftSinisterSoft Maintainer
    Just draw outside, negative coords, etc...
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • bot?
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • rrraptorrrraptor Member
    edited June 2020
    You can use my camera library :smile: (see signature)


    local random = math.random
    local function frandom(min, max) 
    	return min + (max-min) * random() 
    end
     
    local Layer = Sprite.new()
    local RECT_SIZE = 10000
     
    local cam = GCam.new(Layer)
    cam:setAutoSize(true)
    cam:setBounds(-RECT_SIZE, -RECT_SIZE, RECT_SIZE, RECT_SIZE)
    cam:goto(cam.w / 2, cam.h / 2)
    --cam:setDebug(true)
    stage:addChild(cam)
    Layer:addChild(Pixel.new(0,0.5, cam.w,cam.h))
     
    for i = 1, 20000 do 
    	local sq = Pixel.new(random(0xffffff), frandom(0.5, 1), 
    		random(10,80), random(10,80)
    	)
    	sq:setAnchorPoint(.5,.5)
    	sq:setRotation(random() * 360)
    	sq:setPosition(
    		random(-RECT_SIZE, RECT_SIZE),
    		random(-RECT_SIZE, RECT_SIZE)
    	)
    	Layer:addChild(sq)
    end
     
    local tf0 = TextField.new(nil, "x: 0\ny: 0", "|")
    tf0:setScale(2)
    Layer:addChild(tf0)
     
    local tf1 = TextField.new(nil, ("x: %i\ny: %i"):format(-RECT_SIZE, -RECT_SIZE), "|")
    tf1:setPosition(-RECT_SIZE, -RECT_SIZE)
    tf1:setScale(2)
    Layer:addChild(tf1)
     
    local tf2 = TextField.new(nil, ("x: %i\ny: %i"):format(RECT_SIZE, RECT_SIZE), "|")
    tf2:setPosition(RECT_SIZE, RECT_SIZE)
    tf2:setScale(2)
    Layer:addChild(tf2)
     
    local px,py = 0,0
    stage:addEventListener("mouseDown", function(e)
    	px,py = e.x,e.y
    end)
    stage:addEventListener("mouseMove", function(e)
    	local x,y = e.x,e.y
    	local dx = x - px
    	local dy = y - py
    	local zoom = cam:getZoom()
    	cam:move(-dx / zoom,-dy / zoom)
     
    	px,py = x,y
    end)
    stage:addEventListener("mouseWheel", function(e)
    	if e.wheel < 0 then
    		cam:zoom(-0.1)
    	else
    		cam:zoom(0.1)
    	end
     
    	local zoom = cam:getZoom()
    	tf0:setScale(2 / zoom)
    	tf1:setScale(2 / zoom)
    	tf2:setScale(2 / zoom)
    end)
    cam.gif
    618 x 319 - 1M
    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.