Scene setting ID problem?

riotmedic

  • Posts: 17
Maybe it's just me, but when I create a local Scene attribute and then try to set it with an (if > then) tree (I'm using a global variable to keep track of the last scene/level the player died on), the setter for the local scene variable experiences errors.

Code: [Select]
public var _retry:Actor;
public var _lastSceneIWasOn:Scene;
override public function init():void
{

    if (sameAs((getGameAttribute("lastLevelIWasOn") as String), "level1"))
    {
        _lastSceneIWasOn = 0;
    }

    else
        if (sameAs((getGameAttribute("lastLevelIWasOn") as String), "level2"))
        {
            _lastSceneIWasOn = 4;
        }

        else
            if (sameAs((getGameAttribute("lastLevelIWasOn") as String), "level3"))
            {
                _lastSceneIWasOn = 2;
            }
}

This is generate after using the Design section of StencylWorks. Should it not be setting an ID, instead of setting the scene to an INT? I figure so, because of the error message I get:

Code: [Select]
Behavior: Design_5_5_retryclick at line 40
Implicit coercion of a value of type int to an unrelated type stencyl.api.engine.scene:Scene.
            _lastSceneIWasOn = 0;



Behavior: Design_5_5_retryclick at line 45
Implicit coercion of a value of type int to an unrelated type stencyl.api.engine.scene:Scene.
            _lastSceneIWasOn = 4;



Behavior: Design_5_5_retryclick at line 50
Implicit coercion of a value of type int to an unrelated type stencyl.api.engine.scene:Scene.
            _lastSceneIWasOn = 2;

This is probably fixable using Code Mode, but I'm wondering if this is a bug or if I'm managing to mess it up in Design somehow. I'm using v 1.0.2 b402.

Aside from this, this is a great tool, thanks for making it!! Having a lot of fun playing with it.

Epic428

  • Posts: 1118
A better way to do what you are trying to accomplish, is by using this block:



This will reload the current scene, which is much easier than determining the scene and trying to reload.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Alexin

  • *
  • Posts: 3127
Are the variables "first scene", "level2" and "title" of the type Scene?
"Find the fun"
alexin@stencyl.com

riotmedic

  • Posts: 17
Thanks Epic, I'll look into using that one.

And Alexin, yes. lastSceneIWasOn is a Scene type attribute.

riotmedic

  • Posts: 17
I think this might be a bug in translation from design to code, actually.

Code: [Select]


public var _targetScene:Scene;

public function setToEnd():void
{
    _targetScene = 6;
}

is how a set scene attribute box translates to code, but what it should be doing is setting _targetScene as an actual scene object/variable. I'm not sure how to fix it without redoing it in code mode.

The original reason I got into this was because I was building a door/transition from scene to scene, with the target scene being an attribute of type Scene that I wanted to define dynamically during the runtime of the current scene. I wanted the door to appear after a boss actor is killed.

I initially wanted to handle this without recycling but I couldn't just do a) hide and set group to Doodads to avoid collisions, because I have no idea how to set groups in a dynamic way. I can avoid collisions and keep the actors in the scene if I b) recycle the door during initialization of the scene, but the original value of the targetScene attribute is nulled after creating the recycled door again.

Is there another way to set Scene type attributes during run-time? Alternatively, is there a way to hide objects and remove any and all collisions with Player group and then un-hide and turn those collisions back on after an event (death of a boss actor, in this case) takes place?

Thanks. I have this tingling feeling I'm just overthinking the logic behind all this.

P.S.: Is there a deeper purpose of the Doodads collision group other than having a non-collision group? I couldn't find an explanation anywhere on the 'pedia or forums, and I was wondering what the reason behind its existence was.

« Last Edit: July 07, 2011, 10:47:44 pm by riotmedic »