This site requires JavaScript, please enable it in your browser!
Greenfoot back
Roshan123
Roshan123 wrote ...

2021/4/27

Scenario gives error in website but not in app

1
2
3
RcCookie RcCookie

2021/5/1

#
This is a MIT licence:
Copyright <YEAR> <YOUR (USER)NAME>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Put this into a file named LICENCE in your scenario folder. It allowes anybody to use your code, edit and publish it, AS LONG as they keep this licence (with your name) in and thus credit you.
Roshan123 Roshan123

2021/5/1

#
RcCookie wrote...
On Firefox and Chrome you can also hit "CTRL+SHIFT+I" to open the inspection page, then simply select "Console" of the tabs. Anyways, this it said:
> java.lang.RuntimeException: (JavaScript) TypeError: $this is null
Do you have a method named "Crate_act" in which you set the image of the actor?
Their is no method named 'Crate_act'. But yes their is a class named Crate and i created a condition in which if certain classes gets close to the crate then it will create a loop in which it will continuously change its(crate) image again and again I used instance of crate class in MyWorld...B....EnemyTank....EnemyTank1.....Tank
Super_Hippo Super_Hippo

2021/5/1

#
RcCookie wrote...
Why don’t you share it via Greenfoot? You can add a license of you are worried, google for „MIT License“
What is all this about? The source code is already public and you can download it.
RcCookie RcCookie

2021/5/1

#
Yep, that's actually true. I never even looked at that.
RcCookie RcCookie

2021/5/1

#
@Roshan123: In the Crate class, please replace lines 11 and 12 with this:
        {
            System.out.println("Changing crate image of crate " + this);
            setImage("crate1.png");
        }
Then reupload the scenario and tell me.
Roshan123 Roshan123

2021/5/1

#
RcCookie wrote...
@Roshan123: In the Crate class, please replace lines 11 and 12 with this:
        {
            System.out.println("Changing crate image of crate " + this);
            setImage("crate1.png");
        }
Then reupload the scenario and tell me.
Thanks!!!!!!!!!!!!!!!!!!!!!!! Now it works properly
Roshan123 Roshan123

2021/5/1

#
But how is it possible. Would you like to explain me....plz
Roshan123 Roshan123

2021/5/1

#
RcCookie wrote...
@Roshan123: In the Crate class, please replace lines 11 and 12 with this:
        {
            System.out.println("Changing crate image of crate " + this);
            setImage("crate1.png");
        }
Then reupload the scenario and tell me.
By the way is their any other way to fix it. Though its not important but i m having problem in app. Its working but i have to minimize the terminal window every time...
RcCookie RcCookie

2021/5/1

#
Well actually this wasn't supposed to fix it, just debug what's going on...
RcCookie RcCookie

2021/5/1

#
You can try to remove the print statement, maybe it was just a compiling error. If it does not work again then you can at add this line instead:
 Crate c = this;
That should have the same effect.
Roshan123 Roshan123

2021/5/1

#
RcCookie wrote...
Well actually this wasn't supposed to fix it, just debug what's going on...
Wierd....but u can check it out in website. Now its working properly. Even if u can download the source code again to see that i only did what u told me
Roshan123 Roshan123

2021/5/1

#
RcCookie wrote...
maybe it was just a compiling error.
But i re-uploaded it 1-2 times more
RcCookie RcCookie

2021/5/1

#
Roshan123 wrote...
RcCookie wrote...
maybe it was just a compiling error.
But i re-uploaded it 1-2 times more
When I meant compiler error, I meant that there may have been a point in which this did not work (also in the app) and maybe you fixed it, but it did not properly compile into the .class file. This stuff happens sometimes in Greenfoot. Because it wasn't compiled, the change wasn't actually applied, but maybe you thought it was and uploaded it. If you then changed your code a bit more or just reopened the window it may got compiled properly so it would not happen in the app.
Roshan123 Roshan123

2021/5/2

#
RcCookie wrote...
You can try to remove the print statement, maybe it was just a compiling error.
As usual the answer is....u were correct. Yet now its working properly even if the statement is removed. Thanks a lot for it!!!!!
Roshan123 Roshan123

2021/5/8

#
Main class is: MyWorld


269scenario26460.js:4843 Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD
//the above lilne is red in color edited by rosh....)

scenario26460.js:356 Crate@b3dcd522
scenario26460.js:356 Crate@668b25e


scenario26460.js:367 java.lang.RuntimeException: (JavaScript) TypeError: Cannot read property '$node' of null
$rt_putStderr @ scenario26460.js:367
//the above line is red in color(edited by rosh....)
There are more replies on the next page.
1
2
3