XAudio2 Issues

This forum is currently in read-only mode.
From the Asset Store
Wind effect
$2.49 USD
Animated wind effect for objects, grass, trees, etc.
  • I'm wondering if there is a bug with construct 0.99.91. Basicly, the following code doesn't work:

    C: On Left Clicked on mutesprite

    Inverted C: Master is Muted (an XAudio2 function)

    A: Set Master Muted (an XAudio2 function)

    A: mutesprite: Set animation to "Animation 1"

    C: On Left Clicked on mutesprite

    C: Master is Muted (an XAudio2 function)

    A: Set Master Unmuted (an XAudio2 function)

    A: mutesprite: Set animation to "Default"

    C = Condition

    A = Action

    It works as long as you use any keyboard condition except for the left mouse click. Any ideas as to why? If it is a bug, will someone report it onto the bug tracker for me since I don't have a sourceforge account. Thanks.

    BTW-Why isn't there a condition for seeing if the Master is muted? Also, would it be "a XAudio2" or " an XAudio2"?

    Edit: The problem seems to occur whenever the keyboard condition for both events is the same. For example, replace both left mouse clicks with m and you have the same problem.

  • On left clicked is a trigger, so you don't really want to have both in there. You're only going to have success with one trigger of the exact same type in a given frame. Just make the secondary conditions into sub-events (looks like you can get away with the second one being an "else" here, too).

  • This is often asked. I've started a thread, that may help understanding the work flow within Construct and why branching is the way to solve problems like this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi. While tulamide provided a nice write-up of the general problem here, I thought I'd reiterate it about your specific problem as well. The thread that tulamide made is definitely worth a read, though, so check that out as well.

    C: On Left Clicked on mutesprite
    Inverted C: Master is Muted (an XAudio2 function)
    A: Set Master Muted (an XAudio2 function)
    A: mutesprite: Set animation to "Animation 1"
    
    C: On Left Clicked on mutesprite
    C: Master is Muted (an XAudio2 function)
    A: Set Master Unmuted (an XAudio2 function)
    A: mutesprite: Set animation to "Default"[/code:3trxyti0]
    
    Using tulamide's 'snapshot' analogy, the thing to note here is that ALL 'On Left Clicked' conditions will be true for the one tick in which they are polled after the left click takes place. This is by design, so that you can have more than one condition testing for it, though it's usually not necessary.
    
    However, changes that you make are generally instantaneous. So, your first event actually sets up the second to be true as well, effectively canceling each other.
    
    The best way to do that is to check for the left click, then in a sub-event of that, check the 'muted' state, carrying out the appropriate actions if so. It's important that both conditions can't be true in the same tick, so the system->else condition comes in handy for that. Put the second set of actions under an else condition, and there is no way that both sets of actions can be run in the same tick. That's also why it worked if you used different keys for each, as that kept both from being true in the same tick.
    
    [code:3trxyti0]C: On Left Clicked on mutesprite
    ---C: Master is Muted (an XAudio2 function)
    ---A: Set Master Unmuted (an XAudio2 function)
    ---A: mutesprite: Set animation to "Default"
    ---C: Else
    ---A: Set Master Muted (an XAudio2 function)
    ---A: mutesprite: Set animation to "Animation 1"
    
    C = Condition
    A = Action
    --- = Sub-event (one level of indentation)[/code:3trxyti0]
    
    That would look just as tulamide's good and easy 'hello world' example in the other thread, if it's hard to tell the structure from the text example.
    
    [quote:3trxyti0]
    BTW-Why isn't there a condition for seeing if the Master is muted? Also, would it be "a XAudio2" or " an XAudio2"?
    
    
    I didn't see an expression for checking the muted state either. Maybe it was overlooked.
    
    And I've always gone with 'an' with words that start with a vowel sound, and I think of that name as 'ex audio two'.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)