DiegoM's Recent Forum Activity

  • 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.

  • Have you checked "auto keyframes" are turned on? It's the "A" icon in the toolbar.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This should work in theory, but it will clash with a basic restriction of the Files folder, no duplicate file names.

    Importing the files of the first export will be fine, after that if you try to import a new file that has the same name as an existing one, the old file will be updated.

    Even if a new unique name was assigned to each file so everything was imported as expected, the name changes would probably break the exports.

    A possible solution I am thinking about would be compressing each export in it's own zip file, then importing each zip file with a unique name. Doing that you should be able to keep each export intact because C3 doesn't actually get to see the compressed files.

    Then you would need some scripting to decompress a zip at runtime and show the contents in the iframe. Assuming you also import zip.js to handle decompressing the zip files at runtime, it shouldn't be too difficult... depending of course on how comfortable you feel about scripting. What I just described will be pretty difficult if you are not comfortable scripting.

  • Global layers wouldn't work for this because in the editor they are effectively the same as the source, making any changes to them is actually changing the source, which propagates the change to all other global layers with the same name. That would be the same for the sub layers, assuming you could edit them directly, I decided not to allow that because of a potential plethora of problems. If you open the layout where the source global layer exists you can edit the sub layers and the changes are propagated to all other relevant layouts.

    What you are describing is different though, we would need some kind of new system to define a template of layers, which when used in a layout, all the layers in the template would be created, essentially acting as a shortcut to creating all those layers manually. Then editing the template would somehow update all the "real" corresponding layers in each layout, that would include adding, removing, renaming and sorting layers.

    Sounds like a massive feature :)

    Edit: Maybe not massive, but larger than it seems for sure.

  • It's to avoid unexpected problems.

    The layers bar was originally made to work with the layers of the current layout. Showing layers from other layouts and also being able to edit them normally will most certainly run into all kinds of subtle problems. Showing them and not allowing to edit them is a middle ground, so you can at least see if there are layers from another layout being shown in the current one.

    Global layer items have a context menu option to open the layout of the original global layer, so if you want to edit those layers, you can quickly find the layout they belong to.

    As for deleting the layers with a -1 index, I think that should be ok as in most cases once you make a layer global, you don't care too much about what it was showing previously.

  • The editor now shows you the sub layers of the original global layer. Those sub layers are grayed out because they don't belong to the current layout, so allowing them to be interacted with would likely have a lot of unexpected behaviors.

    The editor now also shows you any sub layers a layer might have, but are not being shown because the parent is a global layer and instead it is showing the global sub layers of the parent. Those are shown with the crossed out eye icon to indicate they are not visible. They are also given the -1 index to reflect how they would react at runtime if their index was to be queried using the LayerIndex expression.

    All of that was added because of this github.com/Scirra/Construct-bugs/issues/8532

    The main problem in that report was the editor was showing different layer indexes to the runtime when working with global sub layers.

    I guess this can be confusing if the layers that take the -1 index also have the same name as the original global layer's sub layers.

DiegoM's avatar

DiegoM

Member since 24 Apr, 2015

Twitter
DiegoM has 1,774,968 followers

Trophy Case

  • 11-Year Club
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • RTFM Read the fabulous manual
  • x2
    Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

20/44
How to earn trophies

Blogs