How do I stop this GlitcH ??

tapdroid

  • Posts: 115
On create actor,
 Some times Stencyl will create the actor,
 Some times Stencyl will create Multiple actors.

What would cause the multiple ???
 

Meestar

  • Posts: 652
Post the code where your actor is being created and we'll be happy to look through it and direct you to a solution!
PM me if you require help.  I'm always glad to help out!

tapdroid

  • Posts: 115
package scripts;
import com.stencyl.graphics.G;
import com.stencyl.behavior.Script;
import com.stencyl.behavior.ActorScript;
import com.stencyl.behavior.SceneScript;
import com.stencyl.behavior.TimedTask;
import com.stencyl.models.Actor;
import com.stencyl.models.GameModel;
import com.stencyl.models.actor.Animation;
import com.stencyl.models.actor.ActorType;
import com.stencyl.models.actor.Collision;
import com.stencyl.models.actor.Group;
import com.stencyl.models.Scene;
import com.stencyl.models.Sound;
import com.stencyl.models.Region;
import com.stencyl.models.Font;
import com.stencyl.Engine;
import com.stencyl.Input;
import com.stencyl.Key;
import com.stencyl.utils.Utils;
import nme.ui.Mouse;
import nme.display.Graphics;
import nme.display.BlendMode;
import nme.display.BitmapData;
import nme.display.Bitmap;
import nme.events.Event;
import nme.events.KeyboardEvent;
import nme.events.TouchEvent;
import nme.net.URLLoader;
import box2D.dynamics.joints.B2Joint;
import motion.Actuate;
import motion.easing.Back;
import motion.easing.Cubic;
import motion.easing.Elastic;
import motion.easing.Expo;
import motion.easing.Linear;
import motion.easing.Quad;
import motion.easing.Quart;
import motion.easing.Quint;
import motion.easing.Sine;
import com.stencyl.graphics.shaders.BasicShader;
import com.stencyl.graphics.shaders.GrayscaleShader;
import com.stencyl.graphics.shaders.SepiaShader;
import com.stencyl.graphics.shaders.InvertShader;
import com.stencyl.graphics.shaders.GrainShader;
import com.stencyl.graphics.shaders.ExternalShader;
import com.stencyl.graphics.shaders.InlineShader;
import com.stencyl.graphics.shaders.BlurShader;
import com.stencyl.graphics.shaders.ScanlineShader;
import com.stencyl.graphics.shaders.CSBShader;
import com.stencyl.graphics.shaders.HueShader;
import com.stencyl.graphics.shaders.TintShader;
import com.stencyl.graphics.shaders.BloomShader;
class SceneEvents_0 extends SceneScript
{
    public var _SCORE:Actor;
    public function new(dummy:Int, engine:Engine)
    {
        super(engine);
        nameMap.set("SCORE", "_SCORE");
    }
    override public function init()
    {
        /* ======================== When Creating ========================= */
        playSoundOnChannel(getSound(67), Std.int(1));
        /* ======================== When Creating ========================= */
        setGameAttribute("scorecounter", 0);
        /* ======================== When Creating ========================= */
        hideMobileAd();
        /* ============================ Click ============================= */
        addMouseReleasedListener(function(list:Array<Dynamic>):Void
        {

            if (wrapper.enabled)
            {
                getActor(15).disableBehavior("Follow Drag and Drop");
            }
        });
        /* ======================== Actor of Type ========================= */
        addActorEntersRegionListener(getRegion(2), function(a:Actor, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && sameAsAny(getActorType(4),a.getType(),a.getGroup()))
            {
                getRegion(1).setLocation(0, 0);
                getRegion(3).setLocation(0, 0);
            }
        });
        /* ========================= When Drawing ========================= */
        addWhenDrawingListener(null, function(g:G, x:Float, y:Float, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled)
            {
                g.setFont(getFont(39));
                g.drawString("" + getGameAttribute("scorecounter"), 450, 9);
                g.drawString("" + "SCORE", 270, 9);
            }
        });
        /* ======================== Actor of Type ========================= */
        addCollisionListener(getActor(15), function(event:Collision, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && sameAsAny(getActorType(6), event.otherActor.getType(),event.otherActor.getGroup()))
            {
                setGameAttribute("scorecounter", (getGameAttribute("scorecounter") + 1));
            }
        });
        /* ======================== Actor of Type ========================= */
        addActorEntersRegionListener(getRegion(3), function(a:Actor, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && sameAsAny(getActorType(4),a.getType(),a.getGroup()))
            {
                getRegion(1).setLocation(797, 15);
            }
        });
        /* ============================ Click ============================= */
        addMouseReleasedListener(function(list:Array<Dynamic>):Void
        {

            if (wrapper.enabled)
            {
                recycleActor(getActor(12));
            }
        });
        /* ======================== Actor of Type ========================= */
        addActorEntersRegionListener(getRegion(1), function(a:Actor, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && sameAsAny(getActorType(4),a.getType(),a.getGroup()))
            {
                getActor(15).moveTo(300, 200, 3, Linear.easeNone);
                createRecycledActor(getActorType(26), 540, 260, Script.FRONT);
            }
        });
        /* ======================= After N seconds ======================== */
        runLater(1000 * 20, function(timeTask:TimedTask):Void
        {

            if (wrapper.enabled)
            {
                showMobileAd();
            }
        }, null);
        /* ======================== Actor of Type ========================= */
        addCollisionListener(getActor(15), function(event:Collision, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && sameAsAny(getActorType(10), event.otherActor.getType(),event.otherActor.getGroup()))
            {
                runLater(1000 * 5, function(timeTask:TimedTask):Void
                {
                    createRecycledActor(getActorType(34), getActor(2).getXCenter(), 222, Script.FRONT);
                    getActor(15).setY(-333);
                    getCamera().setLocation(getActor(2).getXCenter(), getActor(2).getYCenter());
                }, null);
            }
        });
        /* ======================== Actor of Type ========================= */
        addCollisionListener(getActor(15), function(event:Collision, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && sameAsAny(getActorType(10), event.otherActor.getType(),event.otherActor.getGroup()))
            {
                runLater(1000 * .8, function(timeTask:TimedTask):Void
                {
                    recycleActor(getActor(10));
                }, null);
                runLater(1000 * 5.9, function(timeTask:TimedTask):Void
                {
                    createRecycledActor(getActorType(40), 450, 44, Script.FRONT);
                    showMobileAd();
                }, null);
                runLater(1000 * 8, function(timeTask:TimedTask):Void
                {
                    createRecycledActor(getActorType(59), 488, 166, Script.FRONT);
                    createRecycledActor(getActorType(61), 419, 200, Script.FRONT);
                    createRecycledActor(getActorType(63), 200, 188, Script.FRONT);
                    createRecycledActor(getActorType(26), 838, 230, Script.FRONT);
                }, null);
            }
        });
        /* ======================== Actor of Type ========================= */
        addWhenTypeGroupKilledListener(getActorType(6), function(eventActor:Actor, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled)
            {
                playSound(getSound(71));
            }
        });
        /* =========================== On Actor =========================== */
        addMouseOverActorListener(getActor(15), function(mouseState:Int, list:Array<Dynamic>):Void
        {

            if (wrapper.enabled && 5 == mouseState)
            {
                runLater(1000 * 6, function(timeTask:TimedTask):Void
                {
                    showMobileAd();
                }, null);

                if (getActor(10).isAlive())
                {
                    runLater(1000 * 8, function(timeTask:TimedTask):Void
                    {
                        createRecycledActor(getActorType(26), getActor(15).getXCenter(), 222, Script.FRONT);
                        stopAllSounds();
                        runLater(1000 * .5, function(timeTask:TimedTask):Void {
                            playSoundOnChannel(getSound(66), Std.int(4));}, null);
                    }, null);
                }
            }
        });
    }
    override public function forwardMessage(msg:String)
{}}

letmethink

  • *
  • Posts: 2542
Please post the block coding as that is much easier to debug based on logic.
~Letmethink

yoplalala

  • *
  • Posts: 1467
You can use http://snag.gy/ to copy and paste image easily :)


tapdroid

  • Posts: 115
FYI
Its   floatingJimmy   that sometimes appears in multiples.

Rimrook

  • *
  • Posts: 251
I gather that Milk is a pickup of some kind?

What might be happening is that the actor somehow collides with Milk and runs its script a few times before something happens to stop it. Is it safe to think that the Milk actor is killed when it touched? If that's the case use something like this by grabbing the [actor of type] block from the yellow 'when' block.

When [Jimmy 15] hits a [Milk] --- [1st actor][actor of type]
Kill [actor of type]

then run the rest of the script. I don't know what exactly happens but I hope this helps to provide a solution for you.

Alternatively, you can use a Boolean attribute to disable things if timing is an issue.

tapdroid

  • Posts: 115
ah ha, I see, However, milk flickers and fades prior to death, leaving time for .....

Disable multiple collision ?   Gonna try.
          Scratch that, continuous collision is off. how can we avoid multiple collision while flickering before death?

letmethink

  • *
  • Posts: 2542
You can have two animations for milk and once it is collided make it switch to the identical one but the identical one won't have any collisions
~Letmethink

dripple

  • Posts: 747
It's a general question for collisions happening, not only for Stencyl.

Use a boolean "isCollided" and set it to <false>. Once the collision has happened, you set isCollided to <true> first and right after, in the collision detection, you check against this boolean [if isCollided=true] and place the code inside the [if]. This makes sure that the collsion code is executed only once, even if the collision is still happening.

Find a save place after all to set isCollied to <false> again.
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper

tapdroid

  • Posts: 115

tapdroid

  • Posts: 115
I though the turning off continuous collide took care of that.

tapdroid

  • Posts: 115
Sorry dripple, I don't understand how to put that together.

dripple

  • Posts: 747
My fault, I mixed two statements.

Create a boolean attribute, call it "isJimmyColliding", set it to false

Next look into the first [when [Jimmy 15] hits [Milk]...]
1. wrap the whole content into a [IF <isJimmyColliding> == <false>]
2. before the other statements, set <isJimmyColliding> to <true>
... and create the new Floating Jimmy.

The boolean attribute makes sure that the following code happens only once, and not continously while the collision is happening - this results in spawing new Floating Jimmiy's :-)

I am not sure where the game continuous, but I think the second collision that also kills the milk that Jimmy previously hit, is a save place to set <isJimmyColliding> to <false> to "arm" that collision again.


Hope this helps?
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper