[Resolved] Instance variable not set when action performed.

From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • Hi guys, I can't figure this out, any help would be grateful.

    The situation:

    I have a sprite with 3 instance variables:

    -a is a Boolean and false as default

    -b and -c are numeric

    When an action is performed, in this case A Mouse click on the sprite with two conditions, when -a=false, a tween its going to be played, when -a=true, I'm playing another tween based on -b and -c. The problem I'm having its that when I click on the sprite, I set -a, -b and -c, but -a never sets the value. So I cannot run the second tween when I click back the sprite.

    Thanks for any help.

    My code goes like this:

    + Mouse: On Left button Clicked on keyBlade

    ----+ keyBlade: [X] Is dragged

    -----> keyBlade: Set initialX to Self.ImagePointX("start")

    -----> keyBlade: Set InitialY to Self.ImagePointY("start")

    -----> keyBlade: Tween "pos" property Position to Self.ImagePointX("end"), Self.ImagePointY("end") in 0.5 seconds (Linear, destroy: No)

    -----> keyBlade: Set dragged to True

    ----+ keyBlade: Is dragged

    -----> keyBlade: Tween "slide-back" property Position to Self.initialX, Self.InitialY in 0.5 seconds (Linear, destroy: No)

    -----> keyBlade: Set dragged to False

    If I invert the comparative Its being set only the first time but never gets the other condition.

    + Mouse: On Left button Clicked on keyBlade

    ----+ keyBlade: Is dragged

    -----> keyBlade: Tween "slide-back" property Position to Self.initialX, Self.InitialY in 0.5 seconds (Linear, destroy: No)

    -----> keyBlade: Set dragged to False

    ----+ keyBlade: [X] Is dragged

    -----> keyBlade: Set initialX to Self.ImagePointX("start")

    -----> keyBlade: Set InitialY to Self.ImagePointY("start")

    -----> keyBlade: Tween "pos" property Position to Self.ImagePointX("end"), Self.ImagePointY("end") in 0.5 seconds (Linear, destroy: No)

    -----> keyBlade: Set dragged to True

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well found the problem!

    Set a global Variable to check for mouse click did the job!

    For future reference here's the code:

    | Global boolean MouseClicked‎ = false

    + Mouse: On Left button Clicked on keyBlade

    -> System: Set MouseClicked to True

    ----+ keyBlade: Is dragged

    ----+ System: Is MouseClicked

    -----> System: Set MouseClicked to False

    -----> keyBlade: Tween "slide-back" property Position to Self.initialX, Self.InitialY in 0.5 seconds (Linear, destroy: No)

    -----> keyBlade: Set dragged to False

    -----> Run JavaScript: console.log("is Not Dragged so play slide")

    ----+ keyBlade: [X] Is dragged

    ----+ System: Is MouseClicked

    -----> System: Set MouseClicked to False

    -----> keyBlade: Set initialX to Self.ImagePointX("start")

    -----> keyBlade: Set InitialY to Self.ImagePointY("start")

    -----> keyBlade: Tween "pos" property Position to Self.ImagePointX("end"), Self.ImagePointY("end") in 0.5 seconds (Linear, destroy: No)

    -----> keyBlade: Set dragged to True

  • It would be much easier to help you if you posted a screenshot of events (instead of text, which is very difficult to read).

  • It would be much easier to help you if you posted a screenshot of events (instead of text, which is very difficult to read).

    I'll take that in mind for the next time. Thanks. Old coder, old habits. LOL! :)

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