0 votes

I want to make my game run inside a border (like a television border etc) Which nodes I have to use for this?

in Engine by (23 points)

1 Answer

0 votes
Best answer

UseSprite for border and attach it as a child of Camera2D
Update
Viewport version would involve few steps:

1.Creating main scene containing "border", Viewport, and Sprite
2. Creating level scene - actual game that will be played
3. Attaching level.tscn as viewport child
4. setting rendertarget.vflip on viewport
5. Attaching into sprite texture new ViewPortTexture
6.setting appropriate dimension of sprite and viewport

here demo of above in my godot-recipes project

by (1,022 points)
edited by

erm not so simple like this, i think its something with viewport like this:

https://steamuserimages-a.akamaihd.net/ugc/178286345952729981/7F26AE7FE447D29EB3B82F946D32B8A103A50F4B/

It is that simple, just ensure that border sprite is at the top. I'll admit though it is a little wasteful - engine will still try to render those parts of scene that are hidden by border, but today GPUs are smart enough to skip those hidden pixel. So give it a go and if you find that it affects performance to much I'll explained how to achieve what you want using vieport.

Thankyou very much, I would like to know how to do it using viewport too, for understand better the viewport node use, cause documents doen't explain cleary

check updated answer and look at linked files, if something still unclear ask

it worked perfectly thanks a lot! But the scene inside doesn't respond, I mean, it has some input codes that doesn't work, do I have to create setter variables to send the key commands or there's another easier/better way?

I've updated linked demo with this code to make input works

extends Node

export(NodePath) var viewport_node = "../Viewport"

onready var target = get_node(viewport_node).get_child(0)

func _ready():
    set_process_input(true)
    pass

func _input(event): 
    target._input(event)

Thankyu again, now everything works fine, thankyu very much ^^

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.