Tungstan's Recent Forum Activity

  • 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

  • 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!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

Tungstan's avatar

Tungstan

Member since 18 Mar, 2018

None one is following Tungstan yet!

Trophy Case

  • 6-Year Club
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

9/44
How to earn trophies