Containers help

For questions about using Classic.

Post » Fri Mar 21, 2008 12:37 am

I recall some discussion a while back about how to use containers, but I didn't quite get it. If I remember correctly it was something about attaching a turret to a tank with containers, and the whole thing moves as one.

What I want to do now is somewhat similar.

I've made an enemy that uses the new Platform movement features (thanks Ash :) ), and I have the basic, blank collider box moving around, jumping, and behaving properly. Multiple instances of this enemy act independently of each other. What I want to do is attach a sprite to each instance of the collider box. So, the box would control the movement and collisions, and the sprite is just there to make it look pretty (but still has to change animation for the appropriate action the box is doing, i.e. jumping).

Is there a way to do this with Containers? And how exactly does one use containers? And if I'm completely on the wrong track, feel free to offer up any ideas on how to achieve this otherwise.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Mar 21, 2008 12:53 am

Containers don't actually affect any object's position. They simply affect the way they are picked by conditions in events. If any object is picked by an event, the rest of the objects in its container are also picked. This still makes them really useful for stuff like this though.

If we call your collider box the collider object and the look-pretty sprite the enemy, you can place the collider and enemy in a container with each other. (all you need to do is select one and add the other to its container in properties, they are both now contained)

Make sure you have an equal number of instances of collider and enemy. The event 'Always - set enemy to position of collider' will naturally match up each enemy to its contained collider.

Now you can go off making your events... anything like 'Collider collides with solid - set Enemy animation to Stopped' will affect only the associated Enemy, not all enemies like you'd expect normally. That's the magic of containers :)
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Fri Mar 21, 2008 1:30 am

Awesome, thank you! Worked like a charm.

By the way, the project this is for is being submitted to the Random Video Game Name Generator contest currently going on at TIGSource. It's just about done.

I'm thinking about mentioning I made it with Construct, as that might drum up a few users. (It doesn't use any of the fancy shader effects and looks decidedly old-school though, so maybe I shouldn't. It might give people the wrong impression of the power of Construct.)

Regardless, I'll be sure and post a thread when this is complete. The contest ends the 24th, so I have to hustle.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests