×

Discussion Board

Results 1 to 5 of 5

Thread: HTML5 apps..

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    8

    HTML5 apps..

    Hi,

    any one try the HTML5 app with the N950 ?
    i had written an HTML 5 app using canvas via the QT html5applicationviewer.cpp

    it seems like there is an error when i Suspend the application in the backgroung by swiping the screen form left toright in Landscape mode. once i done that when i touch the the application from the background and continue to use it will crash..

    QGLWindowSurface: Using plain widget as window surface QGLWindowSurface(0x99bd8)
    Segmentation fault (core dumped)

    here's the index.html
    *****starts ********
    <html>
    <head>
    <title>HTML5 canvas example - Noughts & Crosses game</title>
    <style>
    canvas{
    margin:1px;
    padding:0px;
    border:#333 solid;
    }
    .label {
    font-weight:bold;
    }
    </style>


    <script type="text/javascript">

    var context; //referral to canvas context
    var mouse = {x:-100, y:-100};
    var circle = Math.PI * 2

    var h = 320;
    var w = 320;
    var square_X = 1;
    var square_Y = 1;
    var game_board_grid;
    var playerwins = 0;
    var computerwins = 0;

    function block(x,y,player) {

    this.x = x;
    this.y = y;
    this.player = player;

    }

    function doCalc()

    {
    if(mouse.x < (w/3)*1) square_X = 1
    else if(mouse.x < (w/3)*2) square_X = 2
    else if(mouse.x < (w/3)*3) square_X = 3;

    if(mouse.y < (h/3)*1) square_Y = 1
    else if(mouse.y < (h/3)*2) square_Y = 2
    else if(mouse.y < (h/3)*3) square_Y = 3;

    }


    function $(id) {

    return document.getElementById(id);

    }

    function init() {

    //2D array for the game_board_grid
    if(game_board_grid != undefined)
    game_board_grid.length = 0;
    game_board_grid = new Array(3);

    for(var i=0;i<3;i++) {
    game_board_grid[i] = new Array(3);
    for(var j=0;j<3;j++) {
    game_board_grid[i][j] = new block((w/3)*j,(h/3)*i,'C');
    }
    }

    context = $('canvas').getContext('2d');
    context.fillStyle = "#CCF";
    context.fillRect(0,0,w,h);
    createGameBoard();
    _clock();

    }



    function createGameBoard() {

    context.fillStyle = "#330";
    context.fillRect(w/3,0,2,w);
    context.fillRect((w/3)*2,0,2,w);
    context.fillRect(0,h/3,h,2);
    context.fillRect(0,(h/3)*2,h,2);
    }



    function drawZeroForMovement() {

    context.fillStyle = "#FF0";
    context.beginPath();
    context.arc(mouse.x, mouse.y, 30, 0, circle, true);
    context.closePath();
    context.fill();
    }

    function display_X(x,y) {

    context.strokeStyle = "#666";
    context.lineWidth = 5;
    context.moveTo(x,y);
    context.lineTo(x+w/3,y+h/3);
    context.moveTo(x,y+h/3);
    context.lineTo(x+w/3,y);
    context.stroke();
    }

    function display_0(x,y) {

    context.fillStyle = "#300";
    context.beginPath();
    context.arc(x+(w/3)/2, y+(h/3)/2, 50, 0, circle, true);
    context.closePath();
    context.fill();

    }

    function _clock() {

    doCalc();

    document.onmousemove = function(e) {
    mouse.x = e.pageX;
    mouse.y = e.pageY;
    }

    window.setTimeout('_clock()', 1000/50); //50 frames per second

    }

    function play() {

    doCalc();
    if(game_board_grid[square_Y-1][square_X-1].player == 'C') { //this square has not been used
    game_board_grid[square_Y-1][square_X-1].player = '0';
    display_0(game_board_grid[square_Y-1][square_X-1].x,game_board_grid[square_Y-1][square_X-1].y);

    } else { //Used square
    return false;
    }

    var won = false;

    //Player 0 check for possible win condition

    if(game_board_grid[0][0].player == '0' && game_board_grid[0][1].player == '0' && game_board_grid[0][2].player == '0') {
    alert("You win!");
    won = true;
    init();

    } else if(game_board_grid[1][0].player == '0' && game_board_grid[1][1].player == '0' && game_board_grid[1][2].player == '0') {
    alert("Player wins");
    won = true;
    init();

    } else if(game_board_grid[2][0].player == '0' && game_board_grid[2][1].player == '0' && game_board_grid[2][2].player == '0') {
    alert("Player wins");
    won = true;
    init();

    } else if(game_board_grid[0][0].player == '0' && game_board_grid[1][0].player == '0' && game_board_grid[2][0].player == '0') {
    alert("Player wins");
    won = true;
    init();

    } else if(game_board_grid[0][1].player == '0' && game_board_grid[1][1].player == '0' && game_board_grid[2][1].player == '0') {

    alert("Player wins");
    won = true;
    init();

    } else if(game_board_grid[0][2].player == '0' && game_board_grid[1][2].player == '0' && game_board_grid[2][2].player == '0') {
    alert("Player wins");
    won = true;
    init();

    } else if(game_board_grid[0][0].player == '0' && game_board_grid[1][1].player == '0' && game_board_grid[2][2].player == '0') {
    alert("Player wins");
    won = true;
    init();

    } else if(game_board_grid[2][0].player == '0' && game_board_grid[1][1].player == '0' && game_board_grid[0][2].player == '0') {
    alert("Player wins");
    won = true;
    init();

    }


    }
    </script>
    </head>


    <body onload="init()">
    <canvas onclick="play();" id="canvas" width="320" height="320">Game Exit: HTML5 not supported by browser.</canvas>
    </body>

    </html>
    ******end ************

    its seems like there is issues when using the canvas

    any one can help on this ...

    regards

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,738

    Re: HTML5 apps..

    Hi, your posts were captured by the pre-moderation filter (it often happens with users having low number of posts). Now this one is enabled, as this was posted first, and it seems to contain a longer description. Please let me know if the other post was different (have not compared them line by line, but it looked similar), and it will be restored too.
    Although it is not me who can answer a Qt+HTML5 question, a thing that may worth trying is to check the same code with the built-in browser, just to see if it crashes too. (My guess is yes, but who knows)

  3. #3
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: HTML5 apps..

    Hi mrrekcuf,

    Do you have any valid backtrace?
    Did you try to run the same HTML script on the MeeGo browser? If yes, does it crash?

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    8

    Re: HTML5 apps..

    hi,

    both message are the same..

    after i post i did not see the message so i thought i had click the cancel button...
    so i re post again...
    sorry for the confusion...

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    8

    Re: HTML5 apps..

    hi,

    i had actually use the Qt creator to create a HTM5 app..
    once the project created..
    it is using the Html5ApplicationViewer.cpp to perform the html thing...
    al i need to do its to put in the index.html + others image file..
    you will had a ready html5 apps..
    very impressive...

    but some how it crashes using the html 5 code (from nokia html 5 tic tap toe demo code)

    so i not sure is the Html5ApplicationViewer using the meegoo browser or not..
    btw how do i use the browser to see the index.html ?

    regards

Similar Threads

  1. html5 onclick
    By Meins in forum Qt
    Replies: 1
    Last Post: 2011-07-07, 10:22
  2. Cross-Platform and HTML5
    By mohhassan in forum Symbian
    Replies: 4
    Last Post: 2011-06-16, 13:26
  3. Replies: 9
    Last Post: 2011-05-15, 22:10
  4. to develop Symbian apps(j2me client and j2ee server apps)
    By harish_goel in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2010-07-29, 10:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×