Construct example game Kiwi Story - question

Post » Wed May 24, 2017 9:20 pm

Hi!

I'm going through the example games for Construct 3, and have been "studying" the platformer Kiwi Story.

I'm wondering if anybody could explain what's going on in this specific piece of code below. The main thing I'm looking at is the first line in the function "Transition" (for those who haven't gone through the game, this function is a fade in/fade out effect between layouts). Why is the Transition object being destroyed right away?

As a test, I deleted that line and ran the game. Nothing seemed to change, but I suspect something is happening in the background that I can't seem to put my finger on. Any insight would be appreciated!

Image
B
9
S
3
Posts: 10
Reputation: 645

Post » Wed May 24, 2017 9:32 pm

At the first line of the Transition function, there is no Transition object selected yet which means that "Transition destroy" will destroy ALL Transition objects, and by doing so it will clean up leftover transition objects from previous transitions. After all "old" leftover transition objects are destroyed, a new one is created and the new transition object's size is changed.
B
10
S
1
Posts: 13
Reputation: 481

Post » Wed May 24, 2017 9:54 pm

Ultimadark wrote:At the first line of the Transition function, there is no Transition object selected yet which means that "Transition destroy" will destroy ALL Transition objects, and by doing so it will clean up leftover transition objects from previous transitions. After all "old" leftover transition objects are destroyed, a new one is created and the new transition object's size is changed.


Got it. So at the start of the game, after the first call, there won't technically be a Transition object to destroy yet, so that action will just be passed up. Then each transition afterward will enact the clean-up action of Destroy.

Thanks for the reply!
B
9
S
3
Posts: 10
Reputation: 645

Post » Thu May 25, 2017 7:29 am

Imagine if the transition function was called twice, the second time it would destroy the first functions transition sprite before a new one was created.
B
43
S
22
G
20
Posts: 735
Reputation: 11,977

Post » Thu May 25, 2017 9:37 pm

Ethan wrote:Imagine if the transition function was called twice, the second time it would destroy the first functions transition sprite before a new one was created.


Ethan - thank you! The helps clarify it even further.
B
9
S
3
Posts: 10
Reputation: 645


Return to General Discussion

Who is online

Users browsing this forum: stevenode and 3 guests