Old 30th January 2008, 20:29   #1
corwwin
Senior Member
 
corwwin's Avatar
 
Join Date: Mar 2002
Location: Kingdom of Amber
Posts: 272
Moving things

Hi everybody

I'd like to move an image through the main window, along a predefined trajectory. I wanted to create an indexed table with n lines of x y values, pick the values every t seconds, and assign the coordonates to the object.Something like this :

setdelay.ontimer()
i=i+1;
if (i>n) i=1;
object.setXMLParam("x",System.integerToString(x(i)));
object.setXMLParam("y",System.integerToString(y(i)));
object.gototarget();

but I couldn't find how to create and fill this table, and thereafter read the values.
Any (CPU sparing) help warmly welcome.

P.S. I couldn't either make the object.resize (x,y,w,h) thing to work. Any hidden trick in this function?
corwwin is offline   Reply With Quote
Old 30th January 2008, 21:03   #2
E-Trance
Senior Member
 
Join Date: Oct 2005
Location: Russia
Posts: 164
Send a message via ICQ to E-Trance
Have you seen this?

List.addItem(Any _object);
List.removeItem(int pos);
Any List.enumItem(int pos);
Int List.findItem(Any _object);
int List.getNumItems();
List.removeAll();

Use it to create the table (array of Xs and Ys).

Example usage:

List mylist = new List;
mylist.additem(5);
mylist.additem(10);
int x = mylist.enumitem(0);
int y = mylist.enumitem(1);
delete mylist;

Result: x is 5 and y is 10
E-Trance is offline   Reply With Quote
Old 30th January 2008, 21:55   #3
SLoB
Major Dude
 
SLoB's Avatar
 
Join Date: Jul 2003
Location: UK
Posts: 1,316
yea lists are super quick, checkout the rotational timeline viz (Azenis)
SLoB is offline   Reply With Quote
Old 31st January 2008, 19:06   #4
corwwin
Senior Member
 
corwwin's Avatar
 
Join Date: Mar 2002
Location: Kingdom of Amber
Posts: 272
Good evening
Thanx for the info, I try it asap
corwwin is offline   Reply With Quote
Old 4th February 2008, 19:57   #5
Laurent LM
Junior Member
 
Join Date: Dec 2005
Location: France
Posts: 7
Hi there !

Correct me if I am wrong, but you have to define the list in the body of the function onTimer().

What is your opinion of making an array with the following method ?
code:

// Always include the file std.mi

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

// These are the values that we will use to fill the "array"

#define A1 20
#define A2 30
#define A3 12
#define A4 42
#define A5 7
#define A6 18

Global Layer MyImage;

Function Int AValue(Int n);

// Let's initialize the variables
System.onScriptLoaded() {

// Place here your startup code

} // end of onScriptLoaded()

// Use the defined function like this example:

MyImage.onTimer() {
Int M = 1 ;
MyImage.setXMLParam(AValue(M));
}

// Function AValue fills the "array"

Int AValue(Int n) {
if(n == 1) return A1;
if(n == 2) return A2;
if(n == 3) return A3;
if(n == 4) return A4;
if(n == 5) return A5;
if(n == 6) return A6;
}


Laurent LM is offline   Reply With Quote
Old 5th February 2008, 06:23   #6
E-Trance
Senior Member
 
Join Date: Oct 2005
Location: Russia
Posts: 164
Send a message via ICQ to E-Trance
Quote:
What is your opinion of making an array with the following method ?
It's bad. Why not to use lists?
Quote:
Correct me if I am wrong, but you have to define the list in the body of the function onTimer().
Nah... It can be defined locally or globally as many other types of variables.

PHP Code:
// Define the list
Global List mylist;

// Create the list
System.onScriptLoaded() {
  
mylist = new List;
}

// Delete the list
System.onScriptUnloading() {
  
delete mylist;
}

// Use the list
someFunction(int x) {
  
mylist.additem(5);
  
mylist.additem(10);
  
int x mylist.enumitem(0);
  
int y mylist.enumitem(1);

E-Trance is offline   Reply With Quote
Old 9th February 2008, 08:20   #7
corwwin
Senior Member
 
corwwin's Avatar
 
Join Date: Mar 2002
Location: Kingdom of Amber
Posts: 272
Hi
I could finally use lists as tables of values to move and resize objects.
Needed tables : tablex, tabley, tablew, imagestable
The x y w tables define the coordonates and size along the trajectory.
The imagestable contents the name of every frame image ( image001, image002, etc).
i is the object position along the trajectory.
j is the frame number to be displayed.
After having initialized i j variables, starting size and position and object speed, here is the core code :

object.onTargetReached(){
i = i + 1;
if (i>tablex.getNumItems()-1) i=1;
j=j+1;
if(j>imagestable.getNumItems()-1) j=1;

x = tablex.enumitem(i);
y = tabley.enumitem(i);
a = tablew.enumitem(i);
s = imagestable.enumitem(j);

object.settargetX(x);
object.settargety(y);
object.settargetw(a);
object.settargeth(a);
object.setXMLparam("image",s);
object.gototarget();
}

This allows to move an animated object in the main window, but needs lot of CPU if you want to smooth the movement and animation. I tried to use the resize(x,y,w,h) function, but it doesn't work. Does anyone know why, or how to use this function?
Thanx to the maki gurus for their pertinent an useful replies.
corwwin is offline   Reply With Quote
Old 9th February 2008, 14:27   #8
E-Trance
Senior Member
 
Join Date: Oct 2005
Location: Russia
Posts: 164
Send a message via ICQ to E-Trance
Quote:
Needed tables : tablex, tabley, tablew, imagestable
That is irrational. I think it is better to use one table for all. You also don't need the imagestable if you're using IDs like "image001" - you can implement it just by the following code - "image00"+integertostring(int)
Try also to do it using AnimatedLayer. It is faster.
E-Trance is offline   Reply With Quote
Old 9th February 2008, 17:04   #9
SLoB
Major Dude
 
SLoB's Avatar
 
Join Date: Jul 2003
Location: UK
Posts: 1,316
using a map is fast too
SLoB is offline   Reply With Quote
Old 9th February 2008, 19:27   #10
corwwin
Senior Member
 
corwwin's Avatar
 
Join Date: Mar 2002
Location: Kingdom of Amber
Posts: 272
Hi
Here is the xml code :
PHP Code:
<button id="object"    x="350" y="335"  w="1" h="1"     action="play" tooltip="play"    image="image001" rectrgn="1" /> 
which initiates the first size, position and image of the object.

The moving thing is a button, that's the main reason why I couldn't use an animated layer.
Another point : the frame image is about 100x100 pix, and the animation sequence is 120 images long, a nightmare file in Photoshop!

Quote:
I think it is better to use one table for all
for all what? every table is like a column in an array, tell me how to make it easier.

Quote:
if you're using IDs like "image001" - you can implement it just by the following code - "image00"+integertostring(int)
Works only for the #0 to #9 frames!

The "image00"+integertostring(int) trick didn't work for me (and it's not easy to build a 3 or 4-digits code for the 99 first values - 3DStudio generates 4-digits filenames). My solution is inelegant, needs hundreds of lines to fill the tables, but is basic, efficient and fast.

My main problem is the CPU needed by the settarget and setXMLparam lines, I thought I could solve it using the resize function. So one more time my question : How to make the resize(x,y,w,h) function to work?


Quote:
Thanx to the maki gurus for their pertinent an useful replies
No thanks to be done at the moment....
corwwin is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Skinning and Design > Modern Skins

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump