Develop game on BadaOs and wierd error :C
  • Hey :)
    I try to make a game for samsung wave with BadaOS there is a support for web apps :)
    I make game and it works on browser but when i try to write this code on phone sdk i got a error:

    Osp::Web::Controls::__WebService::AddMessageToConsole (3943) > TypeError: 'undefined' is not an object (evaluating '$.playground().addSprite') at line 50 loaded from file osp://www.93bt1p123e.com/Res/js/game.js

    my line 50 is:

    $.playground().addSprite("background", {height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, animation: backgroundIMG});

    and options (before line 50 :P):
    var PLAYGROUND_WIDTH = 480;
    var PLAYGROUND_HEIGHT = 800;
    var backgroundIMG = new $.gameQuery.Animation({imageURL: "img/game_bg.png"});

    And i dont know what i doing wrong :/
    I try jQuery code on phone and its ok, only this function gives error :C

    Please help me :(
  • Did you define your playground before line 50?

    If not you must do something like that: $("#myPlaygroundId").playgroud(/*options if you need some**/);

    Only then can you call to $.playground().
  • of course i do this :P
    i wrote that game works on web browser on pc :P

    in game.js i have

    declarations of variables like playground width etc.
    declarations functions to move objects
    and after this
    $(function(){
    var enemys_List = new Array();
    var enemy_Number = 0;
     
    $("#playground").playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, refreshRate: 30, mouseTracker: true});
     
    var backgroundIMG = new $.gameQuery.Animation({imageURL: "img/game_bg.png"});
    var playerIMG = new $.gameQuery.Animation({imageURL: "img/player.png"});
    var enemyIMG = new $.gameQuery.Animation({imageURL: "img/enemy.png"});
     
    $.playground().addSprite("background", {height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, animation: backgroundIMG});
    $.playground().addSprite("player", {height: 50, width: 50, posx: 100, posy: 600, animation: playerIMG});
    $.playground().addSprite("enemy_"+enemy_Number, {height: 50, width: 50, posx: 215, posy: 375, animation: enemyIMG});


    and this line with background is my 50 line :)
  • selimselim
    Accepted Answer
    Do you already have an element with the id "background" in your static HTML ? If you switch the order of the .addSprite calls what happens ?
  • Hmm... very wierd :P
    Before in my html file i have
    <body>
     
    <script type="text/javascript" src="./js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="./js/jquery.gamequery.js"></script>
    <script type="text/javascript" src="./js/QBwebapp.js"> </script>
    <script type="text/javascript" src="./js/game.js"> </script> <== my game file :)
     
    </body>

    and i delete this last line with my game.js file and in QBwebapp.js i add
    var blankSlate = new Osp.Ui.Controls.BlankSlate({bounds:{x:0,y:0,width:480,height:800},mode : Osp.Ui.Controls.BlankSlateMode.MARKUP});
    this.form.addControl(blankSlate); //add blank div to form :)
     
    $("div").attr("id", "playground");
    $("#playground").html('<div id="menu"><div id="startButton">Start Game</div></div>');
     
    $.getScript("./js/game.js");


    And it works :P
    Thanks for help :))

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!