How do I load game resources

Just started using Construct 2? Post your questions here

Post » Tue Sep 23, 2014 4:45 pm

The game is set up as follows

When you click campaign it goes to a layout called gui. gui contains all spawnable sprites and UI elements. The spawnable sprites are located in the margin off of the layout, and all objects are tagged as global.

the GUI layout then redirects to whatever layout the player should be on.

What I did as your suggestion is call:

on layout start -> destroy spawnablesfamily

right in the gui layout. But after redirecting it did not spawn any objects like it should have.
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
14
S
4
Posts: 303
Reputation: 1,730

Post » Tue Sep 23, 2014 5:11 pm

Why not create a dump layout which you dump all of your objects? Then, you don't have to destroy the objects on start of layout that you're using.

If you're destroying global object, I think it will remove it entirely from the memory as well, maybe that's the reason it's not spawning.
Last edited by DuckfaceNinja on Tue Sep 23, 2014 5:14 pm, edited 1 time in total.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Tue Sep 23, 2014 5:14 pm

I can't open the capx right now unfortunately but will when I can. If I understand what you're saying, the sprite can be on ANY layout, and if that's the case that would be extremely useful.

I'll check back in later, thanks!
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
14
S
4
Posts: 303
Reputation: 1,730

Post » Tue Sep 23, 2014 5:14 pm

DuckfaceNinja wrote:Why not create a dump layout which you dump all of your objects? Then, you don't have to destroy the objects on start of layout that you're using.

If you're destroying global object, I think it will remove it entirely from the memory as well, maybe that's the reason it's not spawning.



I didn't know I could do that :) Going to try later!

Does the layout have to be loaded?
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
14
S
4
Posts: 303
Reputation: 1,730

Post » Tue Sep 23, 2014 5:15 pm

skelooth wrote:the sprite can be on ANY layout

Yes, that is indeed the case.
skelooth wrote:Does the layout have to be loaded?

Nope, it'll load into memory at the very beginning of loading the index.html, I think.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Tue Sep 23, 2014 5:31 pm

That's what confused me. I read a post by ashley that states that things are only loaded from the active layout, but perhaps he means rendering surfaces, not objects. I love C2 but it's still new to me and I'm used to more conventional libraries like sdl/clanlib/impact/love
Developing Surolace, the survival role playing space game.

surolace-survival-role-playing-space-game_t116953
B
14
S
4
Posts: 303
Reputation: 1,730

Post » Tue Sep 23, 2014 5:39 pm

As far as I understood it, in the webGL renderer, anything present in the layout view of the current layout has their textures loaded, if an object is created without his texture currently loaded, it will be loaded on the fly, then at the end of the layout, everything not needed anymore will be unloaded from memory.

That may be a wrong or incomplete interpretation, but basically: C2 is meant to take care of loading and unloading textures for you.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Previous

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests