How is this possible? See code...

0 favourites
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • I move the mouse to hover over a card sprite, press "F" to flip it over. How can this code flip the wrong card? It flips some other card that is no where near the cursor!? The card that it flips does not even have Location = CARD_INPLAY! There is only one event in all of my Event Sheets that fires on F released. WTH is happening?!...

  • You are calling the function with parameter famcard.GUID, I guess this is to be able to identify the card in the function..

    Are you sure that there is only one card with your variable family.GUID and that you are referencing that card only in your function?

  • LittleStain I added two more screen clips. The function called and my console.log. The global var CARD_INPLAY = 5. In the console, the first card, GUID=20 is the card that my mouse is over, the second card, GUID=180 is the one that flips.

    Yeah, I know

  • I'm not sure..

    I know I would use a very different approach to get the same thing done, but well..

    First of all, I wouldn't use GUID at all, UID should work fine..

    Second instead of pick overlapping, I would use mouse is overlapping famcard..

    Does exactly the same..

    Also I wouldn't use system compare for the animationframe, you can check it from the family-object..

    System compare doesn't pick, but seeing you've already narrowed the pick down, I don't think that's the issue, it might be though..

    Actually..

    I'm pretty sure it's the system compare event..

  • GUID comes from an Xml data file. Are we 100% certain that UIDs will always exactly match on multiplayer games? My assumption is no, so I went with the GUIDs that I am 100% sure will match.

    I did use the Mouse overlapping initially, switched to this to see if it would fix. No change.

    Frame = 0 is the card back, 1 - X are the card faces. Not sure how else to toggle the visible frame? How else?

  • Also, if you're sure it's the GUID compare, I'm in trouble. I have this compare in every single function and event. A hundred places probably. So System compare cannot accurately pick object instances by a var?

  • Also, if you're sure it's the GUID compare, I'm in trouble. I have this compare in every single function and event. A hundred places probably. So System compare cannot accurately pick object instances by a var?

    System compare doesn't pick

    System pick by comparison, does pick..

    So you should change the system compare event checking the animation-frame with a famcard compare animationframe event..

  • GUID comes from an Xml data file. Are we 100% certain that UIDs will always exactly match on multiplayer games? My assumption is no, so I went with the GUIDs that I am 100% sure will match.

    In this case you are calling the UID from a picked instance, so yes, the UID will absolutely reference the same instance..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok that's interesting. I changed the System Compare Frame to FamCard Compare Frame, as you suggested. Now the very first flip does work on the card hovered. But then subsequent flips work on another (not the one hovered) card. So I'll say that's a good step.

    Also, I think we're disconnected on the UID question. Will all Card.UID values be the same on each player's running instance? We could assume that every player has the exact same version of the exported app, but it's possible they may not. How can UIDs be guaranteed to match for all players?

  • Right now, all Cards are in ONE sprite with many frames. Example: a standard playing card would be a sprite with 53 frames, the card back at frame 0 then all the Card values in subsequent 52 frames. I create 52 instances of every different card and set the visible frame accordingly. So one sprite handles every card on the screen.

    Perhaps this is not a good way to do this. I could put each Card in a separate Sprite with just 2 frames, back and front. Maybe this will change something.

  • Ok that's interesting. I changed the System Compare Frame to FamCard Compare Frame, as you suggested. Now the very first flip does work on the card hovered. But then subsequent flips work on another (not the one hovered) card. So I'll say that's a good step.

    Also, I think we're disconnected on the UID question. Will all Card.UID values be the same on each player's running instance? We could assume that every player has the exact same version of the exported app, but it's possible they may not. How can UIDs be guaranteed to match for all players

    ?

    Why would they need to be if you are only using it to reference an already picked object?

    for example:

    on object clicked

    call function with parameter object.uid

    will always call the function for the right object, regardless of it's uid..

  • What you have should work. You probably are safest using fixed GUIDs to sync between two clients.

  • Actually the object's uids will be the same on any computer you run the exported project on. You can easily test this. The only fuzzy part I guess would be if you create any objects at runtime, but even then if you ensure you create the objects in the same order then they would be the same.

    The values for the uid are very predicable too. The first object has a uid of 0, the second: 1, and so on.

    My point is a guid sounds unnecessary.

  • R0J0hound All of the Card sprites are created runtime from Xml data. The configuration Xml is on a server. So that GUID is in the Xml which means I know, with 100% certainty, all Cards on every client have the same GUIDs. They will always be picked correctly and sync'd correctly.

    If there is a compelling reason, say a performance reason or similar, I could switch to UID, but I'd rather stay with what I have unless it's somehow "bad".

  • It was just an idea. No need to switch, and using a guid would be better if you run multiple games.

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