Solved Is it a bug? I found something strange.

Question that is answered or resolved.

DD Tokki

Well-known member
name R-coin
type item
subtype touch
score 100
nolife 1
facing 1
gfxshadow 1 1

anim idle
loop 0
delay 3
offset 11 31
itembox 3 16 16 16
frame data/sprites/cr/misc/co/coin-01.gif
frame data/sprites/cr/misc/co/coin-02.gif
frame data/sprites/cr/misc/co/coin-03.gif
sound data/sounds/coin.wav
frame data/sprites/cr/misc/co/coin-04.gif
frame data/sprites/cr/misc/co/coin-05.gif
frame data/sprites/cr/misc/co/coin-06.gif
frame data/sprites/cr/misc/co/coin-07.gif
frame data/sprites/cr/misc/co/coin-08.gif
frame data/sprites/cr/misc/co/coin-09.gif
frame data/sprites/cr/misc/co/coin-10.gif
frame data/sprites/cr/misc/co/coin-11.gif
frame data/sprites/cr/misc/co/coin-12.gif
frame data/sprites/cr/misc/co/coin-13.gif
frame data/sprites/cr/misc/co/coin-14.gif
frame data/sprites/cr/misc/co/coin-15.gif
frame data/sprites/cr/misc/co/coin-16.gif
frame data/sprites/cr/misc/co/coin-17.gif
frame data/sprites/cr/misc/co/coin-18.gif
@cmd updateframe getlocalvar("self") 0
frame data/sprites/cr/misc/co/coin-18.gif


This is an item I am working on.
As you can see, there is an update frame at the end, so we loop.
A sound file is inserted in the middle, but if you have an item, the item disappears and the sound should also end, but the sound continues for a while.
I wondered if there was a problem with my game, so I inserted a sound into an item with Beats of Rage, and it's the same symptom. Any solution?
 
Solution
Firstly you can replace: @cmd updateframe getlocalvar("self") 0 with: loop 1 no need to use scripts when you don't need them.

Secondly when you pick up a item a didhitscript is activated this can be used to stop the items animation so the sound will no longer play. make a file "data/scripts/item.c" and add it to your items header like this "didhitscript data/scripts/item.c" now open the item.c and copy this in there:

C-like:
void main()
{
    void self = getlocalvar("self");
    changeentityproperty(self,"aiflag","animating",0);
}
Certain item types Items are technically still in play when picked up, they are just moved offscreen. That's why you still hear the sound playing. This behavior is intentional and necessary for the item to work.

You might need to handle the sound with a script so you can stop it playing after pickup, but I'll try and check later today if there is an easier solution.

DC
 
Firstly you can replace: @cmd updateframe getlocalvar("self") 0 with: loop 1 no need to use scripts when you don't need them.

Secondly when you pick up a item a didhitscript is activated this can be used to stop the items animation so the sound will no longer play. make a file "data/scripts/item.c" and add it to your items header like this "didhitscript data/scripts/item.c" now open the item.c and copy this in there:

C-like:
void main()
{
    void self = getlocalvar("self");
    changeentityproperty(self,"aiflag","animating",0);
}
 
Solution
Firstly you can replace: @cmd updateframe getlocalvar("self") 0 with: loop 1 no need to use scripts when you don't need them.

Secondly when you pick up a item a didhitscript is activated this can be used to stop the items animation so the sound will no longer play. make a file "data/scripts/item.c" and add it to your items header like this "didhitscript data/scripts/item.c" now open the item.c and copy this in there:

C-like:
void main()
{
    void self = getlocalvar("self");
    changeentityproperty(self,"aiflag","animating",0);
}
thank you It works fine now.
 
Back
Top Bottom