TextItemGetPosition: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This | This function allows retrieval of the position of a text item. | ||
==Syntax== | ==Syntax== | ||
Line 10: | Line 8: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''textitem:''' The textitem you wish to retrieve the position of | ||
===Returns=== | ===Returns=== | ||
Returns '' | Returns two floats of the ''x'' and ''y'' position on the screen, where the maximum value is 1.0. | ||
==Example== | ==Example== | ||
This example | This example creates a text item 'myTextItem' only if the text item 'otherTextItem' is not in the same position, to prevent overlap | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | myDisplay = textCreateDisplay () --created display | ||
textDisplayAddObserver ( myDisplay, myPlayer ) --made display visible to player | |||
-- | x,y = textItemGetPosition ( otherTextItem ) --get the position of 'otherTextItem' | ||
if ( x ~= 0.5 ) and ( y ~= 0.5 ) then --if the x and y of the text item are not in the middle | |||
myTextItem = textCreateTextItem ( "Hello world!", 0.5, 0.5 ) --create a new item for the display in the middle saying "Hello world" | |||
textDisplayAddText ( myDisplay, myTextItem ) --and add it to the text display | |||
else --otherwise | |||
textItemSetPosition ( otherTextItem, 0.5, 0.6 ) --move the otherTextItem down | |||
myTextItem = textCreateTextItem ( "Hello world!", 0.5, 0.5 ) --and create a new item for the display in the middle saying "Hello world" | |||
textDisplayAddText ( myDisplay, myTextItem ) --then and add it to the text display | |||
end | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{ | {{Text functions}} |
Revision as of 16:08, 16 August 2006
This function allows retrieval of the position of a text item.
Syntax
float float textItemGetPosition ( textitem textitem )
Required Arguments
- textitem: The textitem you wish to retrieve the position of
Returns
Returns two floats of the x and y position on the screen, where the maximum value is 1.0.
Example
This example creates a text item 'myTextItem' only if the text item 'otherTextItem' is not in the same position, to prevent overlap
myDisplay = textCreateDisplay () --created display textDisplayAddObserver ( myDisplay, myPlayer ) --made display visible to player x,y = textItemGetPosition ( otherTextItem ) --get the position of 'otherTextItem' if ( x ~= 0.5 ) and ( y ~= 0.5 ) then --if the x and y of the text item are not in the middle myTextItem = textCreateTextItem ( "Hello world!", 0.5, 0.5 ) --create a new item for the display in the middle saying "Hello world" textDisplayAddText ( myDisplay, myTextItem ) --and add it to the text display else --otherwise textItemSetPosition ( otherTextItem, 0.5, 0.6 ) --move the otherTextItem down myTextItem = textCreateTextItem ( "Hello world!", 0.5, 0.5 ) --and create a new item for the display in the middle saying "Hello world" textDisplayAddText ( myDisplay, myTextItem ) --then and add it to the text display end
See Also
- textCreateDisplay
- textCreateTextItem
- textDestroyDisplay
- textDestroyTextItem
- textDisplayAddObserver
- textDisplayAddText
- textDisplayGetObservers
- textDisplayIsObserver
- textDisplayRemoveObserver
- textDisplayRemoveText
- textItemGetColor
- textItemGetPosition
- textItemGetPriority
- textItemGetScale
- textItemGetText
- textItemSetColor
- textItemSetPosition
- textItemSetPriority
- textItemSetScale
- textItemSetText