zaterdag 5 maart 2016

Stencyl / Apple : Create a distribution IPA file

Previously we generated AdHoc IPA files using the Apple Developers Member Center pages.


Now we continue to make Distribution/Production pairs.

Go to the development site of Apple (developer.apple.com) Login to the member center.



Go to the Provisioning Profiles and use the + icon to create one:



Select App Store









Download







Double click the downloaded file so that XCode is launched and it loads the mobile provisioning.

THIS IS IMPORTANT !!!! You need to have XCode read it and store it!!


Next put the mobileprovisioning in Stencyl:


And select the production / distribution P12 you exported earlier.



Publish to IOS and select App Store instead of Ad Hoc.







Both processes produce an IPA file.
The easiest check is to use iTunes to install them on your device. The Ad-Hoc one will install when your Device ID is in the list of device IDs.
The distribution (App Store) publication will not run.



Next:

How to publish the IPA to Apple?

zaterdag 6 februari 2016

Stencyl : Reading properties from a text file into a Map



The file posted on the website has this text:

MapEntry1=Value1
Property2=Value2

Disclaimer: This will fail when there is a = sign in the map-key!


Haxe / Stencyl : Drawing shapes onto image

Haxe / Stencyl

Drawing stuff like lines, shapes, circles, rectangle on an image:

var shape = new nme.display.Shape();
var g = shape.graphics;
g.beginFill( 0xffffff );
g.lineStyle(1,0x000000);

g.drawRect(8,8,280,280);
g.moveTo(32,32);
g.lineTo(128,128);
g.endFill();
var bmp = new BitmapData(64,64,true, 0x00000000 );
bmp.draw(shape);
var b=new Bitmap(bmp);

attachImageToHUD(new BitmapWrapper(b), 0,0);

or:

bd = new BitmapData(Std.int(shapeWidth), Std.int(shapeHeight), true, 0);
var s = new Shape();
s.graphics.lineStyle(2, 204);
s.graphics.drawCircle(50, 50, 20);
bd.draw(s);
attachImageToHUD(new BitmapWrapper(new Bitmap(bd)), 0, 0);

donderdag 4 februari 2016

Stencyl / Extensions : avoid recompilation of whole project

When you have an Haxe Extension and you use some kind of java you needed to clean the Stencyl project when you changed some Java Code.

This little trick will not re-compile the complete project:

rm -rf ../games-generated/YourGame/Export/android/bin/deps/YourExtension


vrijdag 22 januari 2016

Haxe / Stencyl : Playing OGG file from filesystem

How can we play an OGG file directly of the filesystem.

Example: File /Users/admin/a.ogg

//setGameAttribute("SelectedFile", "/Users/admin/a.ogg");

var bas=sys.io.File.getBytes(getGameAttribute("SelectedFile"));
var ba:openfl.utils.ByteArray=openfl.utils.ByteArray.fromBytes(bas);
var abcd=new flash.media.Sound();
abcd.loadCompressedDataFromByteArray(ba,ba.length);
abcd.play();

donderdag 21 januari 2016

Haxe/Stencyl : Rotate Image

Stencyl lhas a block to spin the image instance, but then it is an instance instead of an image that we can upload.

This block code (Advanced -> Flow ) or Extension function can do the trick.

This is the code in an extension:




 public static function RotateImage(bitmapData:BitmapData):BitmapData{
                var degree=90;
                var newBitmap:BitmapData = new BitmapData( bitmapData.height, bitmapData.width, true );
                var matrix:Matrix = new Matrix();
                matrix.rotate( degree*(Math.PI/180) );
                if ( degree == 90 ) {
                        matrix.translate( bitmapData.height, 0 );
                } else if ( degree == -90 || degree == 270 ) {
                        matrix.translate( 0, bitmapData.width );
                } else if ( degree == 180 ) {
                        newBitmap = new BitmapData( bitmapData.width, bitmapData.height, true );
                        matrix.translate( bitmapData.width, bitmapData.height );
                }
                newBitmap.draw( bitmapData, matrix, null, null, null, true );
                return newBitmap;

        }

dinsdag 19 januari 2016

Haxe / Stencyl : Exporting an image to PNG and optionally upload to online server



PHP Server code:

/*
 *
 * Server Side script:
*
<?php
$name = $_GET["name"];
foreach($_POST as $i){
    // If image is found 
    if(strlen($i) > 10) $img=$i;
}
file_put_contents("uploadDirectory/".$name, $img);
file_put_contents("uploadDirectory/debug.log", $debug , FILE_APPEND | LOCK_EX);

?>
*/


Stencyl Code Block (HaXe)  that uses an Image Attribute which will be stored on the server. In this code the Attribute is called Image



var _URL="http://_YourServer_/YourDirectory/AboveScript.php";


var UploadFile=“MyFile.png”;

// Call the encode function of the BitmapData which is the Image
var png = _Image.encode (_Image.rect, new openfl.display.PNGEncoderOptions());

// Get the bytes from the PNG file
var b = haxe.io.Bytes.alloc(png.length);
png.position = 0; 
var bytes:haxe.io.Bytes = haxe.io.Bytes.alloc(png.length);
while (png.bytesAvailable > 0) {
   var position = png.position;  
   bytes.set(position, png.readByte());
}

// You could save it to the local file system on Native (Windows/Mac) 

// In this case we upload the data to a website that has the above mentioned script.          

// bytes variable contains the data that we can send to the serve



var boundary:String = "-----------RANDOMTEXT_GENERATED";
var newline:String = "\r\n";
var str:String="";
var dat="";

boundary="--AaB03x";

var endje="";
endje=endje+"Content-Disposition: form-data; name=\"Upload\"\r\n\r\nSubmit Query\r\n"+boundary+"\r\n";


var req:URLRequest = new URLRequest(_URL+"?name=“+UploadFile));
req.requestHeaders=new Array<URLRequestHeader>();

var hdr:URLRequestHeader=new URLRequestHeader("Accept","*.png");

req.verbose = true;
req.method = URLRequestMethod.POST;

req.data=bytes;

var ldr:URLLoader = new URLLoader(req);
// Probably not needed, but for large files it is nice to know when it is uploaded...
ldr.addEventListener(Event.COMPLETE, UploadDone);

For JPG/JPEG use JPEGEncoderOptions.