Infinite scrolling all directions

For questions about using Classic.

Post » Fri Jul 24, 2009 6:05 am

[quote="scidave":3113gjn5]Ok, I'm sure there is an easy answer but it eludes me...
I'm dynamically placing objects (like an enemy ship). However, to actually create the object I have to place it somewhere during creation time. The common thing to do (shown in tutorials) is to place it off the layout, but this doesn't help in my case because the ship travels off the layout as well. How to create a sprite and NOT put in statically on the layout during creation time??
[/quote:3113gjn5]

I have wondered this myself. It seems very peculiar that we have to actually place the object (for example a sprite) somewhere on the layout (even if off to the side) to use it.
B
2
G
3
Posts: 68
Reputation: 986

Post » Fri Jul 24, 2009 6:18 am

Tick the 'Destroy on Startup' checkbox under the Attributes section for the object.

You can still reference the object at runtime and it won't create it :)
B
2
G
3
Posts: 27
Reputation: 904

Post » Fri Jul 24, 2009 6:25 am

It's not so strange, really. MMF does it. It has to exist somewhere. If you don't want it there when the level starts, just check "Destroy on Startup."

[quote="scidave":3oseqy58]I'm dynamically placing objects (like an enemy ship). However, to actually create the object I have to place it somewhere during creation time. The common thing to do (shown in tutorials) is to place it off the layout, but this doesn't help in my case because the ship travels off the layout as well. How to create a sprite and NOT put in statically on the layout during creation time??[/quote:3oseqy58]

Why not have a loading sequence at the start of layout that places all of your objects before they have a chance to be seen?

[quote="scidave":3oseqy58]However, when the player decides to "takeoff" and return to the space layout, everything is back to the way it was during game start. Is there a way to keep state between layouts? So the player's ship will be over the planet when you return to the layout?[/quote:3oseqy58]

Use a global variable for the ship's position when it enters a planet layout, and set the ship to that position again when the ship returns to the space layout.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jul 24, 2009 9:54 am

[quote="deadeye":18qfnh6i]It's not so strange, really. MMF does it. [/quote:18qfnh6i]

Yeah, but if MMF does it, it doesn't mean Construct should do it. Why an object should be placed in a layout, when user doesn't want to place it in a layout?

[quote="deadeye":18qfnh6i] It has to exist somewhere. If you don't want it there when the level starts, just check "Destroy on Startup."[/quote:18qfnh6i]

There are non-layout objects too, which don't get placed in the layout. I think that if there's an object type you want to later use in your layout, there shouldn't be need to have an instance of it. There is no such a need even in programming languages - object classes and object types are totally separate.

Also, if you delete the last instance of an object, the object type disappears too. I think that object types should be like Plato's ideas, they should exist in their "own world", in some kind of object bank, and then you could make instances of them in layouts.
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Fri Jul 24, 2009 10:21 am

As far as I know, the object always exists even if there are no instances of it. By adding them to the layout - even non-layout objects - you DECLARE them, so the runtime can use it. C++ and other programming languages are full of such declarations, so object type exists within runtime. You can create and destroy them within runtime as you see fit; if you remove them within edit time, they're gone for good.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Jul 24, 2009 4:17 pm

[quote="Drasa":7m7oh7cr]Some stuff...[/quote:7m7oh7cr]

Don't get me wrong, I agree with what you're saying. An object bank would be nice. But the current system is so entrenched in the foundation of Construct that it's not likely to change.

I would guess the only way to do this would be if the devs completely rewrote Construct's engine and IDE from the ground up, and it's a little late in the game to do that. It might be something to consider for C2 though... hint hint :D
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jul 24, 2009 7:17 pm

You can make an object bank by having a separate layout and keep all the objects you will create in the runtime in that layout.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Jul 24, 2009 8:21 pm

Thanks for all of the replies. I really appreciate how quick answers are around here!

I like Aeal's idea of an object bank on a separate layout, that's actually the way I have started to do things. While I'd prefer an object bank as well, its not a big deal to me, as long as there is a way to organize things (separate layout) and a way to destroy them (destroy on startup) then I'm happy. :|

Deadeye, that's a great idea on the global variables! I will do some playing around with that. I'll have to do it for every movable object/sprite currently on the layout at the time, but that shouldn't be too bad with a For Each on each object type.

I don't know if people realize how amazing Construct really is. I've been trying to implement this game in python/pygame and after about 3 months I quit....it was too ambitious of a project and just tedious. It still might be too ambitious, but I'm already at the same place with just a week of work.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Fri Jul 24, 2009 10:30 pm

the offscreen object is a really common pattern in graphical applications.
I agree it's not really "clean" but... even Windows does it (putting text fields outside of a form to store stuff).
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests