PaulPlay's Forum Posts

  • I still experience a lot of crashes on my relatively recent iPhone. Also, can confirm that ads don‘t pause the game and it also doesn’t pause when opening the app switcher. This is really unfortunate, as the game gets a lot less fps on my old galaxy s8 with 4gigs of ram but there are no other issues.

  • With the current vibration implementation through the Browser object, there is no way to set the duration / length of vibrations on ios (the value will be ignored).

    I made this plugin which adds the cordova-plugin-taptic-engine by Eddy Verbruggen to the build service and comes with multiple actions that let the user add various types of vibration to their games. The actions represent the vibration types for the taptic engine introduced by Apple and explained here: developer.apple.com/design/human-interface-guidelines/patterns/playing-haptics

    I have filed a feature request for this before, but unfortunately the devs do not seem to have the time to implement it (which is totally understandable, but I think this is quite important). Therefore, I figured I would try to implement this by myself and surprisingly it worked. I used the C3IDE for making this plugin and it is really amazing. Big thanks to piranha305.

    Here is the link: construct.net/en/make-games/addons/923/taptic-engine-vibrations-c3

  • I want to make the iphone-x style homebutton transparent like in most mobile games and require 2 swipes (one for waking up the homebutton and one to actually perform the action). I've read online that in unity you can make this work by enabling a simple toggle ("defer system gestures on edges") however, in construct 3 there is no such option.

    I've stumbled upon this cordova plugin online but I have no idea how to implement that. Any help is appreciated.

  • Yeah so far it works well :) Yes, it is quite specific... because most buttons in my game use different animations etc. and I only want 1 event per button because otherwise the code becomes more cluttered and it's hard for me to get an overview. If you just have simple tap buttons that don't react to the touch / lift off of the finger then it is way simpler. (or if you are fine with long touches not registering)

    Overall I think it would be very cool if you could fine tune the parameters of the built in "on tap (object)" event.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for that solution. This sorta works but has a few issues compared to mine ;) First of all, if one finger is on a button, and the other one taps somewhere else, the animation gets reset. I combat this issue in my game by checking if the touch with a specific index ends (as explained at the end of my post).

    Second, we would now need a place to execute the actions of the button. Usually, that happens when you lift up your finger, so we would need a combination of "on any touch end" + "is in touch" and then check if the sprite is currently playing the "intouch" animation.

    Now, because your buttons all got the same animation (a sprite change) you can use a group for that. However, in my game buttons shrink (that's done with the tween behavior or an animation), so that is harder to track. It would work with an instance variable (a boolean) though.

    Another issue is that if you place your finger on the button, then move it away slightly and then back on the button, the action would not trigger because the button animation would have already reset.

    So your solution would work as well if we modified it a bit but it would need at least 2 events per button which is not ideal.

  • On tap does not trigger on long touches.

    The main issue is that the buttons in my game (and many other games) play an animation when they are initially being tapped and play a second animation once they are released.

    Now, you could just seperate these 2 things into different events - 1 for the action of the button (which triggers on tap object) and one for the button animation, which triggers on touched object and on any touch end (+ a second condition to check whether the button was pressed before). However, this eliminates long touches and the buttons feel very unresponsive. If you hold something for longer or move your finger just slightly, the tap does not register.

    The issue with the „On touch end“ event in combination with the „is touching object“ event is that the finger can start touching the screen somewhere else and move to the button and then release & activate it. This is very unnatural. Yes, you could store wether the button had been touched with a variable and then check on the second event with the „is touching object“ condition wether it was also initially touched, but that requires way more code than my solution. In addition to that, you would need another event to make this work, one for playing the initial animation once the object has been touched and one for playing the second / the „back“ animation once the touch has ended & the player was touching the button in the first place - otherwise it would play all button anomations at the same time. You can’t just put this revert animation under the „on touch end“ + „is touching object“ event because then the button would stay small in my case if you would touch the button and then move your finger away from it because then there is nothing that reverts it back.

    So yes, you could make this work, but it would require 3 events for every button and a lot of complicated logic on top of that.

  • You can also modify the function to always return 1 if a controller is being used, this way, you can have controller + touch input in the same button event with an or function and the code still gets executed.

    Also, I added an update for this solution (in the main post) because it had a flaw. If you touched a button and held, then tapped somewhere else, the button would revert to its initial state because the „On any touch end“ event would trigger (and wouldn’t do the action)

    This isn’t a huge deal but the new solution is far more elegant because it mitigates this issue :)

  • Hey everyone,

    making a great and responsive touch button that plays an animation when you first touch it and triggers the action once you release the button in construct 3 is not easy.

    See, when you use "on tap object" a touch of a button does not register if you hold the button for longer.

    If you want to make a button, that plays an animation (e.g becomes smaller) when you first touch it, and play another animation (e.g become big again) and then triggers and action once the touch has ended, there theoretically is a simple option:

    1) You play the first button animation when you touch the object "on object touched"

    2) You wait for a signal that you call something like "Wait for signal: TouchEnd"

    3) You use a seperate event "on any touch end" and trigger the signal "TouchEnd"

    4) The code that comes after the "Wait for Signal: TouchEnd" will be executed

    However, this approach is flawed. See, when you touch the button, then move your finger away from it and release, the action still happens. This means, once your finger is on the button (might be an accidental touch), there is no way to cancel the action.

    For a long time I used "On tap object" for all sensitive actions and this 2nd approach for everything else, but now I have found a great way to check if the finger was released / the touch ended on a certain object.

    Here is how it works:

    First, you add an event "on any touch end" that casts the signal "TouchEnd". Also, we add 2 global variables, TouchEndX and TouchEndY. We set these as seperate actions to Touch.X and Touch.Y respectively - If you have parallax or scrolling layers, you need to use Touch.XAt(TouchIndex,"NameOfUILayer") and the same for Touch.Y. This way, we store the last touch of the player.

    Second, we add a new function that takes the parameter "ObjectUID" -> this will be set to the Object.UID of the object that has the touch action later.

    The function also returns a number. 1 representing a valid touch, 0 meaning that the user has cancelled the touch.

    Now, you need to create a family that consists of all buttons in your game (in my game it is called "Buttons"), that are supposed to use this approach.

    The function, in its first event, now gets 2 conditions. One is called "Pick instance with UID ObjectUID" with ObjectUID being the variable we just assigned to the function. This ensures that only the object the player has clicked on is being used in this expression. The second condition is one of type "compare 2 values". We compare the first value:

    ---

    Compare:

    (Buttons.bboxright>TouchEndX)+(Buttons.bboxleft<TouchEndX)+(Buttons.BBoxBottom>TouchEndY)+(Buttons.BBoxTop<TouchEndY)

    to:

    4

    What I‘m doing too (as you can see in the last screenshot) is to add 35 to the dimensions of the button in this expression so that if the user is moving his finger only slightly away from the button, it still counts as a touch.

    ---

    So what this do? It checks, whether the last touch of the player was in the boundaries of the hitbox of the object / button that he has just touched. If one of these 4 conditions is true, it adds "1" to the expression, therefore the total should be 4.

    If this condition is true, the function should return "1". If the condition is false (add an "else" event here), it should return 0.

    Now let's have a look at the button:

    The parent event is a simple "On touched object" event.

    The (only) subevent consists of your 1st animation, then the "Wait for signal: TouchEnd" action, and after that, the actions that should be executed regardless if the touch ended on the object (so, the 2nd animation to revert the 1st one as well as a sound effect, maybe).

    Now, we add a subevent of this subevent, which checks wether the function we created returns 1. When calling it, we have to specify its parameter (ObjectUID) which is the button.UID (the button of the event). Only if this condition is true, we execute the code of the button. This way, the animation of the button works independently from the action action and as compared to the animation only triggers when the touch ends on the object.

    Note, that this basically eliminates multi - touch for all buttons that use this system. On any touch end, the signal will trigger and all buttons will return to their initial state (with the 2nd animation playing / reverting). However, only the one where the last touch has started (because we only have 2 variables) will cause a button to activate, assuming the touch has also ended on this exact button.

    If you want to improve this with Multitouch, we would need a more complex system, where an object stores the X and Y values of the last touch and the ID of the touch would be taken into account.

    - - - - -

    Update (improvement):

    If you want to make sure that the „on any touch end“ event will only store the position of the finger that touched the button in the first place (otherwise, if you press and hold a button and simultaneously tap somewhere else, it will trigger the event „on any touch end“ and the button will revert back to its initial state without executing the action) there is an easy way to add that to the existing code.

    1) Add a Global variable called „TouchIndex“

    2) Change the „on any touch end“ event to an „on nth touch end“ event and set the number of it to the variable (TouchIndex)

    3) Add a new event „on touched object“ with the object being the Buttons family. Add an action „set value“ to the event and set the value of „TouchIndex“ to touch.TouchIndex . If you have many overlapping buttons, you may want to add another condition, something like „Buttons opacity = 100“ or „Buttons is visible“. If you have many layers that you make visible or invisible, consider also making them inactive when they are transparent.

    -> this means, that only when the user ends a touch that initially started on a button, it will cast the signal „TouchEnd“ and store the position of where it ended.

    In my case, I also got a condition to check whether a controller is being used, but this is how it looks like now:

    Again, if you are using Parallax, you need to use TouchXAt() and TouchYAt() (and your UI layer in the brackets) instead of TouchX and TouchY.

  • I wanted to share this virtual joystick for mobile games that I've been working on with everyone who needs a good virtual joystick for their game. I have seen videos on virtual joysticks on youtube, however, they usually just use the drag and drop behaviour with the stick. The issue with this is, that you really have to tap on the stick and drag it, you can't just touch everywhere on the joystick and the stick will move to that location - so that's what I've done in my solution.

    You can download the example C3P to implement it in your own game!

  • All in all very cool! Unfortunately, it uses quite a lot of performance. Would be cool to see something like this integrated in the official physics plugin which would probably result in better performance (with java script)

  • Yeah, thats exactly what I mean by "with code". I have 2 HUGE event blocks with around 70 actions to set all the keys of a dictionary called "language". I only got 2 languages now, but will have more in the future and will switch to json. I was just wondering wether it has a performance impact to have this much more code, which is only running on start of the layout so I'd guess performance impact probably isn't huge.

    Anyway, the array thing seems good but I have already implemented the dictonary in my game on which I am working on since 2019 and it would be a pain to switch to that. So I will prob just load the Json into the existing dictonary and hope for the best.

    I have seen there is also a "download dictonary" action, which supposedly exports the dictonary as json, maybe this works so I don't have to copy it by hand...

  • The best way to do localization in construct is probably to use AJAX to request a JSON file for the correct language and then AJAX: "On tag completed" -> Dictonary load from Json string (Ajax.LastData).

    I want to switch to this solution because it is easier to have every language in a seperate file, BUT...

    ...I wonder what the real NEGATIVES of just creating a Dictonary in code are. If you have let's say 5 Dictonaries in code and they all contain 30 sentences in a language, does this increase loading times? Or is it bad for general performance? Because text uses only a few kb so I wonder why it isn't a common practise to just put the dictonaries in code and don't load them from json files. I'm curious to see your answers :)

  • Is it available yet? Haven't heard anything about it.

  • Thanks, imma try that if I get sufficient installs. Chadori truly is a Chad, his plugins seem pretty good.

  • Yeah but the IronSource Addon from this guy is 160$, only worth it if my game becomes a great success. If you earn „only“ a couple hundred bucks per month from advertising mediation does not really get you higher ecpm, because other networks often value customers with larger audiences. At least thats what I‘ve heard.