Tungstan's Forum Posts

  • interesting..

    I have checked the file to make sure there's no issues with it, and have re-uploaded here

    hopefully you'd be able to open it this time :)

    Thanks in advance!

  • Hi all,

    I am trying to understand arrays and functions. I have no prior programming knowledge, but I think I get the gist.

    In this instance, I want to create a very basic menu for a building game. The idea is to click on a plot of land (the signpost sprite) which will bring up a building menu, giving one options of what to build on that plot.

    I have written a simple code to get that to work, which it does. I have added an array and a function, but to be honest, I think I could have managed without them also..

    Can someone please have a look at the attached project; the question is this: How could I have written this better? Is this how (simple) arrays are supposed to be used?

    There are some other things in the project, please don't mind them. Everything I want looked at is in the "hud and menu event sheet".

    Thanks in advance for anyone taking the time to look this over!

    attachment

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey blackhornet, thanks for the reply!

    I'm less active during the week (work work work) but will definitely have a look again and see how I can streamline the conditions and actions taking your advice into account and I'll post an update :)

    Thanks again!

  • Thanks very much, blackhornet

    I've added another boolean to check/uncheck whenever the NPC have chosen a state which did the trick!

    I've added an image with the code block, if anyone else who is having brain farts like me :)

    Btw, I am wondering if this can be trimmed / improved in any way?

  • Hi all,

    I have a NPC sprite with animations (walking, idle) and 3 states: idle, left, right. The sprite has a timer behaviour. My goal is to make the NPC walk around (either left or right) for 2 seconds, then choose to either walk again (left or right) or idle for 2 seconds.

    My idea was to start a timer every time the state variable changes to either 0, 1, or 2, (state 0 = idle animation, state 1 = platform left, state 2 = platform right). I've included an image with the code block:

    When the state variable changes, however, the timer is initiated (either walking or waiting) but the countdown doesn't start. Both timers stay at 0/2 seconds:

    Any ideas, anyone?

  • I have actually solved my issue.

    The condition was incorrect. It wasn't set for the mouse coordinates, but for the placeholder sprite, when I needed to have the placeholder sprite snap when THE MOUSE is over the base sprite...

  • Hia folks,

    I have a sprite which follows the mouse (a "placeholder" for a building to be built). I have placed some invisible sprites on the ground which are meant to be a building base (buildings can only be placed on those bases).

    I want my placeholder to snap to an image point of each building base sprite when the mouse is around. So far, I made a rudimentary system with a simple mouse over condition:

    but the results are buggy at best. The placeholder is snapping, but not always, and not where it should.. I have also checked the collision polygons of both sprites. Made a quick capture below:

    https://i.imgur.com/0g6Bigd.gif

    The white rectangles are the base sprites, they are visible for testing purposes

    Any ideas on a reliable method for snapping to an image point are appreciated!

  • I've actually sorted it out!!

    I've made another variable equal to the variable "minutes"*60 and referenced in the Every X seconds and now the sprite is moving every 60 minutes (or one hour), as intended!

    Thanks for giving me the inspiration to find the solution to the problem!

  • Thanks very much for the reply,mrcgkh, I appreciate your input.

    This is how it is set up at the moment, but I can also just have it as self.x +1.

    What this does is moving the sprite right from the start and keeps on accelerating, which is not what I want. Removing "Every tick" doesn't help either. My problem is finding the correct condition to trigger the movement itself only when the "hour" variable changes (increases).

    I can make it work really simple like in the below image, however, I want to be able to trigger it by the "hours" variable rather than a flat number. If I change "Every 60 seconds" to "Every "hours" seconds" ("hours" being the variable), it just starts going right without stopping..

    I hope it makes more sense of what I'm trying to achieve.

    Thanks very much again!

  • Hia folks,

    I'm basically trying to have a representation of time passing in a day with 2 sprites. 1 sprite (at the bottom) is a long line, 54px long with a gradient showing the stages of the day (dark blue, dark orange, orange,yellow, light blue, blue, dark blue again). A second sprite is basically a round object that I want to move across the gradient line as the day in the game goes by. I have several variables that count seconds/minutes/hours/days.

    Basically, I want it so that every time the "hours" variable increases by 1, for the second sprite (the round object) to move to the right (or set position), along the gradient line by x amount of pixels.

    The way that I count times is:

    every 1 second add 10 to variable "seconds". Whenever the variable "seconds" reaches 60, it goes back to 0 and adds 1 to the variable "minutes" and starts counting again. When "minutes" reaches 60, it goes back to 0 and adds one to "hours". When "hours" reaches 24, it goes back to 0 and adds one to "days" variable.

    Any ideas on how to achieve that? It may be something very simple, I'm just not seeing...

  • Hi,

    Worked like a charm when I changed it to PositionToTileX/Y, thanks very much. Very silly me. I was already picking the correct instance of the tilemap, but I think I've just deleted it in the version I have uploaded.

    I think I know now what I was doing wrong. I was converting tile position TO mapsquare x/y when I needed to get tile position FROM mapsquare x/y.

    Please let me know if I'm right in my assumption.

    Thanks again very much!

  • Hi there, thanks for the reply!

    I've not uploaded the project previously as it's pretty big and has many other things in there. I've truncated a copy of it with just the things needed in regards to my issue, link below :)

    I have already checked in debug mode, the instances don't get the variable changed for some reason. I've also tried to force them to change on mouse over the mapSquares. The square maps are created at startup over the tilemap as you'll see. I've also removed the "for each" conditions from mouse over actions but still did not fix the issue.

    The layout has a 9-patch at the bottom (the "frame" of the map) and 2 instances of the same tilemap as stated previously. The UI General sheet is the one you want.

    Thanks very much in advance for any insights!

    https://we.tl/t-aynk06hls1

  • Hi guys, thanks for the suggestions and the example as well!

    When I try that in a new project it works the way it should, however, it's not working in my project and I don't know why.

    I don't know if it's worth mentioning, but there are 2 instances of the same tilemap on top of each other (one has the grass and the other has the objects like trees and river and bridge). I have tried referencing the instance of the tilemap by picking it via its own UID, but still no result.

    Any ideas why?

  • Hia folks,

    I am trying to create a map sort of feature. Very succinctly, I am trying to get each "square" of the map have it's own "resource value" depending on the tile that it is overlapping. Basically, I want to show how many "bundles" there are to collect for villagers, when the mouse is over the trees in the map.

    I have a tile map underneath the grid. The grid is composed of rows and columns of a sprite called "mapSquare". The mapSquare instances and the tiles overlap precisely. The sprite has a variable called "mapSquare_Bundles". My aim is to change that variable depending on which tile is beneath each instance of said sprite.

    Any comments are more then welcome :)

  • Hi guys,

    I'm trying to make a grapple hook / vine gun sort of thing. The idea is that I can shoot the target sprite which then sticks to certain objects. Once stuck, the vine is created by a repeat action, which creates the same sprite (rope) 6 times and moving each new instance at the "bottom" of the previous one.

    I can't think of a way to have the player attach correctly to the segments and have him go up and down and be able to jump from it. I have searched for examples and video tutorials, however none of them have the vines set up like mine, and I would like to keep mine as it's relatively simple to make and I understand (finally) how to make one. I also don't want to change the vine to a single thin sprite with the sine behaviour as it looks stupid (looks more like a swinging bar). Here's a picture of the vine creation for a better understanding: i.imgur.com/0KnHjtj.gif

    I'd really appreciate any tips or ideas.

    Thanks in advance!

    Tagged: