0 votes

I created a room with sprites. and I want to place an object in that room.

Is there any other way to arrange the room locations?

Sorry for my weird english.

thank you.

Godot version 3.3.2
in Engine by (66 points)

Can you tell more about the background of the game. What you want to do is not clear

1 Answer

+1 vote

Assuming that the objects are like table, chair, furniture etc. And your game has nothing to do with collisions of the room and player. And the objects and your room are just static images.
Then you can add more sprites for your objects to overlap the room.

Or if you want to add these objects during the game then

func _input(event):
    if event.is_action_pressed("click"):
        var sprite = Sprite.new()
        sprite.texture =  preload("res://icon.png")
        sprite.position = event.get_position()
        add_child(sprite)

You just have to add an input named click with action left button of mouse

I am not clear about your question. Sorry if it's not the answer.
If you tell more about the background of the game then I can tell you better answer. What you want to do is not clear

by (881 points)

Thank to your answer and sorry for my ambiguous question.

I was make my room generation like the Binding of Isaac.(if player entered the door, add child nextroom and remove child currentroom)

I want to know as arrange rock, or another objects regularly to their rooms. (specific rule?)

use array get the vaule of room position? and In array, whether there is or not objects (empty => 0, object1 => 1 etc.)

I think there is only that. Is there any other good way? If you create an array, the x and y indexes exceed 20, so it doesn't seem like a good way. (By default, there are more than 10 rooms.)

https://drive.google.com/file/d/105zFT2JzIPe5T1aTbhVlhhZL4yIa9dV-/view?usp=sharing
I explained by painting.

If you want to make the room during the game then probably you have to use an array. When I was making my game of building then I myself used an array and checked if that coordinate is in that array or not and then acted accordingly.

Or you can make the room in the editor and then add that as child.

Thanks for your knowledge. After all, there will be only an array.

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 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 webmaster@godotengine.org with your username.