Yes, the sample was not perfect ...
I copy directly from my source code as in my dev. I don't pass the global as argument.
In the main source code :
Here is exactly what I have (simplified) in my project :
// Project: test46
// Created: 2019-04-26
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "test46" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
// ******************************************
Type PKTiles_Type
xxx As Integer
EndType
Global PKTile As PKTiles_Type[] // Gestion dynamique des tiles.
PKCreateTile( 1, 1 )
PKPasteTile( 1, 0, 0 )
Function PKCreateTile( ImageID As Integer, TransparencyMODE As Integer )
newTile As PKTiles_Type
TileID As Integer = -1
newTile.xxx = 0
PKTile.insert( newTile )
TileID = PKTile.length
EndFunction TileID
Function PKPasteTile( TileID As Integer, XPos As Integer, YPos As Integer )
if TileID > 0 and TileID < ( PKTile.length + 1 )
// Draw The tile
Else
Message( "2DPluginKIT Ver 2.0 Error : PKPastetile #" + Str( TileID ) + " - Incorrect TileID ( range 1-" + Str( PKTile.length ) + " )" )
Endif
EndFunction
When I use PKPasteTile, I get the message, and you can see that PKTile.length = 0 and TileID = 1 (tile created successfully and inserted successfully)