Multi-function sprite???

  • 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?

  • 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).

  • 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

  • so it has the possibility of being in 4 different positions when rotated 90 degrees

  • 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.

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

    How do you pin the sprites together though?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • brilliant thanks. Yeah i'm quite the newbie at this haha. Thanks so much. I'll let you know how it goes

  • I recently did a clone of that impossible square game for a client so just type procrastinator to alert me if you have problems.

  • Okay thank you

  • procrastinator I seem to be having some minor complications with my spawning. I posted it as a separate question.

    If you have a chance to look at it that would be GREAT! heres the link

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)