Create objects on the fly via plugin?

For developers using the Construct 2 Javascript SDK

Post » Sun Mar 06, 2016 8:39 am

Hey everyone,

We have about 5-6 games with the same HUD logic, same tooltip mechanism.. etc.
Every time we do a change on one mechanism, it's mightmarish to update the rest of the games.
I've been using Global layers for a while but it's not the ultimate solution since we have a lot of eventsheet activities.

Is there a way to copy the same game logic (touch events, objects etc.) to a plugins? Kind of like an external module that
you can include in every project. Then you'll only have to update the plugin and not every project, every time.

Thanks
B
5
S
1
Posts: 10
Reputation: 295

Post » Sun Mar 06, 2016 7:12 pm

I would also love to do that. Ashley said that Construct 3 will have editor plugins. But for now, I guess we'll have to deal with some duplicate code in every project.

To achieve the modularity that you described, we need the addon sdk to be able to create sprites and objects that have no definition in the project. Say for example that I need a tooltip, I will certainly need to create a sprite for the background or frame and a text object in my Construct 2 project, then I would need my addon to create these objects and display them correctly. But the need to create the objects in the Construct 2 editor completely defeats the purpose. So we need a more powerful and mature sdk.

As someone who has developed games using pure javascript, C, C++ and C#, I completely understand that code repetition is a bad thing in many ways. However, I try to look at it from a positive perspective: it is an incentive to always improve your code with every new game that you make, and not be limited by an old game-specific plugin that you made ages ago.
ImageImage
B
42
S
13
G
10
Posts: 164
Reputation: 7,625

Post » Mon Mar 07, 2016 2:40 am

It is better separating logic from whole gui module (like MVC model) to increase the reusing ability, so it needs lots of programming experience.
Copy-paste objects to new project is more easier, imo.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Mon Mar 07, 2016 4:30 am

Thanks for the answers guys. I really hope that In construct 3 they would implement a solution for this because in my opinion the copy-pasting goes against the DRY principle of programming.
B
5
S
1
Posts: 10
Reputation: 295

Post » Mon Mar 07, 2016 10:39 am

@rexrainbow personally I think MVC is good enough for web/desktop applications that have a front end and a back end linked to a database but not for games, in games this separation is still there but in a more organic and complex way. Aside from that, we could have plugins dedicated to GUI and others dedicated to logic. This is where I agree with you: mixing both GUI and logic in the same plugin is a bad idea.

Furthermore, some people, including OP and me, don't require a high level of reusability all the time. Sure we need plugins that are highly reusable but we also need others that contain some game-specific logic and GUI that we use often in our projects.

In traditional programming, you have libraries and sdks that are highly reusable and independent from third party code, but you can still make your own libraries that rely on other code or on each other to make your development easier. I guess we want Construct to achieve a level of maturity similar to traditional programming languages to be a better development tool, I think Construct 3 will bring us closer to that goal.
ImageImage
B
42
S
13
G
10
Posts: 164
Reputation: 7,625

Post » Mon Mar 07, 2016 11:21 am

@Zed2100

Agree, hope C3 will have "import capx" feature, to treat a capx file as a reuse-able module.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests