AllanR's Forum Posts

  • jobel

    I have programmed for decades too, and use arrays in Construct all the time. I guess I have trained myself to not look at the X and Y labels, and just think Row and Column. When I make loops to go through an array I use tags of "Row" and "Column" so I see:

    Array - set value at (loopindex("Row"), loopindex("Column")) = value

    and to get the number of rows, it is array.width

    we don't get constants, but I do sometimes make variables for field name like in your example to make code easier to read when I come back to it. then code looks like:

    Array - set value at (loopindex("Row"), Player_Name) = value

    Array - set value at (loopindex("Row"), Games_Played) = value

    so, just because it says "Set at XY" doesn't mean you have to switch the rows and columns around.

  • OK! that makes it all clear now!

    I have run into that many times. The issue is you can't assume that the top left corner of the screen is 0,0. Normally I use scan outer to use the whole available screen, so I didn't consider that you would be masking off area outside the layout.

    if all your layers have parallax set to 0,0 then the layout will be centered on the screen. If any layers have the default 100,100 then they will be shifted over to the left...

    so since I don't know how your layers and masking sprites are set up, I adjusted my sample to use all parallax settings of 0,0. You can re-download my sample and now I think it does what you want.

    https://www.rieperts.com/games/forum/timetext.capx

  • You do not have permission to view this post

  • cemdemo

    there is a wide variety of ways to do it... I would probably make a family if you are going to have lots of different block types.

    either you have to keep track of the last Y value, or pick the block with the lowest Y value (since you are building up and higher Y values are lower down the screen).

    I added a variable to keep the last Y. If you are going to be removing blocks and having them drop back down the tower, then you should go with the family idea and pick the block with the lowest Y - since it could change based on what the player is doing.

    https://www.rieperts.com/games/forum/blocktest.c3p

    edit: I was going to say I didn't think using block(-1) would pick the last instance, but I tested it out and it does! I don't remember seeing that in the documentation anywhere. that is very useful!

  • graham-s

    an object that is a container will automatically create all the things it contains at runtime - so even if you only place some on the layout, the rest will get created for you when the layout starts running.

    A family is what you want. The way I would do it is create an instance variable on the family so you can associate foliage with a tree base.

    I made a sample you can get here:

    https://www.rieperts.com/games/forum/treeshake.capx

  • yes, that code all looks fine.

    when I run my sample on my system with two monitors, I can release the touch way out side the viewport (like -1572) and the clock stays within the viewport.

    does my sample work for you? there must be some other place where the position is getting set...

    you could try running it in debug mode, which would let you see how many instances there are, what the coordinates actually are, etc...

    beyond that I would have to see all the code to figure out what is going on.

  • the problem would be after the you create the clock and timetext and compare the coordinates to the viewport. since timetext is pinned to the clock, make sure you are setting the clock's position.

    my sampled works, so there is some difference in your code (and not in the screenshots you posted).

    the viewport code must be a subevent from where the objects are created - otherwise they wont be picked, and the code will not be applied...

  • you can only pass the UID, and pick with it after you create the object.

    When you call the compliment function, you pass in a compliment UID, but then in the function you create a new instance. That instance wont be picked after the function so setting the animation frame wont work.

    what you should do is pass the animation frame you want into the function and set it when you create the object:

    condition1 - call "Compliment" (choose(6,7,8))
    
    condition2 - call "Compliment" (choose(9,10))
    
    Function Compliment
    	System - Create object Compliment on layer "HUD" at (270,0)
    	Compliment - Set animation frame to Function.Parameter(0)
    	Compliment - Stop animation
    	Compliment - Set Y to ViewportBottom("HUD")-60 
    

    check the sample I made the other day - I can drag way out side the viewport and the clock and timetext stay on screen. So you probably have an issue with your greater than and less than signs, or you are adding when you should be subtracting...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • brick334

    I took ROJOhounds example from the thread dop posted, and added a more bubble like image, and the ability to pop and create new bubbles.

    it isn't viable on mobile because the math ROJOhound uses is very cpu intensive... but it looks pretty good.

    https://www.rieperts.com/games/forum/bubbles.capx

    oh, it requires the paster plugin...

    https://www.construct.net/en/forum/extending-construct-2/addons-29/plugin-paster-66240?kws=paster

  • mammoth

    speech synthesis is part of the user media - and as the name implies, it is synthesized it real time by the device.

    you could record the voice and add it as an audio file, if that is what you mean.

  • insanesnake

    I think the manual says that when you regenerate the map, it isn't ready until the next tick. so when do the find path action right after the regenerate, it is using the old map...

  • jwilkins

    I like the blank weapon idea - I don't think it is inelegant at all.

    I also use arrays a lot. While it is true you can't make a family into a container to have an array object automatically created and picked, you can manually do it.

    create an instance variable on the family called WeaponArrayUID. Then whenever a character is created, create a WeaponArray object as well and save the UID with the character.

    then you have to make sure you pick the array by UID when you are dealing with a character, but you will have as much storage as you need.

    you would also have to manually destroy the array when you kill the character, but you probably have to do that to anything pinned to the character anyway...

  • jatin1726

    probably not very easy to do...

    my guess is that you would have to use the Geolocation plugin to get the user's location, build a request string to send to one of the weather APIs using AJAX and then parse the response. (some return XML or jSON)

    You would have to set up an account at one of the weather APIs - some are free but limit the number of requests you can make, others are a paid service.

    get your API keys, some make you whitelist your app - which can take days. Generate an oauth signature...

    The only thing similar I have done is use the google maps api to get mileage between two addresses. It was for a business app used at the company I work for and only used by a few people, so I didn't have to worry about limits and commercial restrictions.

  • you will need the noisejs plugin

    read through the thread, and google perlin noise to learn more.

    https://www.construct.net/en/forum/extending-construct-2/addons-29/plugin-noisejs-71474?kws=noisejs

  • WRS

    that line creates all the level sprites in a grid to evenly space them out.

    you don't have to do it that way - you can have them already placed on the layout.

    it takes a short while to load the array data from local storage, so the game wont know which levels are locked or unlocked when the layout starts. You might want to set the level sprites as invisible until the array is loaded and you can set the correct animation, and show how many stars have been earned.