Antani
February 2, 2021, 11:18pm
#1
So I have no problem with this event in the event editor of the scene, but if I use it in an Action Function it doesn’t create anything:
It should create a wall of brick of random color (that happen when I am not using the Function) and Object_Target_1 is a Group of Sprite where I pick randomly an Object to create it from 3 (for now).
I’ve been doing something that can’t be done in a Function or there is something that I am doing wrong?
Slash
February 2, 2021, 11:23pm
#2
Open the debugger and check your instances and variables
Is your global structure set up?
Is the name of the globalvariable(bricks_all.0/1/2) equal to your object names?
Antani
February 2, 2021, 11:37pm
#3
Yes, it’s set up!
The same event, in the event editor of the Scene instead that in a Action Function, works without problem.
Slash
February 3, 2021, 12:04am
#4
I don’t understand What ure saying.
How can you run events in the editor?
Do you mean the events work in preview but not in a custum function?
The custum function needs parameters
Antani
February 3, 2021, 12:49am
#5
Maybe I am using wrong words but for “editor” I mean the events of a Scene (I have only 1 Scene for now); the one in blue here:
“Game” it’s the name of the Scene; there, the same events, works well.
If I create a Function (“Stage_Creation” in the image) where I put the same events and I call that from the Events of the Scene, it doesn’t work!
Slash
February 3, 2021, 9:48am
#6
did you define the parameters?
Antani
February 3, 2021, 10:23am
#7
Yes! I’ve tried Any Object and Sprite!
Slash
February 3, 2021, 10:34am
#8
you need to use the functions syntax
You can read more about types and how use functions parameters on the wiki page .
For Number and Text parameters types you need to use these expressions for get the value contain in your parameter.
GetArgumentAsNumber(“YourParameterName”)
GetArgumentAsString(“YourParameterName”)
The objects, behaviors, and variables type can be directly used.
Here different types in a use of case.
[image]
Antani
February 3, 2021, 10:38am
#9
I am using only scene variable.
Slash
February 3, 2021, 12:04pm
#10
i tested it, and it worked by using not the itemgroup of the scene, but the sprites of the scene as parameters inside a group of the function.
2 Likes
Antani
February 3, 2021, 10:22pm
#11
Thanks a lot! I didn’t think about it; maybe I can use this idea!
Really thanks.
Antani
February 3, 2021, 10:56pm
#12
Solved! A bit tricky but possible! Thanks again!