Touch and Instances

0 favourites
  • 7 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • Hi. Can anyone try to shed some light on the following:

    Scenario: Sprite with a number of instances. Sprite has 2 frames. Using the touch control, but running on PC.

    The idea is that when the sprite is touched it animates to frame1 (from 0) else reverts back to frame 0.

    Problem: The FIRST TIME any of the instances is touched (mouse button) ALL the instances animate to frame 1. Thereafter it works correctly for each instance.

    <img src="c:%5CcsCode.jpg" border="0" />

    <img src="smileys/smiley5.gif" border="0" align="middle" />

  • You probably hyavre your events set up the wrong way. Maybe the else event is triggered at the wrong moment, or you don't pick the right instance in that event.

    This is just personal preference, but when I want to toggle I always use a variable.

    In your case you could use an instance variable, let's call it FrameToggle.

    On Sprite touched - Sprite set variable FrameToggle: 1-FrameToggle

    -- System compare two values - Sprite.FrameToggle = 1 - Sprite set frame to : 1

    -- System compare two values - Sprite.FrameToggle = 0 - Sprite set frame to : 0

    where -- is a subevent.

  • Thanks LittleStain, will try that. Still the peculiarity of the scenario bothers me. It seems there is never a dull moment in Construct.

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

  • I'm still not comming right with this problem. Same situation when I use a "toggle variable". Could you try to simulate this:

    Create Sprite with 2 frames (e.g. green & red) and put a number of instances on Layout. Also add the Touch control. Then enter the following events & actions in the Event Sheet:

    Event: Touch Is touching Sprite    Action: Sprite Set animation frame to 1

    Event: System Else                      Action: Sprite Set animation frame to 0

    The first touch changes ALL instances to frame 1 but thereafter only changes the frame of the particular instance being touched/clicked.

  • so when touch is not touching a sprite you want to set the frame to 0?

    the else event is reacting on the is touching, not on the frame.

  • replace the is touching with on touch.

    add a subevent if frame is 0 - set frame to 1

    add a subevent else - set frame to 0

    or you could use the toggle event I mentioned before.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi man, thanks for your inset. I have found the problem: Sprite's Animation speed has to be 0 ! What can I say?

    <img src="smileys/smiley9.gif" border="0" align="middle" />

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