AllanR's Forum Posts

  • Stenky

    dop2000's solution sounds like it would work fine... but I was curious how I would tackle that - and what the performance hit would be.

    so, I made a sample. The irregular shape of the provinces does make it tricky. but if you edit the collision masks to cover as much as possible (without adding too many points) it does seem to work well. Neither my computer or iPad broke a sweat... (debugger said it was using about 5% on both)

    I like to keep things as simple as possible and avoid plugins unless you really need the functionality.

    anyway, you can try my version here:

    https://www.rieperts.com/games/forum/france.capx

    it works with mouse or touch... but I only did 10 provinces. Obviously, there are some dead areas near the edge of a province if the collision mask doesn't cover that spot. In the code, I make sure to Pick the Top instance, just to make sure you can only select one province if the masks do overlap.

  • it might be a timing issue... how and when are you setting setting the dictionary key?

    Try adding a "Wait 0" action before the action that replaces the color. That might give it the time it needs to finish initialising the dictionary. (Just a guess)

  • You do not have permission to view this post

  • the problem seems to be that Construct doesn't like to change the visibility of non-existent layers. Your loops go up to 20, but you only have 4 layers. if you change the loops to "0 to 3" then it works the way you expect.

    I couldn't find a way to detect how many layers there are at runtime. You could create a global variable "LayerCount" if you are planning on adding or removing layers - just remember to update the global variable...

  • SnipG that is excellent advise... I had noticed strange IDs in some cases and worked around that, but I definitely like the idea of using the index instead. I will update my example so that people who download it in the future will not be misled.

  • dop2000

    just tried your version, and it seems to works well. Like I said back in my first post, it is up to the game creator to define how the interface works... and what makes sense for the game.

    My method was based on multi-touch requirements that needed different fingers to do specific things. Your shorter version does the job, but has potential drawbacks - if you start moving the beacon with one finger, then start moving the ship with another finger - if that second finger slides off the control it take over controlling the beacon. And if the finger that was controlling the beacon slides over a control it starts moving the ship. That is all fine, if that is what you want...

    Anyway, the OP now has two excellent examples of how to do multi-touch! :)

  • dop2000 my first version had that problem, so I moved part of the initialisation code into the "Is In Touch" block (by using the "NewTouch" flag). and that works properly on my computer, iPad and iPhone...

    (the "is overlapping" section didn't work in the "On any Touch Start". That looks like a bug in C2 to me, but is probably because the TouchPoint sprite isn't fully created until the next top level event).

    pretty sure I uploaded the right version... what are you testing on? and does the TouchPoint sprite have a NewTouch boolean instance variable?

  • AmpedRobot

    I hear your frustration... making a bulletproof multi-touch interface is definitely a very advanced function in C2 - and that is not C2's fault. It gives you the tools to do it. It is up to you to define what the touches mean to the game.

    Rather than use an array, I like to create a sprite object for each active touch. Then you use those to track where the touch is, what it is touching, what it can do, how to handle over-lapping controls, etc...

    I re-created your project using the bare minimum elements from yours, and my standard multi-touch method. I put in as many comments as I could, so I hope it makes sense. I had to add a couple instance variables to the beacon so only one touch could try to control it at a time...

    any touch that does not start on a control, or is not controlling the beacon is tracked, but ignored. So this version will work with any number of touches.

    you can download my version here: http://www.rieperts.com/games/forum/touch_test.capx

    Update 1: oh, yeah - normally I would have the TouchPoint sprite invisible, but I left it visible so you can see them for testing purposes...

    Update 2: Another thing - I put the controls in a Family, so you can do one test to see if a new touch is meant to update controls, or to try to move the beacon. Any other controls added should also be added to the family...

    alright, last update: I copied the code to move the ship and beacon from your file, but normally I would have the controls on a non-movable HUD layer (Parallax 0,0), and make the layer the ships are on scroll around (rather than moving all the objects individually). To do that I would create a camera object (with Scroll To) on the game layer and move that as necessary... You probably know that - I realize you were just testing touch.

  • Yes, it should work fine - it gets the date from the device as far as I know.

  • savvito123 a better way would be to just return the day of month by doing:

    Browser.ExecJS("var d=new Date(); d.getDate()")

    that will return a number between 1 and 31.

  • cybertron7 Just tried my example on my daughters phone - a new LG android phone, and there was no lag. My iPhone still lags, but it is a very old 5s...

    then I decided to try it on my wife's ancient Galaxy S4, surprisingly, I could not see any lag there either! So, R0J0hound's fix works well for Desktops and Androids... just need to test on a newer iPhone.

  • R0J0hound That is SO AWESOME!! wow, that has bugged me for ages! Your example completely eliminates the lag on desktop. It does still lag on my iphone and ipad.

    THANK YOU R0J0hound!!

    I made a couple of tweaks... clamp the textboxexs to the viewport so they scroll on and off the screen a little better, and position the textboxes within C2 before setting the CSS position (this also eliminates the lag when the textboxes are "pinned" to an element that has drag and drop). So, in my example you can scroll the window, or drag the page around - WITH NO LAG (on desktop).

    cybertron7 If you want to do this on mobile, you are pretty much out of luck. About the best you can do is make a "fake" input box under the real one and use CSS to make the real textbox transparent with no borders. Then the box does not appear to lag - but the text inside it still does (but I think this looks significantly better).

    The ONLY other option is to completely make your own input system... I tried to do that last year and ALMOST got it working... you have to make your own cursor, method to select and delete text. But you can't access the system clipboard, you have to make your own keyboard, so no spell checking, no word suggestions, etc...

    you can get my updated version of R0J0hounds example here: www.rieperts.com/games/forum/scroll_w_textbox_fix3.capx

  • resdesign

    there are a couple ways you could do it.

    If the help screen doesn't have a button that needs the pointer to change to the hand, then put the event that changes the cursor to the hand inside the group that you disable - so you effectively disable the buttons and disable changing the cursor at the same time. When you re-enable the group, you will enable the cursor to change again too.

    If you want to disable some buttons, but still have others work (and have the cursor change), then you could add a boolean instance variable to the family called "ButtonEnabled". Set the variable to False for all the buttons you want to disable, and leave it True for the rest.

    On the event that changes the cursor (when the mouse is over a member of the button family) add another condition that says "ButtonFamily is ButtonEnabled"

    If you have lots of buttons in different groups, you could add another family instance variable called ButtonGroup. Then you could have a "Navigation" group, "Help" group, "Settings" group, "controls" group, etc... Then it would be easy to select and disable/enable an entire group as needed.

  • chrislechat

    Yes, use AJAX to send data to a PHP script on your server. The PHP script can read from and write to a mysql database.

    There are tutorials to help you get started.

  • 99Instances2Go

    like newt said, "objects created are picked, until the next higher tier event"

    In your first example the destroy line is outside the scope of the event that creates the sprite (and the new sprite does not officially exist until the next top level event - as I think you know). But in your second example, the action is still within the scope because it is part of a sub event under the one that created the sprite. The new sprite will stay Picked until all sub events are finished, or something else changes the picking. like a condition that does not apply to the new sprite, or if you have a sub event that does a system --> pick All Sprite2, (then all other existing instances will be picked except the new one - because it does not officially exist yet).

    another useful thing to know is that you can pass the UID of the new sprite into a function. The function can pick the object by its UID and do whatever you want to it even though the next top level event has not happened yet.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads