A
Anti-Icarus
Guest
I'm working on an endless scrolling shmup and I'm having a bit of difficulty implementing the use of a shield in it. I want to have enemies sometimes drop a few power-ups upon death. On one hand, I managed to get a functioning power-up that upgrades the number and power of my player character's shots. Getting the shield power-up to work, on the other hand, has proven to be a more complicated matter. I Googled the issue, found this forum thread, and attempted to copy and implement the suggested code in the shield object's Create and Step events. But for some reason it doesn't seem to work.
In my player character's collision event with the shield power-up object, that object gets destroyed and creates an instance of the shield object like this:
I ended up getting the following message the moment I collided with the shield power-up as I ran my game:
To be more specific, I'm trying to make a shield around the player character that would briefly protect him from one hit kills for a few seconds. Based on the thread I read, I wrote the following code for the shield's Create event:
and it's Step event:
And my Alarm[0] event is set to destroy the shield instance after 4 seconds.
It's obvious that my circumstances were different from the ones experienced by the forum thread's original author and I'm convinced that the code that solved the author's problems does not work for me. What would be the most efficient way to create a shield around the player that lasts for 4 seconds upon collision with the shield power-up object?
In my player character's collision event with the shield power-up object, that object gets destroyed and creates an instance of the shield object like this:
I ended up getting the following message the moment I collided with the shield power-up as I ran my game:
When I had it apply to the Other object (the shield being created), the shield just doesn't appear at all.ERROR!!! :: ############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_Shield:
PerformEvent recursion depth failure - check for infinite loops, check objects for parenting
at gml_Object_obj_Shield_CreateEvent_1 (line 4) - with (instance_create (x, y, obj_Shield))
To be more specific, I'm trying to make a shield around the player character that would briefly protect him from one hit kills for a few seconds. Based on the thread I read, I wrote the following code for the shield's Create event:
Code:
image_speed = 30;
alarm[0] = 120;
with (instance_create (x, y, obj_Shield))
{
follow = other.id;
}
Code:
if instance_exists(follow)
{
x = follow.x;
y = follow.y;
}
else instance_destroy();
It's obvious that my circumstances were different from the ones experienced by the forum thread's original author and I'm convinced that the code that solved the author's problems does not work for me. What would be the most efficient way to create a shield around the player that lasts for 4 seconds upon collision with the shield power-up object?
Attachments
-
37.4 KB Views: 5