Juryiel's Recent Forum Activity

  • I have a bunch of sprites, and I'm trying to pick two objects based on the value of one of their variables. The value of the variable, let's call it ID, is different for each sprite. I want to make a condition that will pick two of the sprites, such that if their ID=Value1 OR ID=Value2 they're picked but no other values are picked. It seems like OR does something close to this (e.g. Pick by comparison1 OR Pick by comparison2) however, it doesn't seem to clear previously picked objects the first time.

    What I mean is this:

    I have 2 objects, Object1 and Object2 with two private variables, Var1 and Var2.

    I have 10 Sprites with the private variable ID.

    I have the following code:

    On mouse over Object --->  Call Function Function1 and Remember
    
    On Function 1
         Pick Sprite by Comparison, Sprite.Value('ID')=Object.Value(Var1)
         OR
         Pick Sprite by Comparison, Sprite.Value('ID')=Object.Value(Var2)
                     For Each Sprite --->  DebugText set Text Sprite.Value('ID')[/code:10btf93t]
    
    When I put the mouse over Object1, this works fine and I get the ID of both of the sprites that match
    
    Then, If I put the mouse over Object2, the first time, on top of getting the ID of the two correct sprites, I also get the ID of the sprites that match Object1's variables.  The second time I put the mouse over Object2 I get only the correct two sprites.  This also works in reverse (e.g. if i start with Object2 and then mouseover Object1). 
    
    What's going on?  I can post the cap but literally the only code involved in the function is exactly what I posted above.
  • I THINK this link should work:

    http://sharesend.com/download/au3ii

    If not try http://sharesend.com/au3ii but this one has a 5 second countdown thing.

    Check events 25 and 26. The way it's set up now it works, but what I had set up before was that event 25 had no actions, and event 26 had the expression Function.CheckSameMove(Param1,Param2), where Param1 and Param2 are the two params in 25. Doing it the other way would cause CheckSameMove to only loop through the already selected Unit (I think, in any case it didn't seem to work correctly)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I was reading the wiki and it said if you call a function from an expression, it forgets picked objects. However, this doesn't seem to be the case. I have a function that picks objects , which calls another function via expression, and in that case, the objects picked by the first function remain picked when calling the second function via expression, and the value returned by the second function corresponds to the single object picked by the first function. If I instead call the second function using an action and specify Forget, and then use Function.Return to obtain the value in an expression, the value corresponding to going through ALL objects is returned.

    Is this known? Any way around it? It seems a bit clunky to do an Add Param, call a function as an action, and then use Function.Return as opposed to the better looking Function.MyFunction(Param)

  • Ah, apparently the size of the sprite on the layout and the size of the sprite in the editor were not the same, which I guess might have been causing the issues as well.

  • Well right, it seems to be changed due to loading, not just size difference (e.g. loading same-size frames as the sprite still moves it). Set current animation pivot sets the hotspot then? Great, thanks!

  • Alright I was able to fix this by making individual sprites. I have another issue now though. When I use Load animation frame from file with teh sprites to load a frame during run time, it move the sprite position. The movement varies by the image size of the image I try to load (or so it seems). Even when I load a frame that is the same size as the sprite object (32 x 32 .png files), the sprite still moves to a different (but predictable) location. I could convert all frames to the same size and then move them all by the same amount, no problem, but I was wondering if there was some way to prevent this from happening in the first place. Thanks!

  • Since they have ot be animated, 100 sprites by 5 or so frames each, I wonder if that might be an issue. Probably not since they're fairly small, but I think if there's no object with independent animation frames per instance, and if there's no way to create a new object (as opposed to an instance) at run-time then I might as well sit there and make copy-paste 100 sprites.

  • Ah yes I see, I figured it was something like this. Is there some object that supports animation? I can't tell if the tiled background object does. If not, I could presumably pre-create all the sprites as separate entities, there's only about 100 of them.

  • Alright, I'll post a cap as soon as I get home. I suppose there could be something I'm missing but all I'm literally doing is:

    Container with textbox, sprite, an da couple of other things.

    For 1 to N, 
        Create Object Textbox
        Set position Textbox to SomeExpression + LoopIndex
        Set Text Textbox to SomeOtherExpression + LoopIndex
        Set position Sprite to YetAnotherExpression + LoopIndex
        Load animation frame from file Sprite to YetAnotherExpression2 + LoopIndex[/code:3kg1stf0]
    
    All of the lines seem to work fine except load animation frame from file, which does work except all the sprites end up being set to the last animation frame, instead of each sprite to its own.  I've tried, for example, looping through only some number N-x instead of looping to N, and the N-x file loads on all the sprites if I do that.
  • So I have a container with a few objects. I create a few sets of these using a loop and Create object to create one of the objects, which creates them all. So far so good. One of the objects is a sprite. I set the position of the sprite immediately after creation in the loop, which works correctly, and each sprite is set to the correct position. However, when I set the frame of the sprite, every loop iteration seems to overwrite the frames for ALL the sprites. I'm not doing any object picking checks since I set position and frame as I create each sprite. It works for position( and size, and other properties etc) but apparently not for loading frames. When I load a frame in one sprite it works, but if then do load frame in another sprite, it replaces the frame of BOTH of the sprites.

  • Ah thanks i'll try it. Could not find it on the wiki.

  • Is there a way to retrieve the number of parameters passed to a function? I use a function to which I pass a variable number of parameters and I'd like to know how many I passed so I can loop through all of them.

    I understand that I can do this by simply using a global variable to keep track, but I was wondering if there was an expression that stores this value. Thanks.

Juryiel's avatar

Juryiel

Member since 30 Sep, 2010

None one is following Juryiel yet!

Trophy Case

  • 14-Year Club
  • Email Verified

Progress

15/44
How to earn trophies