Difference between revisions of "love.data.newByteData"
m (0.11.0 -> 11.0) |
(Some clarity about memory initialization.) |
||
(One intermediate revision by one other user not shown) | |||
Line 22: | Line 22: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|Data| | + | {{param|Data|data|The existing Data object to copy.}} |
{{param|number|offset (0)|The offset of the subsection to copy, in bytes.}} | {{param|number|offset (0)|The offset of the subsection to copy, in bytes.}} | ||
{{param|number|size (data:getSize())|The size in bytes of the new Data object.}} | {{param|number|size (data:getSize())|The size in bytes of the new Data object.}} | ||
+ | |||
=== Returns === | === Returns === | ||
{{param|ByteData|bytedata|The new Data object.}} | {{param|ByteData|bytedata|The new Data object.}} | ||
== Function == | == Function == | ||
− | Creates a new empty ByteData with the specific size. | + | Creates a new empty (zero-initialized) ByteData with the specific size. |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> |
Latest revision as of 20:32, 27 October 2020
Available since LÖVE 11.0 |
This function is not supported in earlier versions. |
Creates a new Data object containing arbitrary bytes.
Data:getPointer along with LuaJIT's FFI can be used to manipulate the contents of the ByteData object after it has been created.
![]() |
This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused! |
Contents
Function
Creates a new ByteData by copying the contents of the specified string.
Synopsis
bytedata = love.data.newByteData( datastring )
Arguments
string datastring
- The byte string to copy.
Returns
ByteData bytedata
- The new Data object.
Function
Creates a new ByteData by copying from an existing Data object.
Synopsis
bytedata = love.data.newByteData( data, offset, size )
Arguments
Data data
- The existing Data object to copy.
number offset (0)
- The offset of the subsection to copy, in bytes.
number size (data:getSize())
- The size in bytes of the new Data object.
Returns
ByteData bytedata
- The new Data object.
Function
Creates a new empty (zero-initialized) ByteData with the specific size.
Synopsis
bytedata = love.data.newByteData( size )
Arguments
number size
- The size in bytes of the new Data object.
Returns
ByteData bytedata
- The new Data object.
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info