Improved html5 performance
This commit is contained in:
parent
1aff15069a
commit
af41271af2
9 changed files with 63 additions and 54 deletions
|
|
@ -17,7 +17,7 @@ var map_reference: HexGrid
|
|||
|
||||
var is_active: bool = true
|
||||
|
||||
const BUILD_GHOST = preload("res://InsectTiles/BuildGhost.tscn")
|
||||
const BUILD_GHOST: PackedScene = preload("res://InsectTiles/BuildGhost.tscn")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if insect_resource == null:
|
||||
|
|
@ -28,6 +28,14 @@ func _ready():
|
|||
GameEvents.insect_tile_moved.connect(_on_insect_tile_moved)
|
||||
else:
|
||||
GameEvents.insect_placed.connect(_on_insect_placed)
|
||||
|
||||
tile = BUILD_GHOST.instantiate()
|
||||
tile.resource = insect_resource
|
||||
tile.is_black = is_black
|
||||
tile.map_reference = map_reference
|
||||
|
||||
add_child(tile)
|
||||
tile.visible = false
|
||||
|
||||
func _on_insect_tile_moved(tile: InsectTile, to: Vector4i) -> void:
|
||||
is_active = false
|
||||
|
|
@ -39,31 +47,23 @@ func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector4i) ->
|
|||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
func _input_event(camera, event, position, normal, shape_idx):
|
||||
|
||||
func _on_mouse_entered():
|
||||
hovered = true
|
||||
tile.visible = true
|
||||
|
||||
func _on_input_event(camera, event, position, normal, shape_idx):
|
||||
if Input.is_action_just_pressed("place_tile") and is_active:
|
||||
if hovered:
|
||||
if is_moving:
|
||||
GameEvents.insect_tile_moved.emit(insect_tile, coordinates)
|
||||
else:
|
||||
GameEvents.insect_placed.emit(insect_resource, is_black, coordinates)
|
||||
|
||||
func _on_mouse_entered():
|
||||
hovered = true
|
||||
|
||||
tile = BUILD_GHOST.instantiate()
|
||||
tile.resource = insect_resource
|
||||
tile.is_black = is_black
|
||||
tile.map_reference = map_reference
|
||||
|
||||
add_child(tile)
|
||||
|
||||
func _on_input_event(camera, event, position, normal, shape_idx):
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_mouse_exited():
|
||||
hovered = false
|
||||
|
||||
if tile:
|
||||
tile.queue_free()
|
||||
tile = null
|
||||
tile.visible = false
|
||||
#if tile:
|
||||
#tile.queue_free()
|
||||
#tile = null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue