"Sensor or Solid" behaviour doesn't work in Stencyl 3 anymore

koozek

  • Posts: 9
Hey, folks!  :)
I just upgraded to Stencyl 3 and now the "Sensor or Solid" behaviour doesn't work anymore :(
The error message, when I try running it, says
"Sensor Or Solid (52) -  Unexpected =
  Sensor Or Solid (52) -  Unexpected ="

This is the original code for the "MakeSensor" block:
for(var fixture:b2Fixture = __target.body.GetFixtureList(); (fixture != null); fixture = fixture.GetNext())
{
   fixture.SetSensor(true);
}

I hope somebody has an idea what needs to be changed in Stencyl 3 for this to work as I really, really need this funtion. Thank you very much in advance!

« Last Edit: March 03, 2014, 07:05:05 am by koozek »

Daernet

  • Posts: 4
Having the same problem, I believe it's related to:
'Does your project include ActionScript code?
If your project includes code, you'll have to port it from AS3 to Haxe. Likewise, if you used any Flixel-specific classes (references to FlxG for example), you'll need to figure out what to do on your own. If you don't know how to code, you'll either have to seek help on the forums or drop the behavior in question.'

More specifically I believe it's related to 'For Loops have a more concise syntax.'

But I'm not familiar enough with AS3 or HAXE to fix the issue.

I also believe the MakeSolid event is going to have the same problem.

I'll try and experiment with the 'For Loop' code to see if I can figure it out. If I manage before someone else beats me to it I'll try and provide the solution.

Edit:
I think I may have a solution!

MakeSolid Code:

Code: [Select]
var fixture = __target.body.getFixtureList();
while (fixture!=null)
{
    fixture.setSensor(false);
    fixture = fixture.getNext();
}

MakeSensor Code:
Code: [Select]
var fixture = __Target.body.getFixtureList();
while (fixture!=null)
{
    fixture.setSensor(true);
    fixture = fixture.getNext();
}

Getting some odd behaviour still, but that could be related to other things.

Second Edit, Getting some odd behaviours when transitioning, so still playing with it a bit.

« Last Edit: April 07, 2014, 05:04:05 am by Daernet »

Alexin

  • *
  • Posts: 3127
I think I made that behavior, so I'll try to port it to Stencyl 3.0 in the next few days. No promises.
"Find the fun"
alexin@stencyl.com

Daernet

  • Posts: 4
Got it fixed now, the issues were being caused by the way I was changing things from Sensor to Solid and vice versa.

I was controlling what was a sensor or solid based on the Layer of the actor, but the code block for that was changed as well, in Stencyl 2 it returned the Layer Z-Order of the Actor, in Stencyl 3 it returns the Layer ID of the Actor, which are frequently different.
Fixed that now and it all seems to be working with the code I posted above.

Just check the true and false are the right way around, I kept swapping them around while testing until I realised it was the layers causing my issues.

koozek

  • Posts: 9
Woah, thank you very much, guys! I'll try it out someday. I decided to finish my little game in Stencyl 2.2.0, though, as I had other annoying issues as well (with blend modes not acting like before, etc.) and it isn't worth changing so much when I can just use Stencyl 3.0 for my next game and start anew then.

Mihnutza

  • Posts: 7
I still get that error, even with the code modifications.

mdotedot

  • Posts: 1654
Hello,

Below code changes the sensor for all shapes of all animations. It only takes effect after you do a switch animation:

the 'setting' is a Bool
Code: [Select]
for(sm in actor.shapeMap.keys()){
                        // all shapes inside map
                        var shpmap=actor.shapeMap.get(sm);
                        for(k in 0 ... shpmap.length){
                                // fixture
                                trace("Fixture? : "+actor.shapeMap.get(sm)[k]+" = "+shpmap[k].isSensor);
                                shpmap[k].isSensor=setting;
                        }
                        actor.shapeMap.set(sm, shpmap);
                }


Hope it helps.

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.