I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: PlasmaKaboom on December 23, 2016, 12:31:21 PM

Title: Is there a way to make an item permanently change the player's bow sprite?
Post by: PlasmaKaboom on December 23, 2016, 12:31:21 PM
I am trying to make it so that once my player touches the "objSecretItem", the item changes my player's bow sprite permanently.

I am new to GameMaker and coding in general so I'm sure there is probably a simple answer for this.

The closest I have gotten to getting it to work is by modifying the already premade "objSecretItem" by adding a "change instance" under "actions" that changes "objBow" to "objBow2" (my bow sprite I made). When I press reset or warp to another room, the bow's new sprite stays there, however; when I die it returns back to the original sprite. I want it to keep the new sprite I made even after I die.

Am I doing this in a weird way? Am I making it too complicated? Any help would be appreciated
Title: Re: Is there a way to make an item permanently change the player's bow sprite?
Post by: patrickgh3 on December 26, 2016, 12:22:37 AM
Hi Plasma. So the way I would do this is to add code in the step event of objBow that detects if the secret is gotten, and if true, then delete itself and create an objBow2. So like what you did, but inside the bow step event instead of the objSecretItem collision event. The code would be

Code: [Select]
if (global.secretItem[0]) { // replace 0 with your item number
    instance_destroy();
    instance_create(x, y, objBow2);
}

You can also copy this code to the create event which should get rid of the 1-frame delay when you respawn.
Title: Re: Is there a way to make an item permanently change the player's bow sprite?
Post by: PlasmaKaboom on December 27, 2016, 12:49:01 PM
Wow you've saved me twice now!  :wixSanic: Thanks alot this was driving me crazy!