Draggable sprite overlapping different sprites

0 favourites
  • 7 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi guys,

    I'm currently working on a project but I have a problem while doing it. Well I have a draggable sprite(chameleon) that will overlap two different sprites(DayBackground and NightBackground) and when the draggable sprite(chameleon) overlap to the different sprites(DayBackground and NightBackground), it will trigger different actions.

    Example: Draggable sprite(Chameleon) overlap one of the sprite(DayBackground), the draggable sprite(Chameleon) will destroy.

    I've tried doing sub-events and separating the conditions to different events but it doesn't work. How do I solve my problem? I want to achieve two different actions (based on 2 different conditions) using the same draggable sprite.

    The two different sprite(DayBackground and NightBackground) are overlapping but I've solved the problem by positioning them out of the layout when it is not needed.

    You can see the file here: dropbox.com/s/6r462q08qiac24e/Animals.capx

    Hope to hear from you guys soon!

    Thank you! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • At the end of the day to night transition, the background is still actually the daytime sprite, it's just on very last frame of the 'DayToNight' animation.. so it appears to be the nighttime sprite.

    So.. now you probably realize that it's still being destroyed because the '..is overlapping daybackground' condition is still being met

    You could just fix it so the background sprites swap correctly in the transition..

    ..but instead, i'd recommend redesigning this in a different way, which would solve your problem and also result in a cleaner events sheet.

    have all the background stuff into one object, so don't worry about positioning/setting invisible etc.

    And instead of checking what background it's overlapping, check a variable that toggles between 'day' and 'night' on the transition... or just a variable that toggles between 1 and 0 representing day and night.

    This is good practice too as overlap checks are relatively expensive on cpu.

  • Keepee: I've combine both animation to a single sprite but how do I toggles the variable? Is it Global Variable or Instance Variable? I never try Variable before and I'm currently lost right now. Hope you can help me :) I rarely use construct 2. Thank you!

  • I think this CAPX will be more towards what you're after.

    The WarmBlood animals will rotate right when you drag them on the day, and the ColdBlood animals will rotate left when you drag them on the night. And if you drop them anywhere else the will return to their original positions which are set at the start of the layout.

    Note : That I have used families to make the code smaller, as well as put in conditions so you can't switch from day to night or move animals until the animations have finished.

    If you have any questions, feel free to ask me <img src="smileys/smiley1.gif" border="0" align="middle">

  • emoaeden: Thank you so much :)

    If I have any questions, I will let you know.

  • "..more towards what you're after"

    -vnt@emoaeden

    Well, that's what I suggested you could settle for, but with 1 var you can lose the separate backgrounds' positioning and the overlap checking

    Annisa12 Variables are worth reading up on anyway, they'll open up possibilities/simplify stuff.. and are often essential. The manual will explain better than me, but in short, they are just stored values of number or text.

    In this context what I was getting at, was a global text variable:

    on touching the slide button for day/night, set that variable to "Day" or "Night"

    and then in place of the 'is overlapping DayBackground' you can have 'if variable = "Day"'

    or 'if variable = "Night"'

    But anyways, not a big deal if this is all the project entails, but as it gets more complex, you'll probably want to start using them.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • keepee

    I was going to do it with variables, but from the look of the original CAPX, it seemed as if Annisa12 mightn't have known how to use them, and the changes I made were already vast, so I didn't want to add confusion <img src="smileys/smiley1.gif" border="0" align="middle" />

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