How do I fix the On create Object works without WaitXs

Get help using Construct 2

Post » Sun Aug 28, 2016 3:36 pm

Is all explained in the code but the problem is that i want that the textbox updates with the last sprite name created.

First an event that says -> On click-Create X object

Second > On X object created > Set TextBox as Sprite.name

The unique way to get this working is adding a "wait X seconds" firts, but this will give me problems on the future, so how i can fix it without the WaitXseconds ?

Here the .capx

https://dl.dropboxusercontent.com/u/659 ... oblem.capx
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Post » Sun Aug 28, 2016 4:02 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Sun Aug 28, 2016 4:16 pm

Works, but still prefer a solution without WaitXseconds. And thanks for the link i'm going to read now, looks interesting! ;)
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Post » Mon Aug 29, 2016 1:20 pm

Pick all Sprite
Set TextBox as Sprite(-1).name

?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 29, 2016 1:44 pm

99Instances2Go wrote:Pick all Sprite
Set TextBox as Sprite(-1).name

?


@99Instances2Go Works but the textbox can't be edited. If i put "On create" the first click on create not show nothing in the textbox, and for the next appears the name of the previous object name. Adding the "Wait0s" your solutions works "on created" :P .

Here is the .capx edited with your solution added in the bottom(Event 8), maybe i misunderstood something:
https://dl.dropboxusercontent.com/u/659 ... oblem.capx
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Post » Mon Aug 29, 2016 2:06 pm

You can use a function with Pick with UID.
http://www.blackhornettechnologies.com/ ... m_BHT.capx
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Mon Aug 29, 2016 2:43 pm

Not intended to use with 'on create'. Just as a standalone event. This will always write the last created one in the textbox. (sorry was evident for me)

If you need to use the 'on create', then use what blackhornet suggested, works because the pick by UID always works, no need to wait till the object is actual added to the IID list (pickable).
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 29, 2016 3:18 pm

99Instances2Go wrote:Not intended to use with 'on create'. Just as a standalone event. This will always write the last created one in the textbox. (sorry was evident for me)

If you need to use the 'on create', then use what blackhornet suggested, works because the pick by UID always works, no need to wait till the object is actual added to the IID list (pickable).


@99Instances2Go Don't worry! i understood you correctly, without OnCreated, but in the code i put a solution that works like yours but the "textbox" is not editable, and i need it to use for rename the sprite.

@blackhornet THANKS!, Yes, works without WaitXseconds.There will be any way to do the same without put a function/event in the On Button clicked ?. As i said in the code "And the box_sprite_name event have to be out of the button "on Clicked" like now." i guess i explained bad i mean none event for that inside this ones.

Why?, now for each sprite type i want to create i have to add this function. While "On created Sprite" I can add all the functions and events i want to do, only one time instead of repeat the same actions/events in all the buttons. Is there anyway? Sorry for not be totally clear.
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Post » Mon Aug 29, 2016 3:34 pm

You can't use "On created" as that is called during the Create action - you don't set the name until the next action, so there is no way to get the data until after you've set it.
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Mon Aug 29, 2016 3:56 pm

blackhornet wrote:You can't use "On created" as that is called during the Create action - you don't set the name until the next action, so there is no way to get the data until after you've set it.


@blackhornet Ahh i see obviously! i thought the "on created" works after the event button cliked is finished! :S,

Not have to be specifically "on created", an action that occurs one time that can detect a new sprite has added wil works.

I have now:
On created(Tha is the one only works at the moment with Wait0s)
OR
Drag&Drop Start
OR
On touch

Then -> Select, set name, set Zorder, set opacity to slider,etc...

Mmm, maybe there is some action that detects when the "On button Clicked" event is finished i guess will works too.

If not well, if only is one repetitive event inside the sprite types creation not is the desired but if there no other options and well i guedd i can use to do other future things that needs to detect the end of the button event i guess.
B
25
S
10
G
3
Posts: 577
Reputation: 4,556

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 8 guests