How to save a file
How to publish a game
How to make a sprite have pathfinding
How to add an item in a grid container
How to show the amount of similar items in a item menu
How to create enemy AI
[how to get children nodes from a parent][get_children]
how to use the tween animation
how to turn off the collision of a node/object
How to clear/delete a node from a scene
How to transition to another scene
how to print something to console
how to get a position of a node
how to get a size of a texture/sprite
how to create an instance of an object
[how to create a timer in gdscript][timer-script]
View Content
reference
-
Click on the image in FileSystem folder
-
In the import tab on right of the screen disable
- Filter
- Mipmaps
- Anisotropic
- Now click on the button that says Reimport
View Content
onready var collection = $collection
var timer = Timer.new() # creates a new instance of a timer
func _ready():
timer.set_one_shot(true) # make sure the time doesn't repeat
timer.set_wait_time(5) # set's the countdown time in seconds
timer.connect("timeout", self, "on_timeout") # when the timer ends it call the function on_timeout
collection.add_child(timer)#this adds the timer in a node called collection
timer.start() #this starts the timer when you
pass
func _process(delta):
if paused:
print(timer.time_left) #if paused is true, it will print out the remaining time
pass
func on_timeout():
print("foo") # after the time end it will print into the console foo
View Content
var brick = bricks.instance()
# If I preloaded an object, this will create the object so that I can put it inside
# the scene
View Content
## this checks if the node is a Position2D type
if node is Position2D :
print("k")
View Content
reference
-
Add a node called ParallaxBackground
-
Select ParallaxBackground and add a child node called ParallaxLayer
-
Select ParallaxLayer and a add child node that can either be a TileMap or a Sprite.
-
In the options of the ParallaxLayer there is an called Scale. It has x and y coordinates, and this is the place where you will create the parallax effect. If you want the parallax scrolling to only happen horizontally then change the x coordinate. The default value is 1, but if you make it less than (for example: 0.5), the parallax effect will be more apparent.
-
There are other options like mirroring which will duplicate the image in the ParallaxLayer, and the offset option that position the image. But I haven't really used them that much
View Content
reference
Transition Type | Value |
---|---|
TRANS_LINEAR | 0 |
TRANS_SINE | 1 |
TRANS_QUINT | 2 |
TRANS_QUART | 3 |
TRANS_QUAD | 4 |
TRANS_EXPO | 5 |
TRANS_ELASTIC | 6 |
TRANS_CUBIC | 7 |
TRANS_CIRC | 8 |
TRANS_BOUNCE | 9 |
TRANS_BACK | 10 |
View Content
reference
There are many ways to change the property of a node, so these are a couple of examples of how to change it
syntax
$Tween.interpolate_property(Object, property, initial value, final value, duration time, transition type, ease type, delay time)
$Tween.interpolate_property($Sprite,"modulate", Color(1,1,1,1), Color(1,1,1,0),0.3, Tween.TRANS_QUAD, Tween.EASE_OUT )
View Content
reference
# when the potion collides with a body named isaiah
# shape_owner_clear_shapes will clear all the shapes as long as you have the owner id
# which will usually be 0
func _on_potion_body_entered(body):
if body.get("name") == "isaiah":
shape_owner_clear_shapes(0)
pass
# when the potion collides with a body named isaiah
# shape_owner_set_disabled will disable it as long as you have the boolean set to true
# and the owner id of collision shape which will be 0
func _on_potion_body_entered(body):
if body.get("name") == "isaiah":
shape_owner_set_disabled(0,true)
pass
View Content
You usually do this when you are using signals, but I guess you can do that in any other function
func on_gem_area_enter(area):
if area.get("name") == "player":
queue_free() #this will delete the node which is a gem
View Content
get_tree().change_scene("res://World2.tscn")
View Content
var sprite_size = get_texture().get_size()
View Content
print(get_pos())
View Content
var screensize = get_viewport_rect().size
print("someting to console")