Is there a way to access SpriteSheet.SpriteData directly from ZExpression? New addition to RenderSprite is nice but it has its limits (no batching support yet) so I would like to script my own drawing function instead.

Moderator: Moderators
Not at the moment unfortunately .. and shorts aren't supported yet either ( which is what the SpriteSheet data is stored in ).Kgm wrote:Is there a way to access SpriteSheet.SpriteData directly from ZExpression?
When you want to render tons of sprites ( that use the same spritesheet ) batching is definitely a good idea yes. I'd recommend using a external spritesheet editor and pasting / storing the data in a persistent array for now. Alternatively you could copy the binary blob ( CDATA ) from a SpriteSheet component to a ( byte ) Array component and convert it to integers. Attached is a quick example / converter.Kgm wrote:New addition to RenderSprite is nice but it has its limits (no batching support yet) so I would like to script my own drawing function instead.
Nice trick! I honestly didn't think of it that way, thanks!Kjell wrote: Alternatively you could copy the binary blob ( CDATA ) from a SpriteSheet component to a ( byte ) Array component and convert it to integers. Attached is a quick example / converter.
K
Agreed.Rado1 wrote:There should also be the possibility to import sprite data and/or edit in the form of 2D persistent numeric Array
This was / is planned, and basically worked ... but not when used as custom editor for some reason ( reading the pixel data fails ). I'll look into it again.Rado1 wrote:Another possibility to improve usage of the SpriteSheet editor would be to implement automatic sprite boundary detection
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<Content>
<Array Name="Input" Type="1" Dimensions="1" SizeDim1="4" SizeDim2="6" Persistent="255">
<Values>
<![CDATA[78DA636080000128E68062011CE20A38C40D7088030032E00121]]>
</Values>
</Array>
<Array Name="Output" Type="4" Dimensions="1" SizeDim1="4" SizeDim2="12" Persistent="255">
<Values>
<![CDATA[78DA636060601000420E201440622B20B10D90D80019700121]]>
</Values>
</Array>
<ZExpression Comment="Convert">
<Expression>
<![CDATA[//
Output.SizeDim1 = Input.SizeDim1;
//
int i, w;
for(int s=0; s<Input.SizeDim1; s++)
{
i = 0;
for(int d=0; d<6; d++)
{
w = Input[s,d];
Output[s,i++] = w & 0xFF;
Output[s,i++] = w >> 8;
}
}]]>
</Expression>
</ZExpression>
<Bitmap Name="MyBitmap" Filter="1"/>
<SpriteSheet Name="MySpriteSheet" Bitmap="MyBitmap">
<SpriteData>
<![CDATA[78DA636060601000420E201440622B20B10D90D80019700121]]>
</SpriteData>
</SpriteSheet>
</Content>
</ZApplication>
Yes please. This will be very useful feature.Kjell wrote:This was / is planned, and basically worked ... but not when used as custom editor for some reason ( reading the pixel data fails ). I'll look into it again.
Yes, that's far from ideal state.Kjell wrote:+ There is a way to import the data already, but it's far-from-ideal / quite-cumbersome. Nevertheless, for the time being ...