劍氣縱橫-autojs動畫

牙叔教程 簡單易懂

劍氣縱橫-autojs動畫

“ui”;engines。all()。map((ScriptEngine) => { if (engines。myEngine()。toString() !== ScriptEngine。toString()) { ScriptEngine。forceStop(); }});importClass(“android。animation。ValueAnimator”);importClass(“android。content。Context”);importClass(“android。graphics。Matrix”);importClass(“android。graphics。PorterDuffXfermode”);importClass(“android。graphics。PorterDuff”);importClass(“android。graphics。Color”);importClass(“android。util。AttributeSet”);importClass(“android。view。View”);importClass(“android。view。animation。RotateAnimation”);ui。layout( );// 設定畫筆引數let paint = new Paint(Paint。ANTI_ALIAS_FLAG);paint。setStyle(Paint。Style。FILL);color = colors。parseColor(“#ffffff”);paint。setColor(color);// 設定動畫引數let anim = ValueAnimator。ofFloat(0, -360);anim。repeatCount = android。view。animation。Animation。INFINITE;anim。setDuration(1000);anim。setInterpolator(null);anim。start();let camera = android。graphics。Camera();let rotateMatrix = Matrix();let xfermode = PorterDuffXfermode(PorterDuff。Mode。DST_OUT);/* —————————————————————————————————————— */ui。post(function () { let width = ui。board。getWidth(); let height = ui。board。getHeight(); // log(width。toFloat()); ui。board。on(“draw”, function (canvas) { canvas。drawColor(Color。BLACK); color = “#ff0000”; drawSword(canvas, 35, -45, 0, width, height, color); color = “#00ff00”; drawSword(canvas, 50, 10, 120, width, height, color); color = “#0000ff”; drawSword(canvas, 35, 55, 240, width, height, color); });});function drawSword(canvas, rotateX, rotateY, startValue, width, height, color) { let colorNum = colors。parseColor(color); paint。setColor(colorNum); let layerId = canvas。saveLayer(0, 0, width, height, null, android。graphics。Canvas。ALL_SAVE_FLAG); rotateMatrix。reset(); camera。save(); /* ————————相機旋轉—————————————————————————————— */ camera。rotateX(rotateX); camera。rotateY(rotateY); camera。rotateZ(anim。animatedValue + startValue); camera。getMatrix(rotateMatrix); camera。restore(); /* —————————————————————————————————————— */ let halfW = width / 2; let halfH = height / 2; let radius = Math。min(width, height) / 4; rotateMatrix。preTranslate(-halfW, -halfH); rotateMatrix。postTranslate(halfW, halfH); canvas。concat(rotateMatrix); canvas。drawCircle(halfW, halfH, radius, paint); paint。xfermode = xfermode; canvas。drawCircle(halfW, halfH - 0。05 * radius, radius * 1。01, paint); canvas。restoreToCount(layerId); paint。xfermode = null;}

參考

Android 炫酷自定義 View - 劍氣載入

名人名言

思路是最重要的, 其他的百度, bing, stackoverflow, 安卓文件, autojs文件, 最後才是群裡問問

——- 牙叔教程

宣告

部分內容來自網路

本教程僅用於學習, 禁止用於其他用途