mekonbekon's Recent Forum Activity

  • The reason this isn't working is because the conditions that pick the Family object don't also pick the specific Factory object, so your "Factory isDestroyed" condition picks all of the Factory objects.

    There are a few ways to get around this; the simplest is to shift your "isDestroyed" variable to the Family and then change all the conditions and actions referencing the Factory object to the Objects family.

    Another way would be to move all the Factory conditions and actions to a function; then, in the ObjectType = "Factory" subevent, pass the picked Object's UID to the function in a parameter and use that passed UID in the function to pick the Factory.

  • kncuser

    I think I have a fix, updated in the link above. In the demo, try shifting the 9-patch around and then run it - it should now always scale relative to the centre of the object rather than the centre of the viewport.

    Here's how I approached it:

    On start I save the 9-patch's coordinates to instance variables.

    When the 9-patch is tweening I compensate for the x,y change by repositioning the 9-patch by the z-elevation percentage of the object's distance from the centre of the viewport:

    + 9patch: Is Tween "zUp" playing

    -> 9patch: Set position to (Self.startX-(Self.startX-ViewportWidth(0)÷2)×(Self.ZElevation÷100), Self.startY-(Self.startY-ViewportHeight(0)÷2)×(Self.ZElevation÷100))

    I'm not sure whether this will hold up if the layer is parallaxed or scaled, but should be fine with the default settings.

  • There's a snag doing it this way: z-elevation scales from the centre of the viewport rather than the origin of the object so this method doesn't always work. I'm going to test if you can compensate by adjusting the object's x/y but my hunch is that it'll be a bit of a faff.

  • kncuser

    I literally ran into this issue myself just now - turns out I'd been doing all my z-tweening on objects at the centre of the screen, which works fine. I then tried it on an off-centre object and was stumped as to why it was tweening weird. I figured it out and came to post here, but you'd beaten me too it! :-)

    I'm guessing you could simultaneously tween the x,y back to the initial position? I'll give it a go and report back.

  • nicely done! that works very well - I haven't done much with Z-elevation.

    Cheers :-) I've only recently started exploring it myself, lots of potential when combined with the new pin features.

  • Tweening the z-elevation works well for scaling text and spritefont:

    dropbox.com/s/9lgyx16nidbuiwg/scalingWithZ.c3p

  • You can wrap the offset without having to use additional conditions by using the modulo (%) expression in the action:

    -> TiledBackground: Set image X offset to ((Self.ImageWidth+Self.ImageOffsetX+backgroundSpeed*dt)%Self.ImageWidth

    This will automatically reposition the offset once it exceeds the image width.

    It's worth using a variable for the background speed rather than a fixed variable as it allows you to easily manipulate the background movement during play.

    A negative backgroundSpeed value will reverse the direction of movement.

    Switch width to height and X to Y for vertical movement.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The issue is that all three events will trigger on the mouse click in sequence because each event is setting the conditions for the next one; event 2 sets the frame to 1 so event 3 is true, and so on.

    Here's one way to deal with this:

    On left button clicked on sprite: Set animation frame to min(self.animationFrame+1, self.animationFrameCount-1)

    This will step up the frame number each time you click up to the maximum frame number (animationFrameCount-1).

    Here's another:

    On left button clicked on sprite:

    =>Sprite animation frame = 0: set animation frame to 1

    =>Else Sprite animation frame = 1: set animation frame to 2

    =>Else: set animation frame to 3

    In this example you use a sequence of "Else" sub-events to allow you to step the frame number.

  • Both spritefont and text objects scale fine using z-tweening:

    dropbox.com/s/9lgyx16nidbuiwg/scalingWithZ.c3p

  • It's hard to say what's happening without seeing your event sheet or debug output - are you using two separate array objects, one for each array file?

    In C3 you can load multiple arrays from files in sequence as follows:

    On start (or function, or whatever):

    AJAX: Request array1.json tag "array1"

    System: Wait for previous actions to complete

    Array1: Load from JSON string AJAX.LastData

    AJAX: Request array2.json tag "array2"

    System: Wait for previous actions to complete

    Array2: Load from JSON string AJAX.LastData

  • I also had this issue with 9-patch the other day. The problem with scaling a 9-patch by changing the height and width is that the corners & edges will keep to the preset margin values. Instead I dealt with it this way:

    1. Pin the image to the 9-patch

    2. Set the image pin behaviour to include pin Z-elevation

    3. Add the tween behaviour to the 9-patch

    4. On touch/release tween the z-elevation value of the 9-patch

    The additional benefit of using this method is that you can use the tween ease settings to easily create some nice scaling effects.

  • In event 1 the choose expressions for the sound and tag won't necessarily pick the same name.

    Instead, set a global or local variable e.g.:

    On start:

    set pick to choose("eraser","pencil","ruler","scissors")

    Play pick (tag pick)

    This will ensure your sound and tag match.

mekonbekon's avatar

mekonbekon

Early Adopter

Member since 9 May, 2014

Twitter
mekonbekon has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies