local pauser={}
function pauser:think()
	if game.player.destroyed then return 1 end
	if Keyboard.isKeyDown("ENTER") and game.pausetimeout>20 then
		local menu = Container:new(0,0,100,50)
		local function addlabel(x,y,w,h,tx,to,center)
			local text = (to or menu):add(Label:new(x,y,w,h,tx))
			text:setFontColor(0,1,0,1)
			if center then
				text:setAlignment(Label.LABEL_ALIGNCENTERED,Label.LABEL_ALIGNCENTERED)
				--text:getSkin():setFontColor(0,1,0,1)
			else
				text:setAlignment(nil,Label.LABEL_ALIGNTOP)
				--text:getSkin():setFontColor(0,1,0,1)
			end
			return text
		end
		
		local function addbutton(x,y,w,h,to,tx,fun)
			local btn = (to or menu):add(Button:new(x,y,w,h,tx))
			btn.onClicked = fun
			btn:getSkin():setSkinColor(0,1,0,.3)
			btn:getSkin():setFontColor(0,1,0,1)
			return btn
		end



		addlabel(0,0,100,20,"Paused",nil,true)
		local btn = addbutton(10,20,80,20,nil,"To main menu",startmenu)
		function btn:isFocusable() return false end
		game : showMenu (menu)
	end
end

game:addthink(pauser)