How is this possible? See code...

Get help using Construct 2

Post » Sun Dec 13, 2015 9:38 pm

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?!...

Image

Image

Image
Last edited by locohost on Sun Dec 13, 2015 10:19 pm, edited 1 time in total.
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Sun Dec 13, 2015 10:10 pm

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?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 13, 2015 10:21 pm

@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 :-(
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Sun Dec 13, 2015 11:32 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 14, 2015 12:05 am

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?
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Mon Dec 14, 2015 12:09 am

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?
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Mon Dec 14, 2015 12:14 am

locohost wrote: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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 14, 2015 12:28 am

locohost wrote: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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 14, 2015 12:38 am

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?
Last edited by locohost on Mon Dec 14, 2015 12:44 am, edited 1 time in total.
B
14
S
4
Posts: 300
Reputation: 1,643

Post » Mon Dec 14, 2015 12:43 am

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.
Last edited by locohost on Mon Dec 14, 2015 12:44 am, edited 1 time in total.
B
14
S
4
Posts: 300
Reputation: 1,643

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests