[r114] On key press

0 favourites
  • 6 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Hi,

    Here is the thing :

    <img src="http://img405.imageshack.us/img405/2852/blehfc.png" border="0" />

    On this situation, X works only to setting FireMode to 0, but not to 1.

    If I start the game (FireMode set to 1), pressing X set it to 0. If I press it again, nothing happens.

    If I start the game (FireMode set to 0), nothing happens while pressing X.

    If I use 2 separate keys on each event, for exemple X and V, it's working.

    If I invert events 14 and 15, the problem is inverted.

    Same problem with "On a key released".

    What's wrong with that ?

    I presume Construct is triggering both events 14 and 15 in a row on a single key press, in that case it would be a bug. Only one should be triggered.

  • I am experiencing a strange error with on pressed as well. It seems like there are multiple events being fired at one press maybe? I have a key press command, where on up press, you change a variable from 0 to 4. Each press sets the number to 3, 2, 1, 0. Strangely, right now, if I press up, it should set it to 4. But it is setting to 3.

    In the first image, if I press up, currentlySelected becomes 3. NOT 4.

    <img src="http://i.imgur.com/8uidb.png" border="0" />

    In the second image, it becomes 4 as expected. Let me know if I am just missing something.

    <img src="http://i.imgur.com/7Nfsq.png" border="0" />

  • Tenshi and firebelly/: the bugs you just reported are not actually bugs, as far as i know, if Construct 2 works exactly like any programming language (don't wan to get you bored reading long explanations here).

    Tenshi: if you put a single keyboard event ("On X press") and two separately sub-events ("FireMode = 0" and "FireMode = 1") in an "Else" event type, i imagine it should work properly. Try it!

    firebelly: try to use another variable (lets's gently call it "AlmostTrashVar") just to set the number you've inputed directly in the "CurrentlySelected", and then, outside the event "On Up Arrow pressed", set the "CurrrentlySelected" the value stored in the "AlmostTrashVar".

    I hope i could help you.

    Sorry sir Moderator if I wasn't able to post an answer here. Oops!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Closing as not a bug, neither of these are bugs. Remember events run top to bottom, so in this case multiple events are running in one tick which is probably confusing you. This is why you need to use 'Else'.

  • Totally my bad on this. Adding Else before each of the statements created the right impact. I was assuming subevents acted as Else Ifs and not Ands. Else Fixed everything.

  • It would be more efficient as checking all events first and then if conditions of some are met, execute respective actions.

    So order wouldn't have any impact, it's usually like that every software of this type are working. ;)

    But of course it wokrs with "else". ;)

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