Wrap alignment issue

0 favourites
  • 5 posts
  • Hi All,

    New to C2 and new to the forum.

    Not sure if this is better in the bugs section or the how to section.

    I'm just trying to get my head around a few differences from Gamesalad and this is an issue I've run into.

    In GS the wrap behavior will wrap an object as soon as part of it is off the screen. In C2 the object does not wrap until it is completely off the screen.

    In trying to replicate the GS wrap bahavior I've run into an issue with alignment.

    In the attched demo there is coloured screen width rectangles beside each other, moving at the same speed, so as one begins to leave the screen the other should enter.

    This works ok at low speeds and when little is on screen however gets very sporadic at varied speeds (use left/right arrows to test) or if more events are happening.

    I'm running windows 7, IE9, Chrome and C2 beta r99. The problem seems a little worse in IE9 but is still obvious in Chrome. Pixel rounding is switched on (however I've tried both ways)

    I've also tried turning off the wrapping and 'teleporting' the sprite with variations on the following:

        If Sprite X > LayoutWidth+(Sprite.Width/2) then Set X to 0 - (Sprite Width/2)

    Which seems to work a little better however still has the same issue.

    So my questions are as follows:

    Is this a know issue/bug?

    Is there a workaround?

    Am I missing something obvious or is it just my system?

    How does the wrap behavior work? (what position triggers the wrap? Is the object wrapped to just on or just off screen? Does velocity effect this behavior?)

    Is the a way in C2 to create a looping wrap with a single sprite with perfect alignment? (no overlap as textures won't align)

    Wrap alignment issue demo capx

    Video in case my issue doesn't replicate

    Thanks for any solutions/help/advice

    Cheers

    Chris

  • Perhaps the warp behavior does something similar to what you tried with events.

    Do it with these two events instead:

    X > LayoutWidth+self.Width/2

    set X to self.X-LayoutWidth-self.Width

    X < -self.Width/2

    set X to self.X+LayoutWidth+self.Width

  • Thanks You,

    I make a few changes to the your formulas however that pointed me in the right direction.

    The alignment using this method is very stable in comparison to the wrap bahavior. Of course this method is limited to one axis in its current form, but that suits my current needs.

    X > LayoutWidth+(self.Width/2)

    set X to self.X-(LayoutWidth+self.Width)

    X < (LayoutWidth-LayoutWidth)-(Self.Width/2)

    set X to self.X+(LayoutWidth+self.Width)

    Wrap alignment issue fixed

    Thanks for your help :)

  • Glad it was useful. You can reduce you event count to 2 by putting all the objects you want to wrap into a family.

    I'm curious about the changes to the formulas, namely this:

    LayoutWidth-LayoutWidth

    Couldn't you just use 0 since it will evaluate to 0 no matter the value of LayoutWidth.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just trying to avoid any references to actual values, but yes, that was unnecessary.

    I haven't experimented with families yet, thanks for the tip!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)