-
Java Animation Compile Problem
I am working on my first Java Animation using java.awt.* and javax.swing.* for my final intro to Java class project. My object (an elf) is created in a separate class and then I use the timer to move it across the screen. In the code for my elf, I have added a set value defined in a variable named MOVE to all x values. This compiles just fine for all shapes except my drawPolygon shapes. My polygons are defined correctly as I worked on the program as an applet until I completed it to look as I wanted and am now in the process of adding the animation. I cannot find anywhere where there is an example of a draw polygon or draw polyline that has the correct syntax. Can someone please tell me what I am doing incorrectly?? Thank you.
Rita
-
-
Thank you for the link to the Sun Java site but I am still having trouble adding the increment to my polygons. I get a compile error stating that " operator + cannot be applied to int[],int" One of my polygons is coded as follows:
int [] xBag = {220, 200, 240, 220};
int [] yBag = {150, 120, 120, 150};
Then when I draw it I use the following:
page.fillPolygon (xBag, yBag, xBag.length);
For all of my other shapes, I have simply added a value defined in a variable "move" to the x value to create the illusion of movement. The compiler will not allow me to use the plus sign in the draw polygon??? Do I have to create a loop to add the appropriate value and draw the polygon??? I apologize if these questions are something that should be obvious, but I am totally baffled right now and do not have any idea of what to do to correct my error. Thank you.
Rita
-
Please post the exact error message and the lines to which it is referring.
It sounds to me like you're trying to add a variable that is of type int[], rather than referencing a particular element e.g.
Code:
int[] myValue...
myValue + ... // WRONG!
myValue[1] + .... // RIGHT!
ArchAngel.
O:-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks