2
$\begingroup$

In the BGE is there a way, using just logic bricks and not Python, to format an integer text object so that it stays right justified within a field.

Let's make this a simple two digit number between 0 and 99. When the number changes from 9 to 10, I want the 1 to shift one digit to the left and the 0 to remain in the units position. There are two ways I found to do this, neither very elegant.

One way is to use ( with a single ALWAYS SENSOR ) a two frame animation defining the two positions ( a tens position and a units position ) with two EXPRESSION CONTROLLERS, one for the integer less than 10 and the other for the integer ten or greater. Each controller is attached to an ACTION ACTUATOR that selects the appropriate position frame. The other way I found was to use constraints in a logic brick setup similar to the position animation just described.

Is there a more elegant way or some feature I'm missing in the logic bricks?

$\endgroup$
  • $\begingroup$ without python, not really. The method you've suggested would certainly work. (elegant isn't always important) $\endgroup$ – X-27 Aug 15 '16 at 12:45
  • $\begingroup$ Replace the always with a Property sensor in mode: "Changed". $\endgroup$ – Monster Aug 16 '16 at 4:58
  • $\begingroup$ Thank you both. X-27, chuckle, I agree. In programming I have often abandoned the quest for elegance in the name of utility. Monster, thank you for showing another way ( elegant or not ) for accomplishing what I wanted to do. $\endgroup$ – Dragonbyte Aug 16 '16 at 20:03
2
$\begingroup$

Not really elegant: enter image description here

I guess this is pretty similar to your solution.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.