Multi-function sprite???

Get help using Construct 2

Post » Thu Apr 16, 2015 12:32 am

can i create a square which will be used as a sprite where by each of the 4 faces of the square will act differently.

What I mean by this is that if an object hits the one specific face it will destroy the object but if it hits the other 3 faces it wont?
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Thu Apr 16, 2015 1:32 am

Create 4 extra sprites (these will be your collision boxes which will represent the different faces).

Give them an instance variable (colour - "red", "blue", "yellow", "green")
Pin those sprites to each side of your initial sprite.
Then on collision with any of those, check if the colour instance var is "red" (if that's the face that will kill the player).
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Apr 17, 2015 12:57 am

and if i want the sprite to rotate so that the yellow face was where the red face was for example how would i do that. since it need to rotate but also change its position, and then when rotated change its position again
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Fri Apr 17, 2015 12:57 am

so it has the possibility of being in 4 different positions when rotated 90 degrees
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Fri Apr 17, 2015 2:31 am

Rotating the main sprite will rotate the pinned collision boxes too. Almost sounds like you're doing an "impossible square" game though?

impossible square on codecanyon

I'm not even sure you need collision boxes for this if that's the case. You'd just base it on angles.

Like, red is 0degrees.. yellow is 90.. green 180.. blue is 270

Then on collision, check the angle of the main sprite, then you'll know which colour it is.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Apr 17, 2015 5:00 pm

Haha yeah having looked at that link it does look like a very similar concept.

How do you pin the sprites together though?
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Fri Apr 17, 2015 5:31 pm

Ah soz I thought you'd know.. there's a Pin behaviour. It's as simple as adding it to the sprite like you would Bullet, Physics, Platform etc

Once added, in your events, you add an action Sprite -> Pin To OtherSprite (you can select how to pin it.. position and angle.. position only.. etc). Then when OtherSprite moves, the pinned Sprite will move with it automatically.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Apr 17, 2015 5:50 pm

brilliant thanks. Yeah i'm quite the newbie at this haha. Thanks so much. I'll let you know how it goes
B
8
S
2
Posts: 146
Reputation: 1,132

Post » Fri Apr 17, 2015 6:18 pm

I recently did a clone of that impossible square game for a client so just type @procrastinator to alert me if you have problems.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Sun Apr 19, 2015 5:44 pm

Okay thank you :)
B
8
S
2
Posts: 146
Reputation: 1,132

Next

Return to How do I....?

Who is online

Users browsing this forum: FabianB, Vodakman and 8 guests