-
Notifications
You must be signed in to change notification settings - Fork 1
3.5 ‐ 02 Creating Elements
To explain GDScript's new
keyword and its difference with JavaScript, i'll need to quote 🔗 this comment
by p7f
new()
is used to create a node from the class. Thats why you must callvar img = Image.new()
, cause on the contrary, you would be trying to assign Image built in data type to the variable img. Why you do not call new in Vector2 then? Cause, acording to docs Vector2 is also a member function from the Vector2 built in type, that constructs a Vector2 object and returns it. So you dont call new because Vector2() is doing it for you. When you writevar vec = Vector2(10,20)
you are executingVector2()
function. Image does not have similar member function, so you must callnew
.
With this ECMAScript module, all elements from the Godot API are classes, meaning you'll need to always use the new
keyword followed by godot.ClassName
to create an element (exception made for the constants
)
new Class:ClassName(arguments?)
A brief yet explanatory way to hilight the differences
# GDScript
var center = Vector2(0,5)
var image = Image.new()
// JavaScript
export default myClass extends godot.Node() {
constructor() {
this.center = new godot.Vector2(0,5);
this.image = new godot.Image();
}
}
Here's the list of the 🔴 701 elements 🔴 you can create using
new godot.TYPE
you can find in 🔗 Godot's 3.5 API Documentation
⚠️ Please understand by clicking here this will show a very big list.
- godot.AABB
- godot.AcceptDialog
- godot.AESContext
- godot.AnimatedSprite
- godot.AnimatedSprite3D
- godot.AnimatedTexture
- godot.Animation
- godot.AnimationNode
- godot.AnimationNodeAdd2
- godot.AnimationNodeAdd3
- godot.AnimationNodeAnimation
- godot.AnimationNodeBlend2
- godot.AnimationNodeBlend3
- godot.AnimationNodeBlendSpace1D
- godot.AnimationNodeBlendSpace2D
- godot.AnimationNodeBlendTree
- godot.AnimationNodeOneShot
- godot.AnimationNodeOutput
- godot.AnimationNodeStateMachine
- godot.AnimationNodeStateMachinePlayback
- godot.AnimationNodeStateMachineTransition
- godot.AnimationNodeTimeScale
- godot.AnimationNodeTimeSeek
- godot.AnimationNodeTransition
- godot.AnimationPlayer
- godot.AnimationRootNode
- godot.AnimationTrackEditPlugin
- godot.AnimationTree
- godot.AnimationTreePlayer
- godot.Area
- godot.Area2D
- godot.Array
- godot.ArrayMesh
- godot.ARVRAnchor
- godot.ARVRCamera
- godot.ARVRController
- godot.ARVRInterface
- godot.ARVRInterfaceGDNative
- godot.ARVROrigin
- godot.ARVRPositionalTracker
- godot.ARVRServer
- godot.AspectRatioContainer
- godot.AStar
- godot.AStar2D
- godot.AtlasTexture
- godot.AudioBusLayout
- godot.AudioEffect
- godot.AudioEffectAmplify
- godot.AudioEffectBandLimitFilter
- godot.AudioEffectBandPassFilter
- godot.AudioEffectCapture
- godot.AudioEffectChorus
- godot.AudioEffectCompressor
- godot.AudioEffectDelay
- godot.AudioEffectDistortion
- godot.AudioEffectEQ
- godot.AudioEffectEQ10
- godot.AudioEffectEQ21
- godot.AudioEffectEQ6
- godot.AudioEffectFilter
- godot.AudioEffectHighPassFilter
- godot.AudioEffectHighShelfFilter
- godot.AudioEffectInstance
- godot.AudioEffectLimiter
- godot.AudioEffectLowPassFilter
- godot.AudioEffectLowShelfFilter
- godot.AudioEffectNotchFilter
- godot.AudioEffectPanner
- godot.AudioEffectPhaser
- godot.AudioEffectPitchShift
- godot.AudioEffectRecord
- godot.AudioEffectReverb
- godot.AudioEffectSpectrumAnalyzer
- godot.AudioEffectSpectrumAnalyzerInstance
- godot.AudioEffectStereoEnhance
- godot.AudioServer
- godot.AudioStream
- godot.AudioStreamGenerator
- godot.AudioStreamGeneratorPlayback
- godot.AudioStreamMicrophone
- godot.AudioStreamMP3
- godot.AudioStreamOGGVorbis
- godot.AudioStreamPlayback
- godot.AudioStreamPlaybackResampled
- godot.AudioStreamPlayer
- godot.AudioStreamPlayer2D
- godot.AudioStreamPlayer3D
- godot.AudioStreamRandomPitch
- godot.AudioStreamSample
- godot.BackBufferCopy
- godot.BakedLightmap
- godot.BakedLightmapData
- godot.BaseButton
- godot.Basis
- godot.BitMap
- godot.BitmapFont
- godot.Bone2D
- godot.BoneAttachment
- godot.bool
- godot.BoxContainer
- godot.BoxShape
- godot.Button
- godot.ButtonGroup
- godot.CallbackTweener
- godot.Camera
- godot.Camera2D
- godot.CameraFeed
- godot.CameraServer
- godot.CameraTexture
- godot.CanvasItem
- godot.CanvasItemMaterial
- godot.CanvasLayer
- godot.CanvasModulate
- godot.CapsuleMesh
- godot.CapsuleShape
- godot.CapsuleShape2D
- godot.CenterContainer
- godot.CharFXTransform
- godot.CheckBox
- godot.CheckButton
- godot.CircleShape2D
- godot.ClassDB
- godot.ClippedCamera
- godot.CollisionObject
- godot.CollisionObject2D
- godot.CollisionPolygon
- godot.CollisionPolygon2D
- godot.CollisionShape
- godot.CollisionShape2D
- godot.Color
- godot.ColorPicker
- godot.ColorPickerButton
- godot.ColorRect
- godot.ConcavePolygonShape
- godot.ConcavePolygonShape2D
- godot.ConeTwistJoint
- godot.ConfigFile
- godot.ConfirmationDialog
- godot.Container
- godot.Control
- godot.ConvexPolygonShape
- godot.ConvexPolygonShape2D
- godot.CPUParticles
- godot.CPUParticles2D
- godot.Crypto
- godot.CryptoKey
- godot.CSGBox
- godot.CSGCombiner
- godot.CSGCylinder
- godot.CSGMesh
- godot.CSGPolygon
- godot.CSGPrimitive
- godot.CSGShape
- godot.CSGSphere
- godot.CSGTorus
- godot.CSharpScript
- godot.CubeMap
- godot.CubeMesh
- godot.CullInstance
- godot.Curve
- godot.Curve2D
- godot.Curve3D
- godot.CurveTexture
- godot.CylinderMesh
- godot.CylinderShape
- godot.DampedSpringJoint2D
- godot.Dictionary
- godot.DirectionalLight
- godot.Directory
- godot.DTLSServer
- godot.DynamicFont
- godot.DynamicFontData
- godot.EditorExportPlugin
- godot.EditorFeatureProfile
- godot.EditorFileDialog
- godot.EditorFileSystem
- godot.EditorFileSystemDirectory
- godot.EditorImportPlugin
- godot.EditorInspector
- godot.EditorInspectorPlugin
- godot.EditorInterface
- godot.EditorPlugin
- godot.EditorProperty
- godot.EditorResourceConversionPlugin
- godot.EditorResourcePicker
- godot.EditorResourcePreview
- godot.EditorResourcePreviewGenerator
- godot.EditorSceneImporter
- godot.EditorSceneImporterFBX
- godot.EditorSceneImporterGLTF
- godot.EditorScenePostImport
- godot.EditorScript
- godot.EditorScriptPicker
- godot.EditorSelection
- godot.EditorSettings
- godot.EditorSpatialGizmo
- godot.EditorSpatialGizmoPlugin
- godot.EditorSpinSlider
- godot.EditorVCSInterface
- godot.EncodedObjectAsID
- godot.Engine
- godot.Environment
- godot.Expression
- godot.ExternalTexture
- godot.File
- godot.FileDialog
- godot.FileSystemDock
- godot.float
- godot.FlowContainer
- godot.Font
- godot.FuncRef
- godot.GDNative
- godot.GDNativeLibrary
- godot.GDScript
- godot.GDScriptFunctionState
- godot.Generic6DOFJoint
- godot.Geometry
- godot.GeometryInstance
- godot.GIProbe
- godot.GIProbeData
- godot.GLTFAccessor
- godot.GLTFAnimation
- godot.GLTFBufferView
- godot.GLTFCamera
- godot.GLTFDocument
- godot.GLTFLight
- godot.GLTFMesh
- godot.GLTFNode
- godot.GLTFSkeleton
- godot.GLTFSkin
- godot.GLTFSpecGloss
- godot.GLTFState
- godot.GLTFTexture
- godot.GodotSharp
- godot.Gradient
- godot.GradientTexture
- godot.GradientTexture2D
- godot.GraphEdit
- godot.GraphNode
- godot.GridContainer
- godot.GridMap
- godot.GrooveJoint2D
- godot.HashingContext
- godot.HBoxContainer
- godot.HeightMapShape
- godot.HFlowContainer
- godot.HingeJoint
- godot.HMACContext
- godot.HScrollBar
- godot.HSeparator
- godot.HSlider
- godot.HSplitContainer
- godot.HTTPClient
- godot.HTTPRequest
- godot.Image
- godot.ImageTexture
- godot.ImmediateGeometry
- godot.Input
- godot.InputEvent
- godot.InputEventAction
- godot.InputEventGesture
- godot.InputEventJoypadButton
- godot.InputEventJoypadMotion
- godot.InputEventKey
- godot.InputEventMagnifyGesture
- godot.InputEventMIDI
- godot.InputEventMouse
- godot.InputEventMouseButton
- godot.InputEventMouseMotion
- godot.InputEventPanGesture
- godot.InputEventScreenDrag
- godot.InputEventScreenTouch
- godot.InputEventWithModifiers
- godot.InputMap
- godot.InstancePlaceholder
- godot.int
- godot.InterpolatedCamera
- godot.IntervalTweener
- godot.IP
- godot.ItemList
- godot.JavaClass
- godot.JavaClassWrapper
- godot.JavaScript
- godot.JavaScriptObject
- godot.JNISingleton
- godot.Joint
- godot.Joint2D
- godot.JSON
- godot.JSONParseResult
- godot.JSONRPC
- godot.KinematicBody
- godot.KinematicBody2D
- godot.KinematicCollision
- godot.KinematicCollision2D
- godot.Label
- godot.Label3D
- godot.LargeTexture
- godot.Light
- godot.Light2D
- godot.LightOccluder2D
- godot.Line2D
- godot.LineEdit
- godot.LineShape2D
- godot.LinkButton
- godot.Listener
- godot.Listener2D
- godot.MainLoop
- godot.MarginContainer
- godot.Marshalls
- godot.Material
- godot.MenuButton
- godot.Mesh
- godot.MeshDataTool
- godot.MeshInstance
- godot.MeshInstance2D
- godot.MeshLibrary
- godot.MeshTexture
- godot.MethodTweener
- godot.MobileVRInterface
- godot.MultiMesh
- godot.MultiMeshInstance
- godot.MultiMeshInstance2D
- godot.MultiplayerAPI
- godot.MultiplayerPeerGDNative
- godot.Mutex
- godot.NativeScript
- godot.Navigation
- godot.Navigation2D
- godot.Navigation2DServer
- godot.NavigationAgent
- godot.NavigationAgent2D
- godot.NavigationMesh
- godot.NavigationMeshGenerator
- godot.NavigationMeshInstance
- godot.NavigationObstacle
- godot.NavigationObstacle2D
- godot.NavigationPolygon
- godot.NavigationPolygonInstance
- godot.NavigationServer
- godot.NetworkedMultiplayerCustom
- godot.NetworkedMultiplayerENet
- godot.NetworkedMultiplayerPeer
- godot.NinePatchRect
- godot.Node
- godot.Node2D
- godot.NodePath
- godot.NoiseTexture
- godot.Object
- godot.Occluder
- godot.OccluderPolygon2D
- godot.OccluderShape
- godot.OccluderShapePolygon
- godot.OccluderShapeSphere
- godot.OmniLight
- godot.OpenSimplexNoise
- godot.OptionButton
- godot.OS
- godot.PackedDataContainer
- godot.PackedDataContainerRef
- godot.PackedScene
- godot.PackedSceneGLTF
- godot.PacketPeer
- godot.PacketPeerDTLS
- godot.PacketPeerGDNative
- godot.PacketPeerStream
- godot.PacketPeerUDP
- godot.Panel
- godot.PanelContainer
- godot.PanoramaSky
- godot.ParallaxBackground
- godot.ParallaxLayer
- godot.Particles
- godot.Particles2D
- godot.ParticlesMaterial
- godot.Path
- godot.Path2D
- godot.PathFollow
- godot.PathFollow2D
- godot.PCKPacker
- godot.Performance
- godot.PHashTranslation
- godot.PhysicalBone
- godot.Physics2DDirectBodyState
- godot.Physics2DDirectSpaceState
- godot.Physics2DServer
- godot.Physics2DShapeQueryParameters
- godot.Physics2DTestMotionResult
- godot.PhysicsBody
- godot.PhysicsBody2D
- godot.PhysicsDirectBodyState
- godot.PhysicsDirectSpaceState
- godot.PhysicsMaterial
- godot.PhysicsServer
- godot.PhysicsShapeQueryParameters
- godot.PhysicsTestMotionResult
- godot.PinJoint
- godot.PinJoint2D
- godot.Plane
- godot.PlaneMesh
- godot.PlaneShape
- godot.PluginScript
- godot.PointMesh
- godot.Polygon2D
- godot.PolygonPathFinder
- godot.PoolByteArray
- godot.PoolColorArray
- godot.PoolIntArray
- godot.PoolRealArray
- godot.PoolStringArray
- godot.PoolVector2Array
- godot.PoolVector3Array
- godot.Popup
- godot.PopupDialog
- godot.PopupMenu
- godot.PopupPanel
- godot.Portal
- godot.Position2D
- godot.Position3D
- godot.PrimitiveMesh
- godot.PrismMesh
- godot.ProceduralSky
- godot.ProgressBar
- godot.ProjectSettings
- godot.PropertyTweener
- godot.ProximityGroup
- godot.ProxyTexture
- godot.QuadMesh
- godot.Quat
- godot.RandomNumberGenerator
- godot.Range
- godot.RayCast
- godot.RayCast2D
- godot.RayShape
- godot.RayShape2D
- godot.Rect2
- godot.RectangleShape2D
- godot.Reference
- godot.ReferenceRect
- godot.ReflectionProbe
- godot.RegEx
- godot.RegExMatch
- godot.RemoteTransform
- godot.RemoteTransform2D
- godot.Resource
- godot.ResourceFormatLoader
- godot.ResourceFormatSaver
- godot.ResourceImporter
- godot.ResourceInteractiveLoader
- godot.ResourceLoader
- godot.ResourcePreloader
- godot.ResourceSaver
- godot.RichTextEffect
- godot.RichTextLabel
- godot.RID
- godot.RigidBody
- godot.RigidBody2D
- godot.Room
- godot.RoomGroup
- godot.RoomManager
- godot.RootMotionView
- godot.SceneState
- godot.SceneTree
- godot.SceneTreeTimer
- godot.SceneTreeTween
- godot.Script
- godot.ScriptCreateDialog
- godot.ScriptEditor
- godot.ScrollBar
- godot.ScrollContainer
- godot.SegmentShape2D
- godot.Semaphore
- godot.Separator
- godot.Shader
- godot.ShaderMaterial
- godot.Shape
- godot.Shape2D
- godot.ShortCut
- godot.Skeleton
- godot.Skeleton2D
- godot.SkeletonIK
- godot.Skin
- godot.SkinReference
- godot.Sky
- godot.Slider
- godot.SliderJoint
- godot.SoftBody
- godot.Spatial
- godot.SpatialGizmo
- godot.SpatialMaterial
- godot.SpatialVelocityTracker
- godot.SphereMesh
- godot.SphereShape
- godot.SpinBox
- godot.SplitContainer
- godot.SpotLight
- godot.SpringArm
- godot.Sprite
- godot.Sprite3D
- godot.SpriteBase3D
- godot.SpriteFrames
- godot.StaticBody
- godot.StaticBody2D
- godot.StreamPeer
- godot.StreamPeerBuffer
- godot.StreamPeerGDNative
- godot.StreamPeerSSL
- godot.StreamPeerTCP
- godot.StreamTexture
- godot.String
- godot.StyleBox
- godot.StyleBoxEmpty
- godot.StyleBoxFlat
- godot.StyleBoxLine
- godot.StyleBoxTexture
- godot.SurfaceTool
- godot.TabContainer
- godot.Tabs
- godot.TCP_Server
- godot.TextEdit
- godot.TextFile
- godot.TextMesh
- godot.Texture
- godot.Texture3D
- godot.TextureArray
- godot.TextureButton
- godot.TextureLayered
- godot.TextureProgress
- godot.TextureRect
- godot.Theme
- godot.Thread
- godot.TileMap
- godot.TileSet
- godot.Time
- godot.Timer
- godot.ToolButton
- godot.TouchScreenButton
- godot.Transform
- godot.Transform2D
- godot.Translation
- godot.TranslationServer
- godot.Tree
- godot.TreeItem
- godot.TriangleMesh
- godot.Tween
- godot.Tweener
- godot.UDPServer
- godot.UndoRedo
- godot.UPNP
- godot.UPNPDevice
- godot.Variant
- godot.VBoxContainer
- godot.Vector2
- godot.Vector3
- godot.VehicleBody
- godot.VehicleWheel
- godot.VFlowContainer
- godot.VideoPlayer
- godot.VideoStream
- godot.VideoStreamGDNative
- godot.VideoStreamTheora
- godot.VideoStreamWebm
- godot.Viewport
- godot.ViewportContainer
- godot.ViewportTexture
- godot.VisibilityEnabler
- godot.VisibilityEnabler2D
- godot.VisibilityNotifier
- godot.VisibilityNotifier2D
- godot.VisualInstance
- godot.VisualScript
- godot.VisualScriptBasicTypeConstant
- godot.VisualScriptBuiltinFunc
- godot.VisualScriptClassConstant
- godot.VisualScriptComment
- godot.VisualScriptComposeArray
- godot.VisualScriptCondition
- godot.VisualScriptConstant
- godot.VisualScriptConstructor
- godot.VisualScriptCustomNode
- godot.VisualScriptDeconstruct
- godot.VisualScriptEditor
- godot.VisualScriptEmitSignal
- godot.VisualScriptEngineSingleton
- godot.VisualScriptExpression
- godot.VisualScriptFunction
- godot.VisualScriptFunctionCall
- godot.VisualScriptFunctionState
- godot.VisualScriptGlobalConstant
- godot.VisualScriptIndexGet
- godot.VisualScriptIndexSet
- godot.VisualScriptInputAction
- godot.VisualScriptIterator
- godot.VisualScriptLists
- godot.VisualScriptLocalVar
- godot.VisualScriptLocalVarSet
- godot.VisualScriptMathConstant
- godot.VisualScriptNode
- godot.VisualScriptOperator
- godot.VisualScriptPreload
- godot.VisualScriptPropertyGet
- godot.VisualScriptPropertySet
- godot.VisualScriptResourcePath
- godot.VisualScriptReturn
- godot.VisualScriptSceneNode
- godot.VisualScriptSceneTree
- godot.VisualScriptSelect
- godot.VisualScriptSelf
- godot.VisualScriptSequence
- godot.VisualScriptSubCall
- godot.VisualScriptSwitch
- godot.VisualScriptTypeCast
- godot.VisualScriptVariableGet
- godot.VisualScriptVariableSet
- godot.VisualScriptWhile
- godot.VisualScriptYield
- godot.VisualScriptYieldSignal
- godot.VisualServer
- godot.VisualShader
- godot.VisualShaderNode
- godot.VisualShaderNodeBooleanConstant
- godot.VisualShaderNodeBooleanUniform
- godot.VisualShaderNodeColorConstant
- godot.VisualShaderNodeColorFunc
- godot.VisualShaderNodeColorOp
- godot.VisualShaderNodeColorUniform
- godot.VisualShaderNodeCompare
- godot.VisualShaderNodeCubeMap
- godot.VisualShaderNodeCubeMapUniform
- godot.VisualShaderNodeCustom
- godot.VisualShaderNodeDeterminant
- godot.VisualShaderNodeDotProduct
- godot.VisualShaderNodeExpression
- godot.VisualShaderNodeFaceForward
- godot.VisualShaderNodeFresnel
- godot.VisualShaderNodeGlobalExpression
- godot.VisualShaderNodeGroupBase
- godot.VisualShaderNodeIf
- godot.VisualShaderNodeInput
- godot.VisualShaderNodeIs
- godot.VisualShaderNodeOuterProduct
- godot.VisualShaderNodeOutput
- godot.VisualShaderNodeScalarClamp
- godot.VisualShaderNodeScalarConstant
- godot.VisualShaderNodeScalarDerivativeFunc
- godot.VisualShaderNodeScalarFunc
- godot.VisualShaderNodeScalarInterp
- godot.VisualShaderNodeScalarOp
- godot.VisualShaderNodeScalarSmoothStep
- godot.VisualShaderNodeScalarSwitch
- godot.VisualShaderNodeScalarUniform
- godot.VisualShaderNodeSwitch
- godot.VisualShaderNodeTexture
- godot.VisualShaderNodeTextureUniform
- godot.VisualShaderNodeTextureUniformTriplanar
- godot.VisualShaderNodeTransformCompose
- godot.VisualShaderNodeTransformConstant
- godot.VisualShaderNodeTransformDecompose
- godot.VisualShaderNodeTransformFunc
- godot.VisualShaderNodeTransformMult
- godot.VisualShaderNodeTransformUniform
- godot.VisualShaderNodeTransformVecMult
- godot.VisualShaderNodeUniform
- godot.VisualShaderNodeUniformRef
- godot.VisualShaderNodeVec3Constant
- godot.VisualShaderNodeVec3Uniform
- godot.VisualShaderNodeVectorClamp
- godot.VisualShaderNodeVectorCompose
- godot.VisualShaderNodeVectorDecompose
- godot.VisualShaderNodeVectorDerivativeFunc
- godot.VisualShaderNodeVectorDistance
- godot.VisualShaderNodeVectorFunc
- godot.VisualShaderNodeVectorInterp
- godot.VisualShaderNodeVectorLen
- godot.VisualShaderNodeVectorOp
- godot.VisualShaderNodeVectorRefract
- godot.VisualShaderNodeVectorScalarMix
- godot.VisualShaderNodeVectorScalarSmoothStep
- godot.VisualShaderNodeVectorScalarStep
- godot.VisualShaderNodeVectorSmoothStep
- godot.VScrollBar
- godot.VSeparator
- godot.VSlider
- godot.VSplitContainer
- godot.WeakRef
- godot.WebRTCDataChannel
- godot.WebRTCDataChannelGDNative
- godot.WebRTCMultiplayer
- godot.WebRTCPeerConnection
- godot.WebRTCPeerConnectionGDNative
- godot.WebSocketClient
- godot.WebSocketMultiplayerPeer
- godot.WebSocketPeer
- godot.WebSocketServer
- godot.WebXRInterface
- godot.WindowDialog
- godot.World
- godot.World2D
- godot.WorldEnvironment
- godot.X509Certificate
- godot.XMLParser
- godot.YSort