dop2000's Forum Posts

  • I should also specify that the points themselves shouldn't be in any specific order, just whichever is closest to Sprite 2 instance.

    You should've mentioned this from the beginning.

    The easiest solution would probably be attaching 4 invisible "Anchor" sprites to these image points - you can do this manually in layout editor, add them as children to the hierarchy.

    Then you can pick the nearest Anchor sprite and replace it with Sprite2:

    Sprite1 On collision with Sprite2
    Sprite1 Pick all children Anchor
    Anchor pick nearest to (Sprite2.x, Sprite2.y)
    ... Sprite2 set position to Anchor
    ... Sprite1 add child Sprite2
    ... Anchor destroy
    

    Alternatively, if you want to do this with image points, you will have to loop through all image points, check which ones are unoccupied, and which one is the nearest to Sprite1 - the code for this will be pretty complicated.

  • FileChooser doesn't work on mobile. You will probably need to install a third-party Cordova plugin, like this one. And the app will require permissions to access files and folders.

  • Yes, your event may look something like this:

    Origin image point has index 0. Image points 1-4 are for attaching instances of Sprite2.

  • There are a few options:

    1. Create an instance variable - AttachmentPoint=1. Use it to identify which image point to attach Sprite2 to, and increment it by +1

    2. If attaching with hierarchy you can simply check the number of children on the parent sprite.

    3. You can loop through all 4 image points and check if any of them is not overlapping Sprite2. Use "System Is overlapping point" condition.

  • You do not have permission to view this post

  • Rain particles in Moonstone Island:

    youtu.be/fHn58YcTr-c

    Spawned 2 copies with different size/speed.

    Properties:

  • You do not have permission to view this post

  • I suggest using MoveTo behavior instead.

    Sprite Move to X:random(grid.BBoxLeft, grid.BBoxRight), Y:random(grid.BBoxTop, grid.BBoxBottom)

  • With the official plugin use "CSV parse" action to load the table into an array. Then access the values in the array using "for each" loop or array.at(x,y) expressions.

    You can create a couple of helper functions, for example:

  • Put "Every 0.2s" as a parent condition. And nest other events under it. This way the engine will perform the picking only 5 times per second and not on every tick.

  • If you have more than one tower, your code will not work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's difficult to understand what's going on in your screenshot. In the second event you need to pick the tower instance which is being dragged. Also don't use "Trigger once" like that!

    Here is a simple version which works with mouse and touch:

    dropbox.com/scl/fi/kh30pucvsn4bnx02qzcyt/dragTowers.c3p

  • If you only need to know which instances were destroyed, then you obviously don't need to save their full state as JSON. If you place these objects manually on the layout, they will have fixed UIDs, so you can simply store the list of UIDs which were destroyed. Use an array:

    Player on collision with sprite: Array Push back Sprite.UID, destroy Sprite

    .

    However, if you need to know which instances were destroyed and also save all properties of the remaining instances, you can't use IIDs.

    From the manual:

    Since you are destroying instances, you need to use UID or a different (custom) identifier. Say, add an instance variable "Code" to the sprite, set a unique code for each instance.

    When leaving the layout:

    For each Box : Dictionary add key "Box."&Box.Code with value Box.AsJSON
    

    When returning to the layout:

    For each Box 
     Dictionary "Box."&Box.Code exists : Box set from JSON Dictionary.Get("Box."& Box.code)) 
     Else : Box destroy
    
  • So, for example, the array has two rows - first contains enemy types (zombie, goblin, skeleton), and the second row contains the amount of points. Is this correct?

    Then you need to loop through the array searching for enemy type. Or use array.indexof() expression:

    Add Array.at(Array.indexof("zombie"),1) to Score

    This may be easier to do with a dictionary instead of the array. Then you simply use Dictionary.Get(enemytype) to get the number of points.

    You can store the enemy type in an instance variable on the sprites.