Game Development Community

Setting an object's behavior field value from a level script? HELP!

by Ed 'Mongadillo' Anderson · in Torque Developer Network · 09/24/2009 (6:35 pm) · 2 replies

First some background.

My scene has some simple wall objects around the edges of my game's playing area. They spawn balls that bounce around the scene, off each other and off the walls. When the balls are spawned, the walls shrink in length. I am trying to animate the wall's shrinking action. I am using the Scale behavior. I have set the behavior of each wall in the scene to the Scale behavior in the TGB editor. I modified the Scale script to initialize the x Width Min and Max to be the same, and the same for the y Width Min and Max.

What I want to do is set the y Width Min and Max when I spawn a new ball in my level script. I am trying to set the field values of the Behavior with the following code. The greenBar is a wall object and is a t2dStaticSprite.

%behavior = yellowBar.getBehavior();  
echo("%behavior = %x", %behavior);
%behavior.xWidthMin = 3.333; // all bar are vertical, top and bottom bars are rotated
%behavior.xWidthMax = 3.333;
%behavior.yWidthMax = (%this.yellowCount / 10.0) * %this.fullBarWidth;
%this.yellowCount--;
%behavior.yWidthMin = (%this.yellowCount / 10.0) * %this.fullBarWidth;

When I try to compile and run my game in the editor, it looks like it's choking on %behavior.xWidthMin = 3.333;

I have found one mention of getBehavior() in the forums, and no docs for it.

Again, my goal is to animate a wall shrinking with a duration of 1 second. Are behaviors the right solution? Is the modifying of behavior fields supported?

I'm still pretty new to t2d. And I'm using iTGB for iPhone.

I'll appreciate all enlightening feedback.
Thanks!

#1
09/30/2009 (2:04 pm)
Nobody? Really?
Come on folks, I need some feedback on this!
#2
09/30/2009 (2:45 pm)
You might get more joy by posting in the engine's appropriate forum.
T2D4iPhone
TGB/T2D