Move a sprite with any click like a boolean.

0 favourites
  • 9 posts
From the Asset Store
Move Block
$10 USD
Captivating puzzle game. With challenging gameplay, this game will keep you very engaged.
  • Hello excuse my english,

    I don't understand, i want to move a sprite Y-125 with "any click" and the second "any click" Y+125 for the sprite back in its place.

    Like a boolean, i do this.

    [attachment=1:1civ5p08][/attachment:1civ5p08]

    and this

    [attachment=0:1civ5p08][/attachment:1civ5p08]

    But the 2 lines in the same time don't works.

    with the 2 lines the sprite don't move.

    The 2 lines vanish?

    I go the wrong way ?

    Thanks.

    Chris.

  • If you set c_haut to 1 then the second code triggers immediately, because then c_haut is 1. You have to structure it another way.

  • try -

    [attachment=1:1j2iozl8][/attachment:1j2iozl8]

    but - instead of a global variable why not add an instance variable (boolean) to your sprite ?

    you would get :

    [attachment=0:1j2iozl8][/attachment:1j2iozl8]

  • This will also not work. Because the first condition will trigger the else statement.

    He has to use a boolean and reset it with key release.

    I have to go now. I will post a solution later, if the problem then still exists.

  • Games

    Nope! It's a good solution. The else is bound to the evaluation of the condition it's "elsing", since this evaluation happens before the action, the else will not be triggered.

    RamPackWobble

    Using a boolean instead of a global number is not equivalent though it might be a better solution in this case. But we can't say without seeing the big picture.

    I would guess that you probably want to use a boolean for the semantic (meaning) of a 0/1 switch, but to me it's more because c2 doesn't provide boolean types for globals than for a good design reason.

    (To counter c2's flaw, I usually declare two global constant TRUE = 1 and FALSE = 0 and use that in expressions)

  • This will also not work. Because the first condition will trigger the else statement.

    He has to use a boolean and reset it with key release.

    I have to go now. I will post a solution later, if the problem then still exists.

    ?

    [attachment=0:2rizor7m][/attachment:2rizor7m]

    [attachment=1:2rizor7m][/attachment:2rizor7m]

    Yann - good idea about the TRUE/FALSE globals. I agree about using boolean being different to globals just thought I would offer a possible variation...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks a lot ! i'm going to try

  • it's works !

    it was missing "esle"

    The 2 work but I chose the capx1 without boolean.

    Thanks.

  • since this evaluation happens before the action, the else will not be triggered

    Oh, I didn't know that. You never stop learning.

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