Record/Store & Load Objects and it's parameters from a File.

Get help using Construct 2

Post » Mon Jun 01, 2015 10:50 am

Hi, lads.

I have to understand, how can i record/store objects in a file and then get it in the Construct 2.

Some of you can say - "Why do you need THIS when you have a layout?".
Well, guys. I need not only create objects in the Construct 2 from files, but delete them and create again if needed.

Imagine yourself a hero. His moving from one direction to another, but location so huge that will cost you big amount of fps.
But what if objects on a layout will be loading bit by bit when hero get's closer and deleting if he's far away?
The same technique used in big games - like Assassin's Creed, GTA, The Elder Scrolls, Minecraft and etc.

Image

There is fourth stages:

1) Record (Recording of parameters such as - X, Y, Angle and etc. For the multiple number of objects)

2) Storing

3) Loading (In-game loading of parameters and creating objects in the game with them)

4) Deleting (For objects that is far way)

----------------------------------------
For any help - HUGE Thanks! You will not be forgotten!
That can be a year or two, but boomerang will return. Always does.
--------------------------------------------------------------------------------
If someone want to help me and with that become part of my yet unknown, but already great crusade - then don't be a shy! Send me a letter.
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252

Post » Mon Jun 01, 2015 10:56 am

Destroy objects on start of layout and create them when needed..

If you want to store their values when you destroy them you could do this in a dictionary object or an array in an on destroyed event..
All you have to do then is making sure when created C2 knows which dictionary/array belongs to the object being created..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 01, 2015 11:15 am

Well, first thing i will do anyway - it's build a location and then with one-time operation i'll record everything on a file.
So, every value will be already written and ready to use in anytime. Operation can be only repeat by me if i'll change anything in the game.

Then all i'll need - it's to spawn and destroy objects in-game if they / or not in the "Field of Loading".
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252

Post » Mon Jun 01, 2015 12:15 pm

Why do you want to use an external file for this when all of your requirements can be done from within C2?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 01, 2015 12:18 pm

LittleStain is right use LOGIC
B
245
S
39
G
15
Posts: 1,946
Reputation: 40,276

Post » Mon Jun 01, 2015 12:27 pm

I guess you could try something like this:

Create an "on destroyed"- event, add a sub-event to check if the destroying means it shouldn't appear anymore (for example if player kills it)

Push some values like x,y,health,speed, etcetera into an array..

Every tick check the coordinate values in the array to see if the object should be created or not

On created set all instance variables to the values in the array and remove the values from the array..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 01, 2015 12:37 pm

LittleStrain, at least now - i know where should i look. Thanks!
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests