John Cutter's Recent Forum Activity

  • WackyToaster

    Haha! Unfortunately, I can't open your example. (It says you are using a newer version and won't let me open the file...) Are you using a beta version?

    Before I "fixed the issue" my code was doing this:

    If card clicked on, set global value cardClickedOn
     If random greater than 50 --> start "flip1" tween
     Else --> start "spin1" tween
    
    If flip1 tween is finished start flip2 tween for cardClickedOn
    If spin1 tween is finished start flip2 tween for cardClickedOn
    
    If flip2 tween is finished start flip3 tween for cardClickedOn
    If spin2 tween is finished start flip3 tween for cardClickedOn
    
    If flip3 tween is finished start flip4 tween for cardClickedOn
    If spin3 tween is finished start flip4 tween for cardClickedOn
    

    But I was clicking on new cards before the tweens were finished, so cardClickedOn was no longer the card I was trying to tween.

    I thought about having an instance variable called "Tweening" for each card and iterating through all of them to continue any tweening that had started, but I would have to constantly iterate through every single card.

    Then I hit on the new idea. (Based on an AI suggestion.) Now I just create a bunch of uniquely named tweens that include the UID so I know which card to update.

  • I'm waiting for one of the experts to tell me, "You are WAY overcomplicating things. All you need to do is..."

    ;-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This forum has been an invaluable resource for me so I am posting this in an attempt to "give back" to the community. (This technique might be used by many of you already but perhaps it will be new to some. It was new to me!)

    The Problem:

    My game has 20 or so instances of a card on the screen. To spin the card I have to sequence multiple tweens together, like this:

    - Get UID of clicked on card

    - Tween xscale from 1 to 0

    - If tween is finished --> change sprite image to back

    - Tween xscale from 0 to 1

    - If tween is finished --> change sprite image to front

    But because there can be multiple tweens happening at the same time the logic was getting confused. For example, before the first tween sequence had completely finished the player might have picked a new card. Now my "On finished" event would reference the wrong instance!

    My Solution:

    When I create a tween I now tag it with the UID of the card that was clicked on. Then I can pick the correct card by parsing the tag.

    The player clicks on a card:

    -> fam_cards: Tween "spin1_" & fam_cards.UID property X Scale to 1...

    Then I can simply check:

    + fam_cards: On Tween "spin1_" & tokenat(fam_cards.Tween.Tags,1,"_") finished

    + System: Pick fam_cards by evaluating fam_cards.UID = int(tokenat(fam_cards.Tween.Tags,1,"_"))

  • Thanks, mOOnpunk! I'll give that a try.

  • Thanks for trying to help everyone! I'm not sure what I'm doing wrong here, but it's still not working.

    Layer 1 is set to force own texture.

    + Mouse: On Left button Clicked on Sprite2

    -> System: Create object canvas on layer 1 at (Sprite2.X, Sprite2.Y), create hierarchy: False, template: ""

    -> canvas: Set size to (Sprite2.Width, Sprite2.Height)

    -> canvas: Paste object Sprite2 with effects

    -> Sprite2: Destroy

    -> canvas: Set drawing blend mode to Destination out

    -> canvas: Fill ellipse at (Mouse.X, Mouse.Y) radius (15, 15) with rgba(0, 0, 0, 100) (Smooth edge)

    When I click on the sprite it just disappears.

    I think I'm going to just do this with art. That should still work well!

  • Not sure what I'm doing wrong but I just can't get this to work.

    Here's basically what I'm trying to do. If anyone sees an issue with any of these steps, please let me know.

    - Player clicks on sprite

    - Make sprite invisible

    - Create instance of sprite on "Effects" layer (texture draw = true)

    - Make new instance invisible

    - Copy new instance to canvas (also on "Effects" layer)

    - Wait for events (give time for draw to happen)

    - Set canvas blend mode to Destination Out

    - Paste hole sprite to canvas

    When I do this my sprite image turns black. Any ideas?

  • Thanks for the reply, Jase00!

    I was trying to follow dop2000's example described here:

    construct.net/en/forum/construct-3/how-do-i-8/punch-hole-sprite-reveal-layer-156127

    I modified it to work on just the sprite being clicked on:

    This works... but those same events don't work in my game. I tried to match the sprite and layer details, but with no luck.

    One difference is the way I had to use containers. My game uses spr_card and fam_cards (with spr_card as the only member), and all card references use fam_cards. Unfortunately, I apparently can't use a family in a container... so I had to add spr_card instead. Not sure if that messed anything up or not.

  • I have roughly 35 sprites on the screen, all on their own layer. When the player clicks on one of these sprites I want to punch a hole in it.

    I found an example from dop2000 and tried to adapt it, but the sprite clicked on either turns black, or it cuts out a sprite shaped hole in everything else in the background.

    Note: My canvas object is on the same layer as my sprites. I also set the "Force own texture" to true for this layer.

    Any suggestions?

  • I'm working on a card game and the logic is getting messy. What is the best practice for tween sequencing?

    1. I use tweens to deal cards, one at a time, to the tableau

    2. When the tween is finished I enable a Group to do the next tween.

    Unfortunately, the event in #2 fires as soon as the first tween finished. (The rest of the cards are still being dealt onto the screen.)

    I tried to add a "Wait 2 seconds" to the start of the next group, but this messed up my instance picking. (It took FOREVER to figure *that* out.)

    My other group is called "Draw Next Card" and I have to use a global variable called "UI_var". I set it to 1 and then, after the first set of tweens, I set it to 0. This way it doesn't call the tweens over and over again while waiting for one of them to finish.

    It's working, but is there a better way to manage all of this?

  • dop2000

    SERIOUSLY??? You define the value of a global string by NOT including quotation marks??? I spent HOURS working on this yesterday. Good grief...

    I've been using Construct 3 for years, how did I not run into this before? I guess I have mostly used global numbers. Argh

    I thought I was taking crazy pills last night. I simplified it down to 3 events:

    Set global string to "Testing"

    1. Confirm global string --> "Testing"

    2. If global string = "Testing" --> FAIL!

    WTH??????

  • Well, it's not an issue with the OR block or "On start of layout". I just tried this:

    When I launch my layout and look at the debugger I see:

    versionType = "Testing"

    str_Test = "Testing"

    So I verify that versionType = "Testing" and then immediately test if versionType = "Testing" and it fails. (If it had succeeded str_test would be "OK")

    If I delete "versionType = 'Testing'" it succeeds. Why can't I check the value of this global string? I'm SO confused.

    UPDATE: I just added a new global variable called verNum and set it to 1. Then I changed my condition to:

    verNum = 1

    This works! Why doesn't the string work?

  • Just when I think I'm finally starting to understand this program... <sigh>

    Why doesn't this work:

    In global values I set versionType = "Testing"

    LayoutName = "lay05_coreGame"

    Seems simple, but when I run this code str_test is always an empty string ""

    Possibly relevant:

    - the layout is lay5_coreGame which uses sht5_coreGame.

    - sht5_coreGame includes sht00_globalLogic

    - the code above is in sht00_globalLogic