You need to have four game objects, one per edge and one collision object per edge. Make the collision objects wider than the edges to accommodate for different aspect ratios.
Next step is to move them at run-time based on the screen size to keep them along the edges. You can get the screen size from the render script using the render.get_window_width/height(). These functions can only be called from the render script though. The easiest solution to this is to make a copy of the default render script and use that instead. In your copy you could add a message to query for window size:
function on_message(self, message_id, message)
if message_id == hash("query_window_size") then
msg.post(sender, "window_size", { width = render.get_window_width(), height = render.get_window_height() })
elseif .... rest of message handlers here
You use it from your script like this:
local function position_edges(width, height)
-- position edge game objects here
end
function init(self)
msg.post("@render:", "query_window_size")
end
function on_message(self, message_id, message, sender)
if message_id == hash("window_size") then
position_edges(message.width, message.height)
end
end