My full project .cap, with notes and comments

Post your own tutorials, guides and demos.

Post » Mon Mar 31, 2008 4:52 pm

[quote="Hideous":c2o2synq]I've been looking around at this now, and while it is useful, I think you should use this and write several small tutorials. There's a lot I don't understand in here :P[/quote:c2o2synq]

That what the thread is for. Questions!

Plus, I'm lazy. I'm surprised I actually finished commenting it.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Apr 01, 2008 7:56 am

Yeah alright. So being new to this whole construct deal, I'm wondering how you made the separate square mask thing for the top and stuff. It looks useful :P
B
2
S
2
G
4
Posts: 110
Reputation: 1,670

Post » Tue Apr 01, 2008 11:28 am

Okay then :) From the top (no pun intended):

First, create your sprite:



Easy enough. But it's likely your sprite is animated. If you use per-pixel collisions for detecting the background, it will cause problems because one frame might be clear of the background, but the next frame could intersect. Here's all the top frames visible at once:



The tilted frames only deviate by a couple of pixels, but that's enough to make collision problems occur. Using Bounding Box collisions on the sprite would make the collision area too large, and would cause problems with player collision or look funny when it's being smashed. So we need to make a separate collision sprite as a surrogate:



I've sized it at a nice, "average" size for the top so collisions will appear more consistent. I've also added a registration point to the tops and the mask so that it'll be easy to line up the hotspots when I put them in Construct.

From there it's just a matter of importing your top frames into one sprite, and your collision mask into another sprite.

We want to do all the movement actions on the collision sprite itself (the topBody object in the game) and tell Construct to align the animated sprite on top every cycle. If you have only one instance of each, that's no problem, just put in the events and go. But if you want more than one at a time, you need a way to distinguish between sets of "sprite" and "body." Otherwise, when you do this:

[code:3rpst3l9]
+ body is overlapping weapon
- sprite: Destroy
- body: Destroy
[/code:3rpst3l9]

then that one body will destroy, but so will all the sprites.

To fix this, you can pair up the sprites with the bodies by using Containers. According to Ashley:

[quote:3rpst3l9]
If any object is picked by an event, the rest of the objects in its container are also picked.
[/quote:3rpst3l9]

So that means if I want to pick a specific body, and "sprite" is in the same container as "body," Construct automatically knows which sprite to pick.

To put something in a container, click on the object and open the Containers section in the properties. Click "Add object," and select the object you want to pair up:



Notice that the topSprite is highlighted yellow when the topBody is selected. This is to indicate which pair it belongs to:



When you're using containers, you have to make sure you have an equal number of contained elements. If I have five topBodies, I need five topSprites to match.

Anyway, now we can go back to making events. If we want to align a sprite with it's specific body, just do this:

[code:3rpst3l9]
+ objectBody condition
- objectSprite: Set position to objectBody
[/code:3rpst3l9]

Construct places the correct sprite on top of the body that it's paired with. And if we want to destroy it:

[code:3rpst3l9]
+ objectBody overlaps something dangerous
- objectSprite: Destroy
- objectBody: Destroy
[/code:3rpst3l9]

Construct only destroys the sprite that's paired with the body that is picked by the condition.

I hope that made some kind of sense.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Apr 01, 2008 12:41 pm

YES

Thank you, that was a really well written tutorial :D


You should add it to the wiki, methinks :)
B
2
S
2
G
4
Posts: 110
Reputation: 1,670

Post » Tue Apr 01, 2008 1:06 pm

You're welcome, glad I could help :)

[quote="Hideous":3gukm2fd]You should add it to the wiki, methinks :)[/quote:3gukm2fd]

Maybe a more generic version of it, I don't want to clutter the wiki up with references to my game.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Apr 01, 2008 11:04 pm

The wiki does need a description of containers, I'd be happy to help out. Note two other features of containers:
- If you create or spawn one of the objects in a container, it creates instances for every object in the container, to keep the object counts the same.
- Same with destroying - destroying an object in a container destroys all associated objects (so you only need one Destroy action on any one object to destroy a container).
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue Apr 01, 2008 11:41 pm

[quote="Ashley":3et9owz3]The wiki does need a description of containers, I'd be happy to help out. Note two other features of containers:
- If you create or spawn one of the objects in a container, it creates instances for every object in the container, to keep the object counts the same.
- Same with destroying - destroying an object in a container destroys all associated objects (so you only need one Destroy action on any one object to destroy a container).[/quote:3et9owz3]

Ah, see? I didn't know that.

I'll go ahead and make my Container description a little more generic and post it to the Wiki. I'll probably start on it later on tonight, which means done by morning at the earliest.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Dec 12, 2013 7:21 am

Hello,
The cap link you provided is no longer available. :(((

@deadeye
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Thu Dec 12, 2013 9:04 am

@Doc Ai

That's probably because the thread is nearly 6 years old.

Also, it's been a very long time since DeadEye was around, so unless someone else has his original file, then you may be out of luck.zenox982013-12-12 09:06:39
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,843
Reputation: 48,287

Previous

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 3 guests