maandag 28 december 2015

Stencyl : Change the build process

Changing the Stencyl Make Process

Creating Ad-Hoc IPA file failed in Stencyl.

Solution was given by Captain Comic in this Threat:

http://community.stencyl.com/index.php/topic,42036.0/topicseen.html


Steps:
* Create Back-up first !
* mkdir /tmp/SW
* cp sw.jar /tmp/SW/sw.jar
* Unpack it :   cd /tmp/SW; jar xvf sw.jar
* Edit the file: vi res/ios/PackageApplication
* Search for beta-reports and uncomment them
# runCmd('/usr/libexec/PlistBuddy', '-c', 'Add :beta-reports-active bool', $entitlements_plist);
    # runCmd('/usr/libexec/PlistBuddy', '-c', 'Set :beta-reports-active YES', $entitlements_plist);
* Package the jar again:
* rm sw.jar
* Don't create a new Manifest
* jar -Mcvf sw.jar .
* cp sw.jar $HOME/Downloads/Stencyl-full/.


Launch Stencyl

Reference to my bug-report in this threat: http://community.stencyl.com/index.php/topic,44561.msg249997.html#msg249997


Edit:

The same applies to the generation of the StencylPreloader.hx
It is a file in the sw.jar and when you want to modify it you have to follow the suggestion
above.


zondag 27 december 2015

Stencyl : Swipe-speed recorder

As a follow up on the Wheel-of-Fortune a question was asked how to spin the wheel using a swipe motion.

The following code was attached to the wheel-actor and since it is generic it could be used for all type of speed recording movement on an actor.


The click code from the wheel-spin example could become a custom event and in this actor code we could do a 'execute trigger spin on all behaviors of scene spin' block. The random spin can be replaced by the spin-time. (maybe calculate the fast movement of the spin to rotate more often)

zaterdag 26 december 2015

Stencyl : Drawing an ellipse / circle inside a Rectangle

Graphics : Drawing an Ellipse inside a rectangle

Using Extension for Drawing Utilities in Stencyl: http://community.stencyl.com/index.php?topic=35352.0

Source: Download for 3.2+ Made by ETH 




The ellipse / circle is being drawn using cosinus and sinus in a 360 loop.

The corners of the ellipse can be found by using this code:

var a=_Counter; 
var i=180; // i=90 quarter, i=180 HalfWay etc..

var w=64;
var h=100;
var x=128;
var y=128;
var tempx = w * Math.cos(i * Utils.RAD);
var tempy = h * Math.sin(i * Utils.RAD);
var templ = Utils.distance(0, 0, tempx, tempy);
var tempa = a + Utils.angle(0, 0, tempx, tempy);
tempx = x + (templ * Math.cos(tempa * Utils.RAD));
tempy = y + (templ * Math.sin(tempa * Utils.RAD));
g.fillRect(tempx, tempy, 10, 10); // Mark the side with a rectangle


vrijdag 25 december 2015

Stencyl : Spinning Wheel

A Stencyl-Chat question was how to determine which part of a Wheel-of-Fortune was selected.

Wheel had 16 parts. Randomly the parts were between bad things and good things you would receive.



This is the solution I came up with (Click method on Scene)



Drawing on Scene:

Update one Scene:
Of course for this little example I wouldn't have to use a list. But when the parts are randomly filled with objects it will do nicely.

The difficult thing was to get the angle of the rotated actor:




zondag 20 december 2015

Stencyl : Simple Dialog Box

Dialog Screen

Create a scene that is larger than the display-screen.

Put a button on the first part of the scene 'top dialog'
Button pressed on actor:
[move [camera] to (x:0 y:1400)

Put another button the second part of the scene
Another button
Pressed on Actor:
[move [camera] to (x:0 y:0)

Now you can switch between the 'dialog' screens.

HaXe / Stencyl : Javascript

== Javascript from haxe ==

code-block:

flash.external.ExternalInterface.call(“o3p_write(\”this is the text to store\”)”);


flash.html

<<html>
<head>
<script type="text/javascript">
   function hallo(){
   alert('hallo from swf');
   }
   function o3p_write(v){
   alert('Hi What is variable v : '+v)
   }
   
</script>
</head>
<center>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="480" HEIGHT="320" id="TileAPI" ALIGN="">
<PARAM NAME=movie VALUE="TileAPI.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#333399> <EMBED src="TileAPI.swf" quality=high bgcolor=#333399 WIDTH="480" HEIGHT="320" NAME="TileAPI" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>
</center>
</html>

Another:

ExternalInterface.call return values

To run javascript code inside a flash game you can use externalinterface.call.
The returnvalue is’nt always working.
This worked in Stencyl:



var theResult:String="";
#if flash
          theResult=ExternalInterface.call("doit_return");
trace("The result is: "+theResult);
#end


Javascript function:
function doit_return(){
   return "abcdef";

}

Stencyl / HaXe : Replace TileSet image dynamically ( levels ? )


Note: Blog Post is a quick proof-of-concept outline that was used to replace a tilesheet. It is not a 'use-everywhere'-scenario.

Assumption : there is only one TileSet made in Stencyl {(resources.get(0)}


// old => cast(Data.get().resources.get(0),Tileset).bitmapData=bitmapData;
cast(Data.get().resources.get(0),Tileset).pixels=bitmapData;
// make the rest (than flash) use the tilesheet construction
#if cpp
cast(Data.get().resources.get(0),Tileset).setupTilesheet();
//.bitmapData=bitmapData;
#end

Also you can use the nme.net.URLRequest together with the
nme.display.Loader  (loader.load(new URLRequest(theURL));)
in combination with the 
loaderinfo.content.somehtning.addeventlistener(event.complete,do_the_above_with_tileset_function);


var bit:Bitmap = new Bitmap();
bit.bitmapData = bitmapData;
g.drawImage(bitmapData,0,0,0);

//this.engine.g.canvas.graphics.drawImage(bit, 0,0,0);
/*
var url:String="https://dl.dropboxusercontent.com/u/107982821/test.png";
var loader:Loader = new Loader();
   var urlRequest:URLRequest = new URLRequest(url);
   if(urlRequest != null)loader.load(urlRequest);    
   var b:Bitmap = new Bitmap();
   if (loader.content != null) {
   b = cast(loader.content,Bitmap);
  
     }
     */

  
     /*
g.fillColor=330;
//this.engine.g.canvas.graphics.fillRect(0,0,50,530);
if( b != null){
g.drawImage(b.bitmapData,0,0,0);
}else{
   g.fillRect(0,0,50,50);
}
*/
/*
//actorOfType.originMap.set("1"), new B2Vec2());
var i:Array<Int> = new Array<Int>();
i.push(100);
var ba:BitmapAnimation = new BitmapAnimation(b.bitmapData,1,i,false,null);
actorOfType.addAnimation("1",ba);
//var picLoader = new Loader();
//var spritePic = picLoader.load(new URLRequest("https://dl.dropboxusercontent.com/u/107982821/test.png"));

*/