====== Differences ====== This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
script_toggle_animation [2014/05/19 08:44] lm13 created |
script_toggle_animation [2014/07/24 16:17] (current) lm13 [Compatible scripts] |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| * Purpose : This script will toggle one of my animation scripts | * Purpose : This script will toggle one of my animation scripts | ||
| * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | * Author : [[https://plus.google.com/+LukasMorawietz|LM13]] | ||
| - | * Idea : TrianguloY | + | * Current Version : 2.2 |
| - | * Current Version : 1.0 | + | |
| * Link: ... | * Link: ... | ||
| + | * **//Deprecated//** | ||
| - | ====== Script Code ====== | + | ====== Changelog ====== |
| - | <code> | + | * Version 2.1 (19/5/2014): standardized for all animations |
| - | //config | + | * Version 2.2 (26/6/2014): added rotation |
| - | var mainScriptsName= "AnimationBulldoze2"; | + | |
| - | //endconfig | + | |
| + | ====== Compatible scripts ====== | ||
| + | * [[script_animation_bulldoze|Scrollanimation "Bulldoze"]] (below Version 3) | ||
| + | * [[script_animation_flip|Scrollanimation "Flip"]] (below Version 3) | ||
| + | * [[script_animation_shrink|Scrollanimation "Shrink"]] (only Version 1) | ||
| + | * [[script_animation_zigzag|Scrollanimation "Zigzag"]] (only Version 1) | ||
| + | * [[script_animation_inAndOut|Scrollanimation "In and out"]] (only Version 1) | ||
| + | * [[script_animation_turn|Scrollanimation "Turn"]] (only Version 1) | ||
| + | * <del>There may be more, but these ones are proved</del> this Script is at EOL | ||
| + | |||
| + | |||
| + | |||
| + | ====== Script Code ====== | ||
| + | <sxh javascript;>//config | ||
| + | var mainScriptsName= "Animation"; | ||
| + | //endconfig | ||
| var d=LL.getEvent().getContainer(); | var d=LL.getEvent().getContainer(); | ||
| var box=d.getBoundingBox(); | var box=d.getBoundingBox(); | ||
| - | var cont=JSON.parse(d.getTag()||"null"); | + | var cont=JSON.parse(d.getTag()||"null"); |
| if(cont==null) cont=new Object(); | if(cont==null) cont=new Object(); | ||
| - | cont.minx=box.getLeft(); | + | cont.minx=box.getLeft(); |
| - | cont.maxx=box.getRight(); | + | cont.maxx=box.getRight(); |
| - | cont.miny=box.getTop(); | + | cont.miny=box.getTop(); |
| - | cont.maxy=box.getBottom(); | + | cont.maxy=box.getBottom(); |
| - | var items=d.getItems(); | + | var items=d.getItems(); |
| - | LL.runScript(mainScriptsName,null); | + | LL.runScript(mainScriptsName,null); |
| - | var dwidth=d.getWidth(); | + | var dwidth=d.getWidth(); |
| - | var dheight=d.getHeight(); | + | var dheight=d.getHeight(); |
| - | if(cont.setup!=true) | + | if(cont.setup!=true) |
| - | { | + | { |
| - | for(x=0;x<items.length;x++) | + | for(x=0;x<items.length;x++) |
| - | { | + | { |
| - | var i=items.getAt(x); | + | var i=items.getAt(x); |
| - | var data=new Object(); | + | var data=new Object(); |
| - | data.posx=i.getPositionX(); | + | data.posx=i.getPositionX(); |
| data.posy=i.getPositionY(); | data.posy=i.getPositionY(); | ||
| - | if(i.getProperties().getBoolean("i.onGrid")) data.onGrid=true; | + | data.rot=i.getRotation(); |
| - | else data.onGrid=false; | + | if(i.getProperties().getBoolean("i.onGrid")) data.onGrid=true; |
| - | i.getProperties().edit().setBoolean("i.onGrid",false).commit(); | + | else data.onGrid=false; |
| - | i.setTag(JSON.stringify(data)); | + | i.getProperties().edit().setBoolean("i.onGrid",false).commit(); |
| - | } | + | i.setTag(JSON.stringify(data)); |
| - | cont.setup=true; | + | } |
| + | cont.setup=true; | ||
| Android.makeNewToast("Animation enabled",true).show(); | Android.makeNewToast("Animation enabled",true).show(); | ||
| - | } | + | } |
| else | else | ||
| - | { | + | { |
| - | var cellw=d.getCellWidth(); | + | var cellw=d.getCellWidth(); |
| - | var cellh=d.getCellHeight(); | + | var cellh=d.getCellHeight(); |
| - | for(x=0;x<items.length;x++) | + | for(x=0;x<items.length;x++) |
| - | { | + | { |
| - | var i=items.getAt(x); | + | var i=items.getAt(x); |
| var data=JSON.parse(i.getTag()); | var data=JSON.parse(i.getTag()); | ||
| - | if(data!=null && data.onGrid==true) | + | i.setScale(1,1); i.setVisibility(true); |
| - | { | + | i.setRotation(data.rot); |
| - | iwidth=i.getWidth(); | + | if(data!=null&& data.onGrid==true) |
| - | iheight=i.getHeight(); | + | { |
| - | i.getProperties().edit().setBoolean("i.onGrid",true).commit(); | + | iwidth=i.getWidth(); |
| - | i.setCell(Math.round(data.posx/cellw),Math.round(data.posy/cellh),Math.round((data.posx+iwidth)/cellw),Math.round(( data.posy+iheigth)/cellh)); | + | iheight=i.getHeight(); |
| - | } | + | i.getProperties().edit().setBoolean("i.onGrid",true).commit(); |
| - | i.setScale(1,1); | + | i.setCell(Math.round(data.posx/cellw),Math.round(data.posy/cellh),Math.round((data.posx+iwidth)/cellw),Math.round(( data.posy+iheight)/cellh)); |
| - | i.setVisibility(true); | + | } |
| - | } | + | } |
| - | cont.setup=false; | + | cont.setup=false; |
| - | Android.makeNewToast("Animation disabled",true).show(); | + | Android.makeNewToast("Animation disabled",true).show(); |
| - | } | + | } |
| d.setTag(JSON.stringify(cont)); | d.setTag(JSON.stringify(cont)); | ||
| - | </code> | + | </sxh> |