Very strange issue with objects that moving when they should not move.

94 views
Skip to first unread message

Extreme Alex

unread,
Apr 7, 2016, 6:08:44 PM4/7/16
to haxef...@googlegroups.com
Hi guys,

Have the following very-very strange issue, which is similar to the deep engine problem. I'll try to describe it in detail.
In the game there are many objects (playing cards) based on FlxSpriteGroup.
Deck of cards, the cards on the level and the broken cards - are based on FlxTypedSpriteGroup<Cards>.
With the cards there are many actions: adding to the group, deleting from the group, clicks defining by the MouseEventManager, the movements from place to place with the help of FlxTweens, FlxSorting of FlxTypedSpriteGroups etc.
And at some point, - I can not definitely indicate when it comes - some cards which at this point must not move, are broken up and fly off the screen.
Some researches of an issue revealed that at this moment this "crazy" card have changing their velocity (and sometimes it concerns also their acceleration) - and the velocity become equal to the object's screen coordinates at the time of the "madness starting". So the object's velocity.x becomes equal the object's x (for example, 781) and the card is instantly flying off the screen.

I can not figure out how and when this happens, moreover that nowhere in the code I do not operate on these parameters (velocity and acceleration) and FlxTweens also leaves them intact.
What could it be, and how to fight it?

Thanks!

Extreme Alex

unread,
Apr 7, 2016, 7:20:20 PM4/7/16
to haxef...@googlegroups.com
Seems that such code sometimes can cause issue:

        if (card1.overlaps(card2)){...


It is possible that after such tweening sometimes velocity can be changed.

Extreme Alex

unread,
Apr 28, 2016, 1:35:52 AM4/28/16
to HaxeFlixel
Update: Seems that this issue caused by FlxTween manager.

Could it be that when you call FlxTween.tween(...), this new Tween pulled out from the (killed) tweens pool and have some parameters, that have not zeroed after the previous run?

Gama11

unread,
Apr 28, 2016, 3:47:23 AM4/28/16
to HaxeFlixel
Tweens are not pooled.

Extreme Alex

unread,
Apr 29, 2016, 9:11:32 AM4/29/16
to HaxeFlixel
So it seems that the bug is placed somewhere else. It appeared in the dev build roughly from February. I tried to compile another older game that has a totally different architecture and structure of the objects interaction, and used an older version of the engine and had no such issue - but caught it with a current dev build of the engine.
Now I fix this by zeroing velocity and acceleration in each update() of each object (want to remind that my code does not change these parameters and absoluely does not use them anywhere), but this decision is monstrous.

четверг, 28 апреля 2016 г., 10:47:23 UTC+3 пользователь Gama11 написал:

Gama11

unread,
Apr 29, 2016, 9:28:20 AM4/29/16
to HaxeFlixel
Does this issue only occur on dev (i.e., does it work with 4.0.1)? Is there any way I can reproduce this?

Extreme Alex

unread,
May 3, 2016, 11:04:59 AM5/3/16
to haxef...@googlegroups.com
I only use the Dev version, unfortunately, I can not say about the situation with the Master.
Below is a piece of code that generates the error (rarely, but guaranteed). I can make a video, if necessary.

    ////////////////////////////////////////////////////////////////////////////////////////////////////
   
public function AddBigMessage(_x:Float, _y:Float, _txt:String = "", _ico:String = null)
   
{
       
var duration:Float = 1.25;
       
var path:Float = (145 + _txt.length * 2) * duration;
       
var scale:Float = 1.25;
       
       
var ico:FlxBitmapTextButton = cast (recycle(FlxBitmapTextButton), FlxBitmapTextButton); //recycle(PxButton);

       
Reg.PlaySound("Message");
       
       
ResetCloudObj(ico);
       
        ico
.label = new FlxBitmapText(MessageFont);
        ico
.label.scale.set(3.0, 3.0);
        ico
.label.text = _txt;
        ico
.label.useTextColor = false;
        ico
.label.antialiasing = true;
        ico
.x = _x;
        ico
.y = _y;
       
        ico
.makeGraphic(2, 2, 0x00000000);
        ico
.label.offset.set(ico.label.width / 2, 20);
       
       
FlxTween.tween(ico, { alpha: 1.0 }, duration, { type: FlxTween.ONESHOT } ).then( // in fact, this code does not touch the alpha of the label, so the label is always non-transparent
       
FlxTween.tween(ico, { alpha: 0.0, y: _y - path }, duration * 1.1, { type: FlxTween.ONESHOT, onComplete: cast function() { ico.kill(); ico.label.destroy(); } } ) );
       
FlxTween.tween(ico.label.scale, { x: scale, y: scale }, duration * 1.5, { type: FlxTween.ONESHOT, ease: FlxEase.elasticOut } );
   
}
   
////////////////////////////////////////////////////////////////////////////////////////////////////
   
private function ResetCloudObj(_ico:FlxBitmapTextButton)
   
{
        _ico
.alpha = 1.0;
        _ico
.scale.set(0.1, 0.1);
        _ico
.centerOffsets();
       
        _ico
.acceleration.set(0, 0);
        _ico
.velocity.set(0, 0);

        _ico
.label = null;
   
}




This function displays a message with the effects (scale, then move up with the disappearance by alpha -> 0).

Layer.AddBigMessage(Reg._X + 512, Reg._Y + 384, message);

Sometimes, very rarely, the message is trying to fly down and right (because the velocity at this time becomes equal to the coordinates), but moving Tween trying to return it to the starting position, taking into account shifts in Tween.
This function can be called many times in a row, and screen may have a lot of messages without any issues - so the number of messages does not affect the issue rate.

Extreme Alex

unread,
May 7, 2016, 11:48:41 AM5/7/16
to HaxeFlixel
Upd. Master version 4.0.1 have the same issue.
Reply all
Reply to author
Forward
0 new messages