PDA

View Full Version : animated layer script


coooooop
24th August 2002, 07:01
can someone show me how to edit this script (used in the complex tutorial skin) to trigger an animated layer to start instead of triggering the button to move?

here is the script:

// Complex Tutorial Skin - triangle.m MAKI file
// Created by Ken Chen for the official Winamp3 skinning site.

// #include Section
#include "../../../lib/std.mi"
#include "../../../lib/config.mi"
#include "../../../lib/pldir.mi"

// Variable Declaration Section
global Button button_triangle;
global Int moving_triangle;
global String status_triangle;

// System.onScriptUnloading() Section
System.onScriptUnloading(){
}

// System.onScriptLoaded() Section
System.onScriptLoaded(){
group triangleDrawer = getScriptGroup();
button_triangle = triangleDrawer.findobject("complex.circle3.triangle3");
status_triangle = "closed";
moving_triangle = 0;
}

// Your own functions
button_triangle.onEnterArea(){
if( status_triangle == "closed" && moving_triangle != 1 ){
moving_triangle = 1;
button_triangle.setTargetY(60);
button_triangle.setTargetSpeed(0.25);
button_triangle.gototarget();
}else if( status_triangle == "open" && moving_triangle != 1){
moving_triangle = 1;
button_triangle.setTargetY(30);
button_triangle.setTargetSpeed(0.15);
button_triangle.gototarget();
}
}

button_triangle.ontargetreached(){
if( status_triangle == "closed" ){
status_triangle = "open";
moving_triangle = 0;
}else if( status_triangle == "open" ){
status_triangle = "closed";
moving_triangle = 0;
}
}

Vica
24th August 2002, 15:32
If I get you correctly, you want a button to control an animated layer similar to the way a button controls a drawer.

This script should work:


#include "../../../lib/std.mi"

Global AnimatedLayer SpinningAnim;
Global Button animcontrol;
Global int AnimOn;

System.onScriptLoaded() {
//button & layer definations go here.

AnimOn = 1;
}

animcontrol.onLeftClick() {
if (AnimOn == 1) {
SpinningAnim.pause();
AnimOn = 0;
}
else {
SpinningAnim.start();
AnimOn = 1;
}
}



I'm a noob to maki also, so someone correct me if I'm wrong.

DirtyLowMoFo
24th August 2002, 19:07
Another way to do it with a bit more control over it

code:
___________________________________________________________________

#include <lib/std.mi>

Function DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop);

Global Button mybutton;
Global AnimatedLayer myanimatedlayer;
Global Int ani;

System.onScriptLoaded() {

//button & layer definations go here.

ani = 1;
}

mybutton.onLeftClick() {
if (ani == 1) {
DoAniStuff(myanimatedlayer, 0, 10, 50, 1);
ani = 0;

//this will start at first frame, play to frame 10 at 50 milliseconds a frame & loop continuously
//if u want it to play backwards set the start frame lower than the stop frame eg. DoAniStuff(myanimatedlayer, 10, 0, 50, 1);

}else {
if (ani == 0) {
DoAniStuff(myanimatedlayer, 0, 0, 0, 0);
ani = 1;
//if u dont want it to play set the start & end frames the same
}
}
}

DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop) {
ToBeAnim.setStartFrame(start);
ToBeAnim.setEndFrame(stop);
ToBeAnim.setAutoReplay(loop);
ToBeAnim.setSpeed(speed);
ToBeAnim.play();
}

____________________________________

hope this helps

coooooop
24th August 2002, 21:36
thanks guys, i'll try these out and get back to you

coooooop
24th August 2002, 22:55
alright dirtylowmofo, i have been able to use your script exactly the way i want to, but there are a couple things that i dont know how to do, when the animation ends i want the last frame to stay visible instead of disappearing immediately, also where i have changed it to trigger at the onEnterArea class i need to define the area because i need the button to be a ghost but ghost buttons dont pick up hovers, so i need to define the area from coordinates or something but i dont know how (it would be great if i could get a half circle shape area, but just a rectangle will work too) thanks for all your help already!

here is the modified script

if anyone else could help me too that would be great


#include "../../../lib/std.mi"

Function DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop);

Global Button mybutton;
Global AnimatedLayer myanimatedlayer;
Global Int ani;

System.onScriptLoaded() {
group triggerDrawer = getScriptGroup();
mybutton = triggerDrawer.findobject("trigger");
group bubbleDrawer = getScriptGroup();
myanimatedlayer = bubbleDrawer.findobject("bubbleani");


ani = 1;
}

mybutton.onEnterArea() {
if (ani == 1) {
DoAniStuff(myanimatedlayer, 10, 0, 100, 0);
ani = 0;

//this will start at first frame, play to frame 10 at 50 milliseconds a frame & loop continuously
//if u want it to play backwards set the start frame lower than the stop frame eg. DoAniStuff(myanimatedlayer, 10, 0, 50, 1);

}else {
if (ani == 0) {
DoAniStuff(myanimatedlayer, 0, 0, 0, 0);
ani = 1;
//if u dont want it to play set the start & end frames the same
}
}
}

mybutton.onLeaveArea() {
if (ani == 0) {
DoAniStuff(myanimatedlayer, 0, 10, 100, 0);
ani = 1;

//this will start at first frame, play to frame 10 at 50 milliseconds a frame & loop continuously
//if u want it to play backwards set the start frame lower than the stop frame eg. DoAniStuff(myanimatedlayer, 10, 0, 50, 1);

}else {
if (ani == 1) {
DoAniStuff(myanimatedlayer, 0, 0, 0, 0);
ani = 0;
//if u dont want it to play set the start & end frames the same
}
}
}



DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop) {
ToBeAnim.setStartFrame(start);
ToBeAnim.setEndFrame(stop);
ToBeAnim.setAutoReplay(loop);
ToBeAnim.setSpeed(speed);
ToBeAnim.play();
}

DirtyLowMoFo
24th August 2002, 23:39
not sure but think this should work how u want it (still new at this myself)

code:
______________________________________________________________________

#include "../../../lib/std.mi"

Function DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop);

Global Button mybutton;
Global AnimatedLayer myanimatedlayer;

System.onScriptLoaded() {
group triggerDrawer = getScriptGroup();
mybutton = triggerDrawer.findobject("trigger");
group bubbleDrawer = getScriptGroup();
myanimatedlayer = bubbleDrawer.findobject("bubbleani");
}

mybutton.onEnterArea() {
DoAniStuff(myanimatedlayer, 10, 0, 100, 0);
}

mybutton.onLeaveArea() {
DoAniStuff(myanimatedlayer, 0, 10, 100, 0);
}

DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop) {
ToBeAnim.setStartFrame(start);
ToBeAnim.setEndFrame(stop);
ToBeAnim.setAutoReplay(loop);
ToBeAnim.setSpeed(speed);
ToBeAnim.play();
}
______________________________________________________________________

in your xml try this (not checked but should work)

code :
______________________________________________________________________

<button
id="trigger"
action=""
x="?" y="?"
image="?"
downImage="?"
ghost="1"
rectrgn="1"
/>
______________________________________________________________________
fill in the ? with the relevant info :)

& just to be clear the first frame of the animation is frame 0, so to end on frame 10 u need 11 frames

coooooop
25th August 2002, 00:11
thanks, i didnt touch the script cause it works fine except for the end frame, and now it works perfect, i still cant seem to get it to recognize mouseover when ghost="1" i put rectrgn="1" in my xml but it didnt change anything, what does it do?

thanks for all your help already, i'll just keep looking for a way to do what i need


does anyone know if and how i would use the function "isMouseOver(int x, int y)"?

DirtyLowMoFo
25th August 2002, 00:38
Not sure why u want a button with ghost="1".
If it's because u dont want the image to change just set the downImage=" " to the same as the image=" " in your xml or change the button to a layer or remove the ghost="1" from the button & put a layer on top of it (with the image u want)& set the layer to ghost="1".

coooooop
25th August 2002, 00:52
no, actually its kind of complicated and completely unnecessary but i think it looks cool, see i have an animation that slowly covers other buttons, then when you hover the mouse over the animated layer it will open and let you click the hidden buttons underneath

does that make sense?

DirtyLowMoFo
25th August 2002, 01:07
screenshot might help :)

coooooop
25th August 2002, 01:27
alright, i dont like showing half finished work but here is the area of the skin in question

the greyish colored bars are the play functions (next, back, play etc...)

coooooop
25th August 2002, 01:28
and in the up position

DirtyLowMoFo
25th August 2002, 01:50
try this

code:
______________________________________________________________________

#include "../../../lib/std.mi"

Function DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop);

Global Button mybutton;
Global AnimatedLayer myanimatedlayer;

Class GuiObject HintObject;

Global HintObject playbtn, nextbtn; //add the rest of the buttons that r under the animated layer

System.onScriptLoaded() {
group triggerDrawer = getScriptGroup();
mybutton = triggerDrawer.findobject("trigger");
group bubbleDrawer = getScriptGroup();
myanimatedlayer = bubbleDrawer.findobject("bubbleani");

playbtn = wherever?.findObject("play");
nextbtn = wherever?.findObject("next");
}

myanimatedlayer.onEnterArea() {
DoAniStuff(myanimatedlayer, 10, 0, 100, 0);
}

HintObject.onLeaveArea() {
DoAniStuff(myanimatedlayer, 0, 10, 100, 0);
}

myanimatedlayer.onFrame(int framenum) {
if (framenum == 0) {
myanimatedlayer.setXmlParam("ghost", "1");
}else {
if (framenum == 10) {
myanimatedlayer.setXmlParam("ghost", "0");
}
}
}

DoAniStuff(AnimatedLayer ToBeAnim, int start, int stop, int speed, int loop) {
ToBeAnim.setStartFrame(start);
ToBeAnim.setEndFrame(stop);
ToBeAnim.setAutoReplay(loop);
ToBeAnim.setSpeed(speed);
ToBeAnim.play();
}
____________________________________________________________________

not sure but i think your animatedlayer xml needs to have ghost="0"

coooooop
25th August 2002, 03:26
no go

:(

thanks though, in this thread you have pretty much taught me how to script lol