nimos100's Recent Forum Activity

  • I fought with the same problem as you and came up with a solution for not having to use waits, whether it will work in your case I don't know. But this is from that post (Its a bit long ):

    "-- First post --"

    Think I might have found a solution to do it without using waits. However it does requires an extra check every tick. But if it works I think its worth it

    The Idea is to use an object handler, that can handle all newly created objects.

    You can make it with a list or array whatever you prefer. However you still need to organize the way you create objects according to the normal rules.

    In my case it uses a list, the idea is that these objects that rely on other objects that might not be created yet during the cycle, are added to this list. And then you apply whatever extensions to them that you want. And its actually quite simple to make.

    In my game the handler looks like this:

    Which in this case is the Quest_master_object that give me the problem. As its the one that rely on a Quest_step, which is a sub quest that are part of the master quest. To this Quest_step there is a dungeon attached. Which again is used to generate a random Quest description.

    To use the object handler all you have to do, is tell it what action you want it to do, in form of a Boolean, and then add the UID to the list. And then hook it up to a function, or whatever you prefer.

    And you can just add as many conditions and objects to the object handler as needed. I think the benefit comes when you have to do something several times during one tick. For instant in my case I actually have to repeat it 5 times, but having to wait each time is first of all not something I like, but also seems to create problems, as sometimes the descriptions got mixed, some steps weren't made etc.

    Anyway haven't tested it fully, but the initial tests seems to work very well, and now at least this problem is solved "

    "-- Second post --"

    [quote:2psokaom]Nice work. Looks pretty slick.

    I was reading up on the thread that explains why picking works this way now, and I'm actually confused.

    In the thread, it is explained that the object doesn't exist to same-level events until the next top level event. Then how come pick by UID works on our tests?

    Agree that it gets confusing, because its logic that you have created the object, so surely it must be there, but it actually ain't as explained by Ashley in that post.

    A solution also from that post is:

    [quote:2psokaom]The workaround is to try to do everything in the same event - nest the other events beneath the creating event if possible, so everything is moved up in to the green area.

    Which are the reason that you can create an object and right afterwards set its variables.

    Create object

    Set Object name = "Whatever"

    That also means that you can pick UID of the object if its in a sub level of the create function.

    But if you do it like this:

    level 1: Create object

    --------------Do something

    Level 1: Pick Object with UID of the newly created object shouldn't work.

    You have to reach a top level. (Now this post is from version r102, so its pretty old, but don't think a lot if any have changed.)

    However the common way of dealing with this problem as you most likely know is to throw in a Wait of 0, 0.1 or 0.01 or whatever as it will then go through to the next tick and force it to reach a top level or what to say and then it works. Im not really sure how solid this actually is, it seems to work well with simple stuff, but if it gets a bit complex it seems to not really work well.

    For instant if you have an event:

    Repeat 10 times

    ------- Call function("Spawn enemy")

    Function Spawn enemy

    Create enemy()

    Call function ("initialize enemy")

    Function Initialize enemy

    Call function ("Create enemy weapon")

    Function Create enemy weapon

    Create Enemy_weapon

    Then suddenly things starts to go wrong as I see it.

    Because now there are actually two objects that doesn't exist yet, The Enemy and the Weapon that you want it to use. So if you throw in a Wait different places to solve it, It might work. However at the very start we are actually repeating this 10 times, to create 10 enemies which will then create 10 different weapons, so suddenly you might have 20 objects that actually doesn't exist, and then it seems to go wrong. Whether that's completely true im not 100% sure about, but it seems that a function doesn't count as a top level, which I find to be logic if its the case, but I haven't seen anything saying that it ain't which is why im not certain.

    As I mentioned in my last post, I had to repeat it 5 times, but I did something similar with 50 objects using a wait, and it looked like it was working fine, however as I went through the objects in the debugger I could see that suddenly some of the objects would have "NaN" in some of the variables. Which didn't make sense as 95-98% of them had no problems and all different possibilities for this variable was used, but for some reason some of them just failed, and my guess it that since I repeated it several times, it might have screwed up with the wait somehow. So the only thing I did, was to move the function call to the Object handler, didn't change any code and none of them had any problems after that, same goes for several other mistakes that was happening. So I moved those as well and now all of them gets initialized correctly, without having to use wait, which I think in itself is a huge benefit.

    "--- end ---"

    Also if this doesn't work, maybe you can use the "Wait for signal" which weren't available when the above was discussed, but you might be able to make it so it will not do anything to these objects you create before all of them are made, in that case you "Signal" it to continue.

    R0J0hound - a nice visual explanation! So does Wait 0 sort of make the Function act like a top level event?

    No, wait doesn't make anything a top level, it just forces C2 to go "around" so to speak, it will look like it might make a function a top level. But in fact it could be anything else and most likely Is something else. And also as mentioned it the last part of my "Second post" you will most likely end up with things that seems to work but at some point it will probably give you weird problems, that are not easy to fix, as you "loose" control when using wait 0, 0.1 etc., At least that's my experience and why I never use them.

  • Sounds like you are using individual sprites, so depending on the size of your grid any event that works with these sprites will need to check each of them, so if you have a large grid it will eventually kill performance as you add more and more events and actions to your game.

    Depending on your game and what these tiles are used for, you might consider switching to using a tilemap object instead, and just use 2 different images. 1 which is grey and the other that looks blurry. And then you just switch the frame whenever you mouse is over one of them. Think that would make you able to do it pretty much without any performance drop and with a much larger grid than you can have with sprites.

  • You need to check the angle between your object and the mouse click. Here is an example of 4 directional movement:

    On mouse left click (Trigger)

    Next you need the four directions, Since the angle is calculated from 0 to 180 degree when going clockwise and 0 to -180 degree when going counter clockwise you have to add 360 to those in the counter clockwise direction to get the correct angle.

    So you will need 4 sub events, one for each direction and these you check with a between values.

    Up (Since this is going counter clockwise we add 360)

    Condition:

    255 <= 360 + angle(Object.x, Object.Y, Mouse.X, Mouse.Y) <= 315

    Action:

    Object.Angle = 270 (So whenever you click above the object in a cone shape it will set the angle of the object to 270)

    Down (Since this is clockwise we don't need to add anything)

    Condition:

    45 <= angle(Object.x, Object.Y, Mouse.X, Mouse.Y) <= 134

    Action:

    Object.Angle = 90 (So whenever you click below the object it points down)

    Left (As it changes from positive to negative as it goes pass 180 you need two conditions and an OR)

    Condition:

    180 <= 360 + angle(Object.x, Object.Y, Mouse.X, Mouse.Y) <= 224

    OR

    135 <= angle(Object.x, Object.Y, Mouse.X, Mouse.Y) <= 180

    Action:

    Object.Angle = 180

    Right (Exactly the same as for left except now it changes as it goes pass 0)

    Condition:

    0 <= angle(Object.x, Object.Y, Mouse.X, Mouse.Y) <= 44

    OR

    315 <= 360 + angle(Object.x, Object.Y, Mouse.X, Mouse.Y) <= 360

    Action:

    Object.Angle = 0

  • Its in the construct 2 examples when you start a new project just type RTS in the search bar and it will show up as a template.

  • The addition of ("Bases") makes the x and the y based on the layer Bases..

    If you have more layers than one and the paralax or scale of those layers are different x and y values can get troublesome, for they differ between the layers.

    Ok that makes perfect sense, thanks

  • Was looking in the RTS example and found this:

    What is the purpose of ("Bases") at the end of Mouse.X and Mouse.Y, Doesn't recall haven't seen it before. And reading the rest of the code doesn't make it any clearer why and what this is used for.

    Anyone knows?

  • First you need the sprite to "find a path" to somewhere.

    Then you need to check if the sprite have found a path "On path found" and in that case it should "move along the path"

    Then you add an "On arrived".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Running the bug preview I see I am getting around 45 FPS on desktop and on mobile preview I am getting around 12 FPS. I know desktops have better performance but should I be concerned with the low mobile frame rate?

    All my objects so far are sized with a power of 2 at 32X32 or 64X64, except for the player sprite, even my BG image is tiled at 64X64.

    It kind of depends on your game, if its a very small game or you are in the beginning of making one and you are seeing big drops in FPS, then something is most likely not working correct. But it also depends on your computer, and the debugger will always lower performance a bit compared to a normal preview.

    But are your game big with loads of graphic and events etc. Then loosing a bit of FPS in preview is rather common and should be expected.

    But what performance do you get with a normal preview?

  • Ok so if I understand you correct you have X amount of characters available, at some point during the game, the player can unlock these, and use them in later games if they wish. So when the player starts a new game you would like to load each unlocked character and show them in a selection menu, which is a tilemap?

    [quote:2pkn6525]As I write this the idea came to me that instead of using the UID of sprites or IID of the avatar family. I will look into just having the avatars in a folder in my project file and pull their img form there to replace a generic avatar. thus negating the need of a family. Worth a shot so give me some time and I will report back

    You don't have to pull the image from an url, if you use a tilemap it is much easier to store each character in the tilemap it self.

    So in Tile0 you make an image which might say "Unavailable" which you use for all characters that haven't been unlocked yet. As they get unlocked you simply switch a given tile to another tile. So if the player unlock character 1 you switch the tile (0,0) to tile1.

    If I understood you correct, you only need to store whether a character have been unlocked or not in a file, so you know this whenever the player starts your game. If you keep the family containing you characters you don't have to use an array to store there stats. These stats you make in the family and whenever a character is loaded you simply read these values from the family it self (The specific character sprite).

    So after you have started the game, and found out that character 1 and character 2 is available, you can make a function that get the stats for each character. If you also need it to be placed at a certain position, you can pass this as well, so:

    Requires:

    Parameter 0 = Character.UID

    Parameter 1 = Position

    Function "Load character stats"

    Sub event 1:

    Pick character1.UID = Function.Param(0) (Will only select character1 if the passed UID matches it, else it will just skip it)

    --------- If Function.Param(1) = 1 (Will place character 1 at position 1)

    Set textbox_CharacterName_1 = Character1.Name

    Set textbox_CharacterHealth_1 = Character1. Health

    Set Tile.At(0.0) to Tile1 (Assuming that this hold the image of character 1)

    --------- if Function.Param(1) = 2 (Will place character 1 at position 2)

    Set textbox_CharacterName_2 = Character1.Name

    Set textbox_CharacterHealth_2 = Character1. Health

    Set Tile.At(1.0) to Tile1 (Assuming that this hold the image of character 1)

    Sub event 2:

    Pick character2.UID = Function.Param(0) (Will only select character2 if the passed UID matches it, else it will just skip it)

    --------- If Function.Param(1) = 1 (Will place character 2 at position 1)

    Set textbox_CharacterName_1 = Character2.Name

    Set textbox_CharacterHealth_1 = Character2. Health

    Set Tile.At(0.0) to Tile2 (Assuming that this hold the image of character 2)

    --------- if Function.Param(1) = 2 (Will place character 2 at position 2)

    Set textbox_CharacterName_2 = Character2.Name

    Set textbox_CharacterHealth_2 = Character2. Health

    Set Tile.At(1.0) to Tile2 (Assuming that this hold the image of character 2)

    Then you just create one for each character and each position. And then you just call this function every time you need to load a character.

    Call function("Load character stats", <FamilyCharacter.UID or specific character UID>, <Position of where you would like the character to be loaded to>)

  • Im not really sure what you are trying to do.

    [quote:7uf79jho]The problem I am running into is that I can not link my array and family. Meaning that I cant run though the array and have each row correlate to a member of the family. I have tried having each row being the UID of each member but I can not find a way to automate that idea. And simply having Bob.UID in the first part of each row does not work.

    I don't understand what you mean that you want to link the array and family?

    The array hold whatever data you add to it, and can not be linked to anything, in theory any object in your game can use these data if you want them to, depending on your conditions for reading and making use of the content in the array. If what you mean is that you have stored some data to the array at some point and then when a character is available you want to use this to set some settings for the character, then you have to make sure that these characters UID matches the ones stored in the array, which it could sound like it doesn't.

    I get the impression that this is what you have been trying. But its very hard to troubleshoot when not sure how and what you store in the array.

    The family is also something that you cant link anything to, it more or less just a wrapper that can hold a group of other objects of different kinds but which share some common attributes, and therefore makes it easier to work on several different types of objects at the same time. So I don't understand what you mean with linking to it? If your characters are part of the family they are already "linked" to it through that and can be selected using:

    Pick Random FamilyCharacters

    Character1.UID = FamilyCharacters.UID (Assuming that the random Familycharacters chosen is a character1)

    Can you try to explain what you want to use the family for and when, and what the array hold of data that you need. And how and when you store the data, in correlation to when you need to read from it, think that would make it easier to help you?

  • Im not 100% sure but I don't think that the 8 bit pngs in PS works very well with opacity, and therefore if your sprites in 24 bit depth have smooth edges, they will render a white border around the image where the opacity occurs.

    To solve it you have some options:

    1. Make all sprites with hard edges, mean you paint them with pixel setting in PS. This is the time consuming way, as you will have to repaint all the sprites.

    2. You can use this website to convert 24 bit to 8 bit pngs and will preserve the opacity as well. You can only do it with one image at the time so if you have a lot it will ofc take some time as well. To save the 8bit image you just right click the image it self and choose "save image as.."

    http://www.8bitalpha.com/

  • Problem Description

    Not really sure if this is even a bug as much as an inconveniency. But if you create a sliderbar or any other system UI element such as buttons etc. And press "tab" until it is selected/highlighted. There are no way to deselect it again unless you press "Tab" once more.

    For the buttons you can use unfocus, but something like this doesn't exist for the sliderbar, and not sure there is a good way to deal with it for buttons anyway.

    The problem is that keyboard input doesn't work while one of these are selected.

    Maybe an option to remove these elements from working with "Tab" or something. Anyway not the biggest problem ever just inconvenient if you use them.

    Attach a Capx

    Not capx related

    Description of Capx

    Steps to Reproduce Bug

      Create any system UI element and tab during runtime until it is selected. Make something that react to a "key press" and it wont work, while the element is selected.

    Observed Result

    While selected keyboard input doesn't work.

    Expected Result

    Affected Browsers

      Tested with Node webkit

    Operating System and Service Pack

    Windows 7

    Construct 2 Version ID

    r180 but most likely all versions as these are system elements.

nimos100's avatar

nimos100

Member since 23 Sep, 2012

None one is following nimos100 yet!

Trophy Case

  • 12-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies