Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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 1008 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacob_

Junior Member


Projects: 3



« Posted 2010-07-07 21: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 00:33:28 »

Update: someone with Windows 7 had the problem too.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2010-07-08 02: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 05: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: 4


David Aaron Muhar


« Reply #4 - Posted 2010-07-08 06: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 13: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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2010-07-08 14: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.

 

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

The first screenshot will be displayed as a thumbnail.

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!