Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Why doesn't my applet work on Mac?  (Read 771 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacob_

Junior Member


Projects: 3



« Posted 2010-07-07 23:08:00 »

This works fine for me on Windows, but someone with a Mac tested it and said that they just got a black screen, although they could hear their character moving. repaint() is definitely being called but it isn't doing it...

Strangely, on a Mac I have (it's an old PowerPC one with Java 1.5 and OS X 10.4), I get a black screen too but if I resize the browser window or move another window on top of it, it starts working.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
    public void init() {
        setBackground(Color.black);
        log("Setting up");
        //Initialize the canvas, set up input listeners
       log("Starting animator");
        animator = new Thread(this);
        animator.setName("AnimatorThread");
        animator.start();

        new Thread(new Runnable()
        {
            public void run()
            {

                setIgnoreRepaint(true);
                //load some stuff
               setIgnoreRepaint(false);

                doneLoading = true;
            }
        }).start();
    }
    @Override
    public void start()
    {
    }
    @Override
    public void update(Graphics g)
    {
        canvas.repaint(); //Updates a VolatileImage stored in the Canvas class
       g.drawImage(canvas.getImage(), 0, 0, this);
    }
    @Override
    public void paint(Graphics g)
    {
        update(g);
    }
    public void run()
    {
        log("Current thread is "+Thread.currentThread());
        while(Thread.currentThread() == animator)
        {
            //Process input and so on
           repaint();
            try {
                Thread.sleep(8); //limit FPS
           } catch (InterruptedException ex) {
            }
        }
    }


I've tried moving code around between init() and start() and paint() and update(), no success.

Anyone see a problem?

Edit: Fixed some code that was copied incorrectly
Offline Jacob_

Junior Member


Projects: 3



« Reply #1 - Posted 2010-07-08 02:33:28 »

Update: someone with Windows 7 had the problem too.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #2 - Posted 2010-07-08 04:53:51 »

Why not put it online somewhere so I can test it and see what happens?

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Swattkidd7

Junior Member





« Reply #3 - Posted 2010-07-08 07:37:05 »

its from the cubic realms thread in the showcase, here is the link
http://1scripts.net/cubic/game.php
Offline bobjob

JGO Knight


Medals: 10
Projects: 6


David Aaron Muhar


« Reply #4 - Posted 2010-07-08 08:08:05 »

its a good idea to call validate() at the end of you init code.


looking at your code, you should call it after your Thread has finished loading.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline Jacob_

Junior Member


Projects: 3



« Reply #5 - Posted 2010-07-08 15:41:50 »

Here it is: http://1scripts.net/cubic/game.php?version=CubicRealms0.06_old.jar

After posting this I decided to try remaking the game as a JApplet with graphics drawn on a JPanel just to see what happened; here is the new one: http://1scripts.net/cubic/game.php

Although the loading screen didn't work on my Mac (it's an old one, maybe the loading takes so much CPU so the graphics thread is getting starved?), I didn't have to resize the window to get it to work, which seems like a good sign.

I had someone with Win7 test the JApplet version and it worked for them, although they hadn't tried the old version.
Offline Eli Delventhal
« League of Dukes »

JGO Kernel


Medals: 39
Projects: 12


Game Engineer


« Reply #6 - Posted 2010-07-08 16:42:29 »

Works fine on my Mac.

It's 2D Minecraft! Smiley

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
hobbles (7 views)
2013-05-22 00:54:55

cubemaster21 (74 views)
2013-05-17 21:29:12

alaslipknot (86 views)
2013-05-16 21:24:48

gouessej (115 views)
2013-05-16 00:53:38

gouessej (110 views)
2013-05-16 00:17:58

theagentd (121 views)
2013-05-15 15:01:13

theagentd (110 views)
2013-05-15 15:00:54

StreetDoggy (155 views)
2013-05-14 15:56:26

kutucuk (177 views)
2013-05-12 17:10:36

kutucuk (175 views)
2013-05-12 15:36:09
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.097 seconds with 20 queries.