Results 1 to 2 of 2
  1. karrott's Avatar
    11 Posts
    Global Posts
    75 Global Posts
    I've been a web developer for a long time now, but surprisingly I'm unable to wrap my head around the way webOS works. I'm able to get applications to run and set up basic widgets, but almost everything I try to do causes the app to fail. I've decided to try converting one of my flash games over to javascript so I can use the canvas element. (I'm aware of the limits Palm has on it.)

    The trouble is that no matter how many different ways I try to draw even a simple line on a canvas, nothing appears. (The code is valid, it works in the browser.) I know this is a newbie question, but can anyone give me a working example of a canvas element successfully running in an app. I really don't understand the scope of webos apps, and have trouble getting the code connected to the canvas. I appreciate any and all help!
  2. #2  
    to get started you need to have the scene html contain this:
    <canvas id="gamecanvas" width="320" height="480"></canvas>
    even if you are programming for pre and pixi, just set it to 320x480. you'll use the id in the next part.

    and in any function you are using canvas (or do a global creation), you need to have this first defined:
    var canvas = this.controller.get("gamecanvas");
    var ctx = canvas.getContext('2d');
    i'm sure you know how to use the settimeout and setinterval to do "animation", but let me know if you don't. here is how to draw a circle in canvas (note the ctx var above, and the ctx. below):
    ctx.lineWidth = 8;
    ctx.strokeStyle = "rgba(0,0,0,1)";
    ctx.arc(X, Y, R, 0, Math.PI*2, true);
    i've done quite a few apps using just canvas (PicSketcher, Cubix, Ballooning, SoccerShots and MazeHunter3D). if you have more quesions feel free to PM me!
    My site: Shanerooni, LLC
    Follow me on Twitter
    My apps: GuessWhat? | MazeHunter3D | Small Wonders | PhakePhoney | AutismAware | PicSketcher | Cubix | QuickSolve | QuickSpell | QuickTrace | QuickWhack | QuickSuite | Soccer Shots | Ballooning |

Tags for this Thread

Posting Permissions