InDWrekt's Forum Posts

  • You should be using a State Machine to control your enemy states.

    A State Machine is a common programming tool that defines states something can be in. Each state needs an entrance and exit condition. All the code the enemy uses will be defined by the state it is in. Take a look at this example I through together from your question.

    drive.google.com/file/d/1t3nFqiq7syZXKRWGSOE-VrwVknfgDbeV/view

    My enemy will wander randomly until the player gets within 200 pixels. It will then charge the player and return to where it started the charge. It will be unable to charge until after a cooldown. If the player climbs the stairs so they are higher than the enemy, it will enter a flying state. I didn't add the code for attacking in the air but the state is there. After the player returns to the ground, the enemy will return to the ground and start wandering again.

  • You need to add the audio plugin. After you add it, there is an action "Play (By Name)." Pass the array value into this event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As I understand it, the ToLocaleString shows the time in the most common format for the location you are in. If you want to keep using that method, you will have to split the result up and modify the value yourself. You can use the ToLocaleDateString to get the date and join it to the ToLocaleTimeString. You would check if the time is followed by a pm and if it is, add 12 to the hours.

    -> Set text to Date.ToLocaleDateString(Date.Now) & " " & left(int(left (Date.ToLocaleTimeString(Date.Now), 2)) < 12 & right(Date.ToLocaleTimeString(Date.Now), 2) = "PM" ? int(left (Date.ToLocaleTimeString(Date.Now), 2)) + 12 & right(Date.ToLocaleTimeString(Date.Now), 9) : Date.ToLocaleTimeString(Date.Now), 8)

    Another option is just to build the time yourself using the getHours, getMinutes, getSeconds methods.

  • What method are you using to get the time? If you are using the Date plugin, the time is already stored in 24 hour mode and most of the time methods display it that way.

    Date.toString(timestamp) returns the date info followed by HH:MM:SS in 24 hr then time zone

    Date.toTimeString(timestamp) returns HH:MM:SS in 24 hr followed by time zone information

    Date.getHours(timestamp) returns a value between 0 and 23

    If you need to get the timestamp, use Date.get(Y,M,D,h,m,s,milli)

    Read through the documentation to see more uses:

    construct.net/en/make-games/manuals/construct-3/plugin-reference/date

    If you aren't using the date object, we would need to know how you are getting the date and time to be able to help you/

  • I'm not sure really what you are trying to do but maybe this will help.

    First, given the image, your events aren't going to choose a specific text object. You are using the system compare 2 variables event. This will trigger if it finds a value that matches but no object is selected so you don't know which object the system will choose. Most likely it will be all text objects.

    Instead, you should use a text event and compare it's variable. This is what your events would change to:

    Also, you can cut down your events simply by using the instance variable as the array index.

  • drive.google.com/file/d/1njkOW5E93Z6dAKfrj2u2FB2pDBqoCkmo/view

    Take a look at this example I built for another date question.

  • Without looking at your projects, we can't really tell you how to fix your issues. However, here are a couple things that are good practices that may at least get you a little closer:

    Platform - Check the animation origin point and make sure it is the same distance from the bottom collision boundary.

    Explanation - Your characters sprite will swap between a falling and standing animation repeatedly if the distance between the bottom of the sprite and it's origin are different on the 2 animations. I prefer to set my origin on platform characters at the base of the sprite and make sure the bottom of the sprites collision polygon is the bottom of the sprite.

    Top Down 1 - Don't use the move to behavior.

    Explanation - I wouldn't think this is what you are doing but I wanted to cover all the bases. Move to doesn't care about solid objects. It just moves to the given destination.

    Top Down 2 - Make sure your tile size matches the pathfinding grid size.

    Explanation - I can only assume in this situation that you are using something like the pathfinding behavior. This happens a lot using pathfinding for users who don't take the time to learn how the path algorithm works. If I'm wrong, you would have to post your project to be able to get help with this one. With the pathfinding, the system uses a grid to define impassible areas. The the size of the grid is stored in one of the pathfinding properties. If your tile size is 32 but your pathfinding grid is 20, the system may not calculate the path correctly. Your tilemap needs to have the same tile size as the grid size of the pathfinding behavior and it needs to have it's origin aligned with it as well (meaning the tilemap origin needs to be on a grid point with 0, 0 being the best origin). Take a look at this to get familiar with how the pathfinding grid works:

    construct.net/en/construct-2/manuals/construct-2/behavior-reference/pathfinding

    Again, to get help with a specific problem, it is best to post your project so others can see exactly what is going on. Without it, you may never get the answer you need.

  • If you're just using a png, all you have to do is open the image in the image editor of the built in tilemap object. The message you are getting comes from trying to open the file from the Tilemap bar.

    Find the tilemap in the Projects panel under the Objects section and double click it. This will pull up the image editor (just like editing a sprite). From there, open your image.

  • In my opinion, the easiest way to do this is with an array containing the animation names. When the game starts, you create the array and fill it. At the start of each round, you pick 3 random items from the array and set the text and image objects from them, then remove them from the array.

    I'm trying to make this matching game as an endless one...

    ...//probably 100 different animation

    I just want to point out, if you have 100 animations, showing 6 at a time and don't ever want an image to appear more than once, this project won't be an "endless one." The most levels the player will be able to play is 17. For an endless game, I would suggest not having the requirement that an image not show more than once. Since the images are chosen randomly, it is very unlikely that an image will appear right after it already has. Statistically, with a high number of images, it should be a while before you see the same image again (with these numbers, an image should show 1 time in 17 rounds).

  • In this image, I modified the tap ColorName action. It is now an on tap action which clears the color of the text with a subevent picking the tapped text object and sets its font size and color. In this version I am also using a global variable instead of the highlights variable.

    As for your comment:

    InDWrekt ...

    (I know "ColorNameHighlight" is kinda compulsory, so I made it invisible on the startup)

    Please help. Thank you.

    Nothing in the code I sent you is "compulsory." You can do everything I showed you many different ways. I try to emphasize this to newer Construct users. Nothing I show you is "The right way." It's just ONE way.

    I have modified the original project. There are now 2 different event sheets. The first layout is using the new event sheet. Instead of using the highlights, I added 2 instance variables to the TriesCountLabel that hold the last chosen color and name. I scale up the selected text and color squares and change the color of the text object. The new version still keeps score the same way, disables colors and names that have been correctly selected and continues to the next level when all 3 colors are chosen.

    Remember, there are many different paths that lead to the same result. The most important thing for you, is to learn the tool and decide which path works best for your needs.

    Good luck with your project.

  • Really!?

    local variables constantly reset!? Do you know the logic of why this is so?

    this makes them rather limited and forces me to use global when there isn't really a need for it to be global other than this weird limitation...

    mutajon, to answer why; in programming, a local variable is a variable that only exists at the time a method runs. Each time the program calls the method, the variable gets created and when the method ends, the variable gets destroyed. The variable is "local" to the method. Every tick in construct, the actions and events are run as separate instances. In essence, the system is calling each of these actions like methods which causes a local instance of the variables to be created then.

    I hope that helps you understand these local variables a little better.

  • You can either store the information in a format that the user can't easily figure out or encrypt the information.

    To save in a format the player can't easily figure out, you would convert the data prior to saving to something like a bit stream. A bit stream is a line of 0s and 1s built from converting your information to bits, zero padding each piece so the stream has each piece of information in exactly the same location, then appending all together so it is one long line. You have to parse and convert this back to the actually data when the file is loaded. This type of save is still able to be edited by more clever users but it will be harder.

    Encryption may be easier if you use a plugin. There are couple encryption plugins. I haven't tried them but they may be what you are looking for. You simply run the encrypt action when saving. Then decrypt when loading. This will make the file nearly impossible to modify and if the user tries to edit it, it will most likely corrupt the file. The only way to see and change the file information is with the correct encryption key and algorithm.

  • I can see why you are struggling with this. There really isn't an easy way to reference a global variable indirectly. There is 1 way I was able to come up with for you however. Try this out:

    drive.google.com/file/d/1HXei-9dZKNK7auwO9zIhSobVDIKQ4U_y/view

    I believe this will do what you are asking for. However, it could very quickly get out of hand if you have a bunch of global variables. You need 1 event per global you want this function to change.

    On a side note, why are you using global variables for this? Do you need the values to persist across multiple layouts? I only ask because I see many newer users using global variables like they were local variables. If these values don't really need to be persisted from 1 layout to the next, you could cut down the number of events necessary. For instance, instead of using globals, you could store the values in an array. Then, you would pass the index of the value you want to modify instead of the name of the variable. This would take the above example from 4 events in the function to just 1. In fact, this would even work if you do need these values to be persisted because the array is considered global if I remember right.

  • Sorry, you're right, I didn't notice this was in the Construct 2 forum. I just saw it under the unanswered questions.

    In Construct 2, you would do something like this:

    -> CurDate: Set text to left(Browser.ExecJS("Date()"), 24)

    This gives this result for me right now:

    Sat Dec 12 2020 09:30:49

    I believe the time is displayed in 24 hour format so instead of am/pm, you get a value between 0 and 23. If you need the date formatted exactly the way it is in your post, you will either have to modify it yourself or see if there is a plugin that will do it for you. I believe there is a pretty good date plugin from RexRainbow you could look at.