DiegoM's Forum Posts

  • Have you tried using bookmarks? It's not exactly the same, but it should work similarly. You setup the bookmarks in the places you are going to be going back and forth, and then you keep the bookmarks bar open on the side.

    If you have more than one monitor (or a very large one) you could even detach the bookmarks bar to a popup window so it isn't in the way.

  • Adding the notion of a template layer is massively complex, on the surface it seems straight forward, but I can already foresee it being an endless source of bugs.

    Mainly because it would need to "just work" with regular layers, global layers, sub layers, all their combinations and an indefinite level of nesting.

    I don't even want to think about the kind of setups that could be made, like a template global layer which is also a sub layer of another template, or something to that effect.

  • I looks like you should be using Tween "On finished" trigger, rather than Sprite "On finished".

  • I will try to fix this for the next stable version. It looks like it's a subtle problem with looping.

    It would be better if you make an issue in our bug tracker.

    github.com/Scirra/Construct-bugs

    That is the best way to make sure it's not forgotten!.

  • I looked at the implementation and it's slow because it's technically correct (checks if the incoming set of tags is a sub set of the corresponding instance tags), but does so in an inefficient way.

    I think it can be made to be about 50% faster, by handling the special case of a single tag and in other cases, improving the check against the existing tags set. That would be it for improvements though, I don't think it can be made to be much faster because the condition is inherently more complex than just comparing two values.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is not possible in a browser. If your server does not support web sockets at all you will need a proxy that does so it can stand in the middle and translate the messages.

  • You are running into an edge case.

    When the focus is on the TextInput, then the Keyboard object no longer handles keyboard input, instead Construct is allowing the browser to take control. Handling the interaction between the keyboard and a text input is surprisingly difficult (if you want it to work as users expect it should work that is), so instead of reinventing the wheel, we just let the browser do it's thing and for most cases it's the right thing to do, just let the user type normally.

    To do what you describe, you have to get a little bit clever though...

    The first thing I noticed is that after making the input visible, focusing it wasn't working for me, so I included a very short wait to make sure it worked.

    The unintuitive part is hiding the input, to do so I did a couple of things:

    1. Use a trigger that responds to changes in the input.
    2. Use a regular expression to check if the last character of the input is the one I am interested in. In this case the regular expression "'$" does just that. The $ is checking it is the end of the string. "gi" are regular expression flags indicating the match should be global (g) and case insensitive (i), I don't think any of those matter for this contrived example.
    3. Make sure to remove the "'" from the string in the action block, because I imagine you don't want it to be written in the text input.
  • Construct only understands numbers, strings and booleans. You need to quote the whole thing to pass it as a string.

    '[{"key":"username","value":"JohnDoe"},{"key":"email","value":"test@example.com"}]'

    In your plugin code you can then use JSON.parse(your_string) to transform the JSON string into a JSON object.

    About quotes... make sure the outermost quotes are different to the ones used in the JSON object. In this case I quoted the whole thing in single quotes, that way the computer can easily understand that everything in between the single quotes should be a string.

    If for some reason you wanted to use double quotes in the outermost layer, you would need to escape the double quotes in the JSON string so they are interpreted as the raw character instead of their special meaning and it would look something like this

    "[{\"key\":\"username\",\"value\":\"JohnDoe\"},{\"key\":\"email\",\"value\":\"test@example.com\"}]"
    

    In my opinion you should only do something like that if it's absolutely necessary.

  • You have two problems, the first one is the call to random.

    It looks like this

    	random(0.2-1.5)
    

    The problem with that is that it's generating a random number between 0 and -1.3.

    I think you were trying to do this instead

    	random(0.2, 1.5)
    

    To generate a random number between 0.2 and 1.5.

    The second problem is a little bit more subtle. When you flip (or mirror) a Sprite, Construct is inverting that size. Ej. A width of 50 when flipped becomes -50.

    If you then do any calculation assuming a width or height is positive, then it's not going to work.

    In your case the Compare Width check you are doing only works as long as the width is positive.

    To do the proper calculation, you need to make sure you are always performing that check with a positive value. Instead of using Compare Width which doesn't let you manipulate the width, you can use the System condition Pick by evaluate to have a little bit more control on what is going on.

    Use that condition, choose the object you want to pick and then use this as the expression to evaluate.

    abs(foodFish.Width) < fish.Width - 20
    

    That is pretty much the same you are already doing, but it takes care of converting foodFish.Width to an absolute value before comparing it to fish.Width.

    With that condition it doesn't matter which size the foodFish has, it will always work.

  • You forgot the video :)

    Anyway, to get help It's better to share your project if you can, so people can take a look at what you are trying to do.

  • WackyToaster Yeah if you do that, the reference to the tween will be kept around because technically it is never finished.

    Right now I would keep track myself of what is going on and then do different things when the tween says it is finished.

    Use a variable to keep track of when you stopped the tween. When the finished promise is resolved, check if you stopped it and do what you need to do and if you didn't stop it you can let it do something else.

    async attack()
    {
    	if(this.attacking)
    		return;
    	
    	this.attacking = tween;
    	tween.finished.then(
    		
    		if (this.attacking)
    		{
    			// do something when finished with no interruption
    		}
    		else
    		{
    			// do something when cancelled
    		}
    	)
    }
    
    cancelAttack()
    {
    	this.attacking.stop();
    	this.attacking = null;
    }
    
  • I see, I am looking at it right now and there is a difference when a tween is stopped from an event and when it is stopped from the scripting API. Probably the scripting API needs to change to do the same as the events.

  • When you stop a tween it is completed. To do what you where thinking about you should use pause and then use resume to restart from the place it was left in.

  • The next releases will not be showing layers with a -1 index. Even though it is more accurate at showing what is happening, it runs into the possibility of showing the same layer multiple times in different places of the tree when combined with global layers, something which the Layers Bar was never meant to do and is actively design against.

    So we will be rolling back on that.

  • I thought about looking into this, and it looks like loading a website from a zip file into an iframe is way more complex than I thought XD

    I mean, it's possible but it's a bit ridiculous. The main issue is that since the files are not served from anywhere, you need to create in memory URLs to all of them and then update all the places that use URLs in your index.html with your in memory ones, so the iframe can find them.

    It seems like it might work for simple use cases, but a C3 export is not a simple use case and I wouldn't be surprised if the approach runs into problems.