Issues adapting a "0.98.9" file version to "0.99.42&quo

For questions about using Classic.

Post » Wed Nov 25, 2009 4:29 am

I've just returned to Construct after completing Year 12 and I recently created a cloud generator in an older version of Construct (0.98.9). I then wanted to use Construct on PC, so I installed the latest stable version (0.99.42) but the file doesn't run properly. I've tweaked around and rebuilt the entire thing from scratch but I still cannot replicate the old version of the file, which leads to me believe I'm overlooking something very simple or there may be a glitch.

If anyone wants to assist, I've uploaded a compiled version using v. "0.98.9" so you can see how it's supposed to appear: Download here

And also the *.cap file to examine in the latest stable version of Construct: Download here

With the exact same code, this is the difference in output between the two versions:


Any help appreciated.
B
2
S
2
G
3
Posts: 143
Reputation: 1,536

Post » Wed Nov 25, 2009 5:40 am

I believe the issue is construct changed how it picks objects after creating them. So if you had:

Create sprite
Create sprite
- Set angle of sprite

in 98.9 it would change the angle of both. In newer versions, the same event would result in the second sprite being rotated. This is because on creating an instance of an object, construct picks the object that has been created and forgets all other instances of the object. The new version of the event:

Create sprite
- Set angle of sprite
Create sprite
- Set angle of sprite

I haven't checked the .cap tho, so it might be something else.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Wed Nov 25, 2009 9:00 am

I'm sorry, but I'm not sure I understand. I don't think I did a good job in explaining my situation in the first post to here I'll explain my situation in detail here:

(highlighted are the important events)

Event Two: Creates a random cloud sprite with a private variable called 'indicator' set to '0'

Event One: All cloud sprites created with 'indicator' set to '0' spawns a cloud with random variables make it distinct. It spawns another cloud in an area relative to it. This is repeated around seven times for each newly created sprite to create a cloud sprite that looks like this with 0.98.9:



As you can see, it creates distinct clouds and creates the new spawn in the area relative to the spawned cloud. Each newly spawned clouds creates another and this is repeated '7 + Random(2)' times.

Now, when I run this in 0.99.42, this is how it looks:


As you can see, there's an extraordinary amount of clouds in those areas, only after a couple of seconds running the app. It's also only spawning new clouds in only the two areas shown, while the new spawns aren't spawning any relative to their own position. I just reran it for a minute, and it's really random, as sometimes it begins to spawn some clouds like in the older version, while other times it's just an endless stream of clouds. Though no matter what type of clouds it's spawning, it always spawns from those two areas.

I hope this helps...
B
2
S
2
G
3
Posts: 143
Reputation: 1,536

Post » Wed Nov 25, 2009 4:27 pm

What I think is happening is you're selecting a cloud via the conditions, but when you create a cloud in the actions, it forgets the selected cloud from the conditions, and the new cloud that was created becomes the only selected cloud, meaning that the new cloud spawns from it's own pivot point.

Also, since the objects with the bullet behavior are set to destroy themselves automatically when leaving a layout (in the properties), you don't need the sprite to clean them up when they go offscreen. A much easier computationally method, if the bullet behavior wasn't cleaning up after itself already, would be to check their x position. Much faster than checking for collisions.

I modified your .cap. I set a global variable for each cloud picked in the conditions so the x/y you wanted to spawn from wouldn't be forgotten when you created a new cloud and used those instead. Take a look at it and tell me if there's anything you don't understand.

viewtopic.php?f=16&t=5057
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sat Nov 28, 2009 2:09 am

Sorry for the late response, but I've been busy these past few days.

Thanks for the assistance. I think I understand most of it and it works wonderfully. Just a question: in the future, if I wanted to replicate this but in a different situation, should I always settle for global variables when generating batches of sprites in random areas?

EDIT: Great. I just discovered my old, semi-complete remake of Blockdude is broken on the new version :| Gonna to be fun 'porting' it over...
B
2
S
2
G
3
Posts: 143
Reputation: 1,536

Post » Sat Nov 28, 2009 3:04 pm

A global variable is helpful to use because it will be unaffected by the picking process. It doesn't need to be a global variable - you could have a 'valuesprite' if the values are needed for only that layout. As it is, you're picking an object, then creating another instance of that object which forgets the previously selected instances of the created object, which makes it confusing. By setting the place to create from somewhere else, it makes it all work smoother.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests