• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Can't destroy a sequence

M

Maker

Guest
First of all, English is my second language, so please be patient and thanks for take your time to read and help me.

My objective: when I press the object, this create a sequence in looping, but I dont want the sequence to be there forever, I must to delete this sequence to make the things works.

I have tried a lot but zero results, my knowledge is very basic and everything that I know comes from videos tutorials, if you could help me I would be very glad, thanks.
 
M

Maker

Guest
I used this code here, but when I use Sequence_destroy the comand doesn't works.

maybe this happens cause I can't say to the code where and what I want to delete.


var _playerInst = instance_find(Hand, 0);
var _sequence = Moviment;
var _layerName = "Instances_1";


var _seqElm = layer_sequence_create(_layerName, _playerInst.x, _playerInst.y, _sequence);

var _seqInst = layer_sequence_get_instance(_seqElm);

sequence_instance_override_object(_seqInst, Hand, _playerInst);

and to delete I just used this:

sequence_destroy(_sequence);

and doesn't works, sometimes this code deletes even Sprites.


Thanks for read and for the help.
 
M

Maker

Guest
I tried this too, but the result is the same, nothing happens to the sequence, and one of my sprites is deleted

I have sure that the problem is where I have to put in the code,

my code:

##mouse left released##

if global.selected=1 {
image_index = 1

var _playerInst = instance_find(Hand, 0);
var _sequence = Moviment;
var _layerName = "Instances_1";


var _seqElm = layer_sequence_create(_layerName, _playerInst.x, _playerInst.y, _sequence);

var _seqInst = layer_sequence_get_instance(_seqElm);

sequence_instance_override_object(_seqInst, Hand, _playerInst);

layer_sequence_destroy(_sequence);

}
 
M

Maker

Guest
You are totally right, now I can delete a sequence, but just when it was there since the beginning, when I use a object to create a sequence the function destroy stops to works, I almost have sure the problem is caused by the way that I'm making, I'm using this to create the sequence code:


var _playerInst = instance_find(Hand, 0);
var _sequence = Moviment;
var _layerName = "Instances_1";


var _seqElm = layer_sequence_create(_layerName, _playerInst.x, _playerInst.y, _sequence);

var _seqInst = layer_sequence_get_instance(_seqElm);

sequence_instance_override_object(_seqInst, Hand, _playerInst);

When I use in this way the layer_sequence_destroy() doesn't work.

I have to use a code to show what sequence and in what layer it is?

When I configure the function to destroy is just use another short event, like this:

###Right Down###

Var _sequence = (the thing);

Layer_sequence_destroy (_sequence);

I just now know this way to delete, and apparently this doesn't works to sequences created by a object, if have other way to makes its works I would be very grateful.

Thanks again.
 

Nidoking

Member
Var _sequence = (the thing);
This is not valid GML. I don't see you actually saving the return value of layer_sequence_create anywhere, and that's what you need to pass to layer_sequence_destroy. Could you show what you've actually typed instead of shortcuts that prevent anyone from seeing the problem?
 

rIKmAN

Member
You're assigning things to local variables, which means they only exist in the scope of that current event.

Trying to destroy the sequence using that same local variable in another event isn't going to work because that variable doesn't exist anymore once the event you created the local variable in has been run.

For example: a local variable assigned in the Create Event cannot be accessed in the Step Event because it's scope is limited to the event in which you created it. In this example that's the Create Event, but the same rules apply for local variables created anywhere.

Also you more likely want a "Pressed" event so that the destroy is only called once, using the "Down" event will fire every frame the RMB is held, which unless you are a ninja is going to be more than once when running at 60fps.

As Nidoking says, post the exact code you are using (use code tags) and what event each piece of code is in.
 
Last edited:
Top