AllanR's Forum Posts

  • You could have an instance variable for each colour, have them start at 0, and when you collide with a colour, set that variable to 1 (or if it is already 1, set it back to 0).

    Then if the sum of the variables is 5 you know you have all the colours.

    The trickier part is showing what colours you have, because there are a lot of possible combinations of the colours! (31 I believe). So, either you would need to have that many animations, or you would have to have one additional sprite for each colour, pinned to the player sprite, and show or hide them based on whether you have collected that colour or not.

  • I haven't looked into it too much, but I don't remember seeing anything other than the percentage loaded, so I think you may be out of luck...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That would probably work for fine for testing, but once you start distributing your game it would need to access a publicly accessible server. And you would only really need a server like that if you want to have access to the players data, have players share data, or for a global high score list, etc. If you are only storing data for the local player you may want a solution that doesn't require a server. I know there is a CSV plugin, and ways to read and write text files... And I have heard people say they store a lot of data in webstorage.

  • I have used Construct2 with MySQL - using AJAX to make calls to php scripts that read or write to the database. Works great and not very hard to do. There are several tutorials to help you get started. However, you need access to a server obviously...

  • vtrix, I believe Colludium is correct.

    I dragged the group out of the On Start of Layout section and got the incorrect spacing as you described.

    So, I disabled the line "Sprite : Destroy", and then the sprites were spaced correctly.

    Then I changed the Create object line to just create the Sprite on layer 0 at (0,0)

    and on the next line Sprite : Set position to ( 300+ loopindex("y") * (sprite.Width+1), 300 + loopindex("x") * (sprite.Height+10) )

    and that worked fine (even with the "Sprite : Destory" line re-activated). So, basically, it needs to already have a Sprite instance available to get its width and height. You just have to divide the line to create the Sprite first, then position it second rather than do it all on one line...

  • You certainly have the right idea. Although, you could simplify it...

    if you use "Set at X" instead of "Set at XY" you could leave out the extra ",0" at the end of every line that sets or accesses the array.

    You could also easily eliminate the global variables by just putting the random() statement down at the bottom where you set the citizen instance variables. Make sure you put the Floor() outside of the Random() call: you want "Set FirstName to FirstName.At(Floor(Random(FirstName.Width)))"

    Also the last section where you assign the names to citizens will run every tick - constantly reassigning names unless you put that in an "On start of layout" block or in a function...

    One other thing to be aware of, FirstName.Width will be the number of spaces defined in your array, not how many you have used. Your code shows you have set up 3 names, but if your array has room for 10 names, then your code would try to assign names that don't exist sometimes.

  • Use "Set Layout Scale"

    if you set it to 0.5 then you will twice as much, after a few seconds set layout scale back to 1.0

  • smallbear, I just tried your before capx and cropping worked fine for me...

  • That would be really nice, but no, that is currently impossible.

  • Nitro187, without seeing the real code it is hard to tell for sure, but it looks like the line " Player: Player = loopindex +1 //Gets the proper instance" is assigning a value to the Player instance variable, rather than "Picking" the correct instance... which would certainly give bazaar results because it would just be a random instance of Player, rarely the one you want.

    You want to use the System "Pick by evaluating Player" where the expression is "Player.Player=loopindex+1"

  • I use php a lot, and it could easily do what you want (it is not just for mySql), although it does require a web server - so I guess that is not the way for you to go.

    Keep reading through the manual - I am sure there is a fairly easy way to do it!

  • RenatoB, the reason you were seeing the correct number when you clicked on it was because you were displaying the number in the text field before you called the CheckAnswer. At that point you did have the correct instance, but then in the function it has no idea what has happened outside of the function so it just used any random instance.

    The comparing a string variable to an integer would have also been a problem... anyway, glad you got it working!   :)

  • v2k, you can also do it using AJAX and php.

    I made an app that is accessed through a website where you have to login (using .htaccess) and then pass the username into the Contstruct 2 app using AJAX to call a php script that just echos the username.

  • RenatoB, I had trouble like that a while ago. I believe there was a known bug where touch events weren't firing in some versions of IE. It sounded like Ashley thought he had fixed it, but I know I had the issue after that (but I may have still been using an older version of C2). I haven't tested in old versions of IE recently, but if you are up-to-date and still having the problem you may want to submit a bug report...

  • RenatoB, there are a few things in your code that seem a little funny to me, but I tested some of them out and they seem to work (but just aren't quite the way I would have done it).

    I believe the main problem is that the CheckAnswer function is not working with the same "numbers" instance as the one you touch. When you touch one, it is the only instance "picked", but when you call the CheckAnswer function it will randomly pick any instance to work with. So, You should pass in the numbers.UID into the CheckAnswer function, and then in there "pick" that unique ID.

    One other potential problem is in your "On Start of layout" section, where you "Pick a random numbers instance". You repeat that loop 20 times, but theoretically it could pick the same numbers instance all 20 times. Out of 20 times through the loop, you will have no way of knowing how many instances got picked more than once, and how many never got picked. If you have 20 instances of numbers, and want to set each one to a random animation frame, then replace the "Repeat count times" and "Pick a random instance" with "For each numbers". (the part where you choose a random index and delete it out of the array seems fine as far as I can tell).