Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - davient

Pages: 1
1
...
Workaround
The workaround is of course to _not_ modify your list attributes, but it's quite annoying.


I also ran into this bug. Though in my case, the problem was more pronounced, I find that whatever initial values I set the list to they are not respected.

My workaround is to manually initialize the values of the list in an on created block.

2
Archives / Re: Create Joint Block
« on: August 19, 2012, 05:11:12 am »
Thank you for the nudge in the right direction :)

Indeed it has everything to do with what "this" references. A simple "this.toString()" for within the creation and the collision code yields the difference. The creation code runs with "this" being an instance of "ActorEvents 0", which as is required, has an attribute scene, which allows the code to run fine.

However, where the collision code runs  "this" represents an "[object global]" which has no clear way I can find to access the scene property. So I've whipped up a simple workaround.
Simply set an attribute to the actor that has been collided. Then activate an event. In that custom event you can call the revolute joint code referencing "this" without any problems.

See attached for my example:

Note: I've had to switch the coordinates of Self and the Colliding Actor to get the joint to be in the correct place. This was not an expected need and may help others :)

3
Archives / Re: Create Joint Block
« on: August 19, 2012, 12:38:04 am »
Further investigation leads me to see that this only occurs when the code is called from a Collision event.

So in my attached example: enabling the revolute joint "when created" block, will successfully create a revolute joint with Blok2 at 50,50.

However, disabling this block and enabling either of the collision blocks results in the same error as error shown above (TypeError: Error #1010: A term is undefined and has no properties.
   at scripts::Design_6_6_JointBlocks$/CreateRevoluteJoint()[C:\Users\Dave Cooper\AppData\Roaming\Stencyl\stencylworks\preview\scripts\Design_6_6_JointBlocks.as:50])


4
Archives / Re: Create Joint Block
« on: August 18, 2012, 01:25:58 am »
I think I have fully customized the block. I assume you mean selecting the correct variables by dragging them across or otherwise.

Testing by removing these values, leads to clear null pointer exceptions.

The code for the custom joint block function (by captaincomic) is:

Code: [Select]
42 /* Params are:__actor1 __x1 __y1 __actor2 __x2 __y2 __this */
43 public static function CreateRevoluteJoint(__actor1:Actor, __x1:Number, __y1:Number, __actor2:Actor, __x2:Number, __y2:Number, __this:Object):void
44 {
45       __x1 = GameState.toPhysicalUnits(__x1);
46       __y1 = GameState.toPhysicalUnits(__y1);
47       __x2 = GameState.toPhysicalUnits(__x2);
48       __y2 = GameState.toPhysicalUnits(__y2);
49       b2Def.revoluteJoint.Initialize(__actor1.getBody(), __actor2.getBody(), new V2(__x1, __y1));
50       var joint:b2RevoluteJoint = __this.scene.world.CreateJoint(b2Def.revoluteJoint);
51       joint.m_localAnchor1.x = __x1;
52       joint.m_localAnchor1.y = __y1;
53       joint.m_localAnchor2.x = __x2;
54       joint.m_localAnchor2.y = __y2;
55       __this.lastCreatedJoint = joint;
56  }


5
Archives / Re: Create Joint Block
« on: August 17, 2012, 03:35:45 am »
*Alright, alright, I'm coming...* ;)

What kind of joints do you need?
I uploaded my custom blocks on StencylForge, the behavior is called Joint Blocks.
It contains blocks to create Revolute Joints and Mouse Joints, but I guess creating the other joints won't be much different. There's also a block to destroy them and to modify the parameters.

Here's an example on how to use them:

I'm trying to use your code to add a revolute joint when two Actors collide.  (really I want a fixed joint, but that should be simple to change once I get the basics done :)

From the log it looks like I'm using this on something that has not been initialized. Any pointers on debugging this?

Dave

Pages: 1