dop2000's Forum Posts

  • Yes, if you use "wait" in a loop, you can't access any temporary variables (local variables, loopindex expression, function parameters etc.) after the "wait" action.

    You need to use either global variables, instance variables or static local variables.

    For example, this will not work:

    For i=1 to 10 -> Wait 0.5*loopindex ; Create Sprite at (loopindex*50, 200)

    You have to change it to something like this:

    Local Static variable x=0

    For i=1 to 10

    ... Wait 0.5*loopindex

    ... Add 1 to x

    ... Create Sprite at (x*50, 200)

  • You can convert both ways:

    Set number=int("2")

    Set text=str(2)

  • facecrime

    find(Object.myStringOfNumbers, "2")

    If this returns a number >=0, this means that "2" is found.

    But, if your string is long and contains numbers with multiple digits ("0,7,8,12,22,729") , if you need to find exact number 2, you should search for ",2," string.

    With lists like this it's better to use tokenat/tokencount

  • There are a number of expressions you can use:

    to parse a string with a list of values separated by comma or some other symbol - use tokenat(), tokencount()

    For example:

    For "x"=0 to tokencount(text, ",")-1

    ...value = int(tokenat(text, loopindex, ","))

    to search for a substring - find()

    Other expressions:

    left

    right

    mid

    len

    etc.

    https://www.scirra.com/manual/126/system-expressions

  • Both sprites should be on the same layer, mask sprite should be above the pink square, mask sprite should have "Destination out" blend mode.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I started replying, then got distracted and tarek2 beat me

    Yeah, the problem is that all these events are executed on every tick (unless they are sub-events under some parent event, it's not clear from the screenshot).

    If these events are top-level, this means that the animation is restarted again and again on every tick and lots of "wait 1.83" threads are created... It could be a total mess.

    You need to use Else:

    Health=4

    Else Health=3

    Else Health=2

    etc.

    Otherwise when health is for example 1, all four top events are triggered.

    Or add another condition - check if animation is playing:

    Health<=4

    (and) Heart5 is "HeartDestroy" is NOT playing

    Alive=0 condition is also triggered many times and restarting the animation...

    You can add "Trigger once while true" to it or set alive= -1, to prevent if from triggering again.

    Also, don't use long-running "Wait" actions, you don't have control over them. Use Timer behavior.

  • You should try again, because it does work. Make sure the "hole" sprite is on top of the main sprite. And both sprites are not on the bottom layer.

  • raymond91 , It may sound stupid, but check maybe this behavior is already added to the object?

    Or it could be added to the family, if the object is part of the family.

    Timer behavior has no properties, so it's hard to notice.

  • You can use Touch.AngleAt(0) and Touch.SpeedAt(0) to recognize gestures.

    Here is a demo I made for another post:

    https://www.dropbox.com/s/tetv3j8m1psww ... .capx?dl=0

  • Check the tutorials section or google "construct 2 quiz", there should be lots of examples:

    https://www.scirra.com/tutorials/all

    As for the roulette, here is a demo:

    https://www.dropbox.com/s/rkdka12tfwcv6 ... .capx?dl=0

  • Pretty sure all sprites (visible, invisible, off-screen, with all their animations) are loaded into memory on start of the layout.

    You can easily test it - put several big sprites on the layout, make them invisible, run the project in debug mode (Ctrl-F4) and check memory usage.

  • I hit this bug again today and it took me almost 2 hours to figure it out!

    This time it was a bit different. I have two sprites in a container, and an event like this:

    Sprite1 DragDrop is dragging
    
       Sprite2 var=foo    -> Sprite2 set x to 100
       or
       Sprite2 var=bar
    
       Else        -> Sprite2 set x to 200
    [/code:3lirp5ur]
    
    The Or-block and its Else part are supposed to test only one instance of Sprite2 (the one in the container with Sprite1 which is being dragged).
    But instead, these subevents sometimes pick some other instances on the layout...
    Changing the Or-block to "System compare two values: Sprite2.var=x | Sprite2.var=y"  resolved the problem.
    
    @Ashley , will this ever be fixed?
  • I also though it was hard, until I discovered Tutorials and FAQ!

    https://www.scirra.com/tutorials/all

    how-do-i-frequently-asked-questions_t63692

  • Two ways to do this:

    1. add "shotDamage" instance variable to your shot sprite. When shot is created, set shotDamage to some number (how much damage it should deal).

    When shot hits an enemy, subtract shotDamage from enemy's health.

    2. When shot hits the enemy, compare shot's animation name and/or animation frame and decide how much damage it will deal.

    Something like this:

    Shot On collision with Enemy

    ...Shot animation "BigBullet" is playing -> Enemy subtract 100 from health

    ...Shot animation "SmallBullet" is playing -> Enemy subtract 20 from health

  • In the future you need to save your project as single file (capx) and share just the capx file, not the entire folder.

    I modified your "autosave" file, so it might not be the latest version of your game:

    https://www.dropbox.com/s/fsndp78ierdqo ... .capx?dl=0

    You should spawn new towers from "TowerDisplay" object, not from Tower1.

    I also removed all off-screen objects and moved them to an unused layout. This way they will not interfere with your game.

    When you add new objects, place them onto that Assets layout.