|
|
|
|
Reply From: |
Footurist |
First, you have some luck, because with RigidBodies scaling can be a bit annoying, since they reset their scaling at runtime, but static ones work fine for this. What you’re looking for is called tool mode. If you write tool at the very top of your script, you can see editor changes in realtime. You can use the keyword setget to set up setter functions, which will do the trick. It looks like this:
tool
extends StaticBody2D
var ready_called = false
export (Vector2) var my_scale setget set_my_scale
func _ready():
ready_called = true
func set_my_scale(value):
my_scale = value
if ready_called:
scale = my_scale
I think you don’t need to use setters for in-built properties, but I wanted to show you how it works. The flag test is there, because it prevents Godot from calling the setter when the object’s properties aren’t yet set when you run the project.
Can we rewind a little bit?
Firstly, I can’t even seem to make a wall that I can scale in one direction, and has colour (filled).
My stack seems to be wrong. Or I’m misunderstanding something about how to build a wall object.
confused | 2018-03-12 18:10
btw, I mean to be able to edit this in the editor, with the handles… kind of just like how this might be done in any other visual editor, from Unity to 3ds Max to Photoshop and everything in between.
Then change the colour of some of these wall segments. etc. Just as though this was a 2D visual editor.
confused | 2018-03-12 18:13
edited question to better explain what I’m trying to do.
confused | 2018-03-12 18:29
The correct hirarchy for a “wall object”, which can collide, is as follows:
StaticBody2D
-CollisionShape2D
-Sprite
Then, you can select the selection tool (arrow) and drag the vertices. However, this is not always advised, because this way you scale the object, that is selected in the hirarchy, which in your case is fine. All CanvasItems have a property “modulate”. Since a lot of nodes inherit from CanvasItem, you can change the modulate of most nodes to change the color. You’ll find this property in the inspector of the node.
Btw: The children do not have to be in a certain order in that specific case.
Footurist | 2018-03-12 20:58