tanman1129's Forum Posts

  • 8 posts
  • I have an intentional "fragmented" array where some elements are at unpredictable index positions. What I need to do is to only keep elements (string in this case) consecutively in index positions (0,1,2...n) thus eliminating any "holes" in between in the array and then reducing the Width (size or len) or array to just those elements that are not empty (strings, and not zero in this case).

    The code is shared in the attached image.

    What I want is something like (in C-like pseudocode):

    for (int i=0; i<Array1.width)

    if Array1 == 0

    delete(Array1.)

    But the problem is, where I added a sub-event under for-loop to check if Array1.At(LoopIndex("i")) it removes SOME empty elements but not all at once. If I repeatedly press the Defrag Array button, it eventually removes all zero/empty ones...but I need it to be done in one loop in one step.

    For example: If fragmented array was "0A0C0000D0"

    and I call Degrag function in my code, it turns it into "AC00D" (leaving two zeros still...where only ACD must be retained after degragmenting)

    After I press "Defrag Array" two more times, it correctly comes to the clean array: "ACD" with Width=3

    Which makes me suspect that I did not place the check if Array1.At(LoopIndex("i")) correctly to check each element within the for-loop in one fell swoop. This is in function DefragArray.

    Thank you in advance.

  • It appears suddenly, as of "Release r268 stable", the sprite's index 0 and 1 are not working correctly. Even though the index 0 frame is a specific image (and property is set to initially index 0), it loads the index 1 frame (even when animation is turned off). This is a new behavior. Is it only a bug for the free edition (which I'm on currently for evaluation) or more widespread??? Never noticed it before. Thank you.

  • Is there any to show a modal dialog (as in PCs) on top of an existing layout with buttons such as "OK", "Cancel" or "Yes", "No" without having to design another layout? If so, any example or pointer to documentation would be appreciated.

    TIA!

  • Hello coders. New to C3 here. Wondering if C3 can make it simple to create a game between 2 tanks (classic game) where user sets the angle and fires. So the gun would move up/down viewed from the sides of two-facing tanks (as opposed to being viewed top-down on the turrets) depending on the angle value chosen. The bullet/projectile should follow general formula of a projectile's trajectory (based on user's selection of speed or acceleration?...bullet property as speed and acceleration and gravity). And the distance should be close to realistic. Wind speed factor calculation would be great. I have the general formula (somewhere tucked away) for calculations but would like to know what params of the bullet behavior (unless there's another to use) I should get from user, and more importantly if it can make a bullet/projectile sprite follow the path/trajectory properly given those params. TIA!

  • Can you please share how to have a button or sprite (when clicked) open a URL/webpage? I have an HTML app built on Construct3 (which is hosted on my server) and in some conditions I need users to be able to go into another HTML5 app (also built in C3) to a link simple as myserver.com/blah where I'm hosting another C3 HTML5 app.

    Many thanks!

    Tagged:

  • Hello again Kyatric, I delved into the details of the code and details of each object. Very clever! I like it. The instance variables for x,y coords associated with each tile uniquely and that each sprite's images animation frame can be accessed at will was my X factor. Well done! I think I can figure out the array part on my own from this point on if I choose to scale out at large matrices. Cheers.

  • Thank you Kyatric for the example. The reason I wanted array implementation is because I'd like to increase the size to say, 15x15 matrix and not have to manually put 225 tiles on the layout...so I'm hoping that I can have just 2 sprites: 1 happy, 1 sad.

    Then in a loop I'd like to create 225 (n) number of cells of the happy sprite, and just 1 cell with the sad face...the objective is to only identify a click/touch on the sad one.

    I see your example and is very helpful and will go through it more---but I wonder if tiles creation can be done for the larger matrix (maybe for-loop and createobject or cloneobject method in the loop)?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi all, very new to C3. How can I make a simple 2x2 matrix that looks like tiles and each tile will have a simple image/sprite...except one. That one will be a different sprite but should be located at random location of the tile. So I'm thinking a 2D array but not sure how to link the array in memory to the sprites/images' location. I know C/C++, Python and others, but this paradigm is new to me.

    example: I want an image of a happy face (image_ repeated and shown in a tile of a 2x2 matrix. Then at a 0-index based array's random location (e.g. 0,0 at first cell once, then at 1,1), I want a sad face (image) appear. Then when the user clicks on the sad face sprite object the game does something, like score (I can do that part).

    A simple example would be VERY appreciated and make the difference between buy/not-buy.

    I need to populate the array with a for loop (I think I can figure out the loop part on the array object) but with the images (this part I'm confused about). Then pick a random location and insert (push?) an image to that random location and keep track of that specific tile (so I can track user-click on it).

    P.S. I'm trying out on free account before buying, so I can only do 2 layers max and 50 events.

    MANY THANKS!

    Tagged:

  • 8 posts