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.


Topics - out2lunch

Pages: 1
1
This is for Jon and the gang.

With the "half-width of Self" and "half-height of Self" blocks, Stencyl pastes in actor.getWidth()/2 and actor.getHeight()/2 into the code, but doesn't put parenthesis around them.  Most cases are ok except when used with another division where operator precedence gives the wrong answer.  Here's some examples:

(5 * 5) / 2 = 12.5   (Precedence will force this to happen, luckily equalling the intended one)
5 * (5 / 2) = 12.5   (Intended precedence)

(5 / 5) / 2 = 0.5   (Precedence groups them left to right, so this is the answer given instead of the intended one)
5 / (5 / 2) = 2.0   (Intended precedence)

5 + (5 / 2) = 7.5   (Precedence will force this to match the intended one)
5 + (5 / 2) = 7.5   (Intended precedence)

5 - (5 / 2) = 2.5   (Precedence will force this to match the intended one)
5 - (5 / 2) = 2.5   (Intended precedence)

Operator precedence: http://haxe.org/manual/operators

So, can Stencyl put parenthesis around them? ex: (actor.getWidth()/2)

2
Suggestion Archives / "join list using separator" block
« on: December 12, 2013, 01:56:45 pm »
To complement "split text using separator".  This would return a string.

Code: [Select]
join [list] using separator [separator]

public function ListJoin(__list:Array<Dynamic>, __separator:String):String
{
    return __list.join(__separator);
}

Pages: 1