global_position = global_position get_parent (). While the in-game story may take a few turns for the serious, RAID: Shadow Legends is a fun and complex experience at heart. queue_free () func instance_scene ( scene ): var new_scene = scene. texture = texture_default # if the enemy should be dead if TYPE = "ENEMY" & health newitem. play ( newanim ) func damage_loop (): # If you're in hitstun countdown the timer health = min ( health, MAXHEALTH ) if hitstun > 0 : hitstun -= 1 $ Sprite. "animation" is a string # of the sort "idle", "push", or "walk" func anim_switch ( animation ): var newanim = str ( animation, spritedir ) if $ anim. DOWN : spritedir = "down" # This changes our player animation. ZERO ) func spritedir_loop (): match movedir : Vector2. normalized () * 125 # move_and_slide takes care of collisions and has you slide # along walls that are blocking your path move_and_slide ( motion, Vector2. normalized () * SPEED else : motion = knockdir. replace ( ".png", "_hurt.png" )) func movement_loop (): var motion # if you aren't in hitstun then move normally # otherwise get knocked back if hitstun = 0 : motion = movedir. png with _hurt.png texture_hurt = load ( $ Sprite. texture # make the hurt texture the same name and path as the default texture # but replace. ZERO var spritedir = "down" var hitstun = 0 var health = MAXHEALTH var texture_default = null var texture_hurt = null func _ready (): # keep the enemies frozen until they enter the camera scene if TYPE = "ENEMY" : set_physics_process ( false ) # set the collision mask to collide with the # walls in the camera scene set_collision_mask_bit ( 1, 1 ) texture_default = $ Sprite. new () # "CONSTANTS" var SPEED = 0 var TYPE = "ENEMY" var DAMAGE = null var MAXHEALTH = 1 # MOVEMENT var movedir = Vector2. Class_name entity extends KinematicBody2D # we put this here instead of autoloading it # nothing wrong with autoload, but I prefer things in the code var dir = directions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |