Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas still empty #39

Closed
yckart opened this issue Apr 3, 2013 · 10 comments
Closed

Canvas still empty #39

yckart opened this issue Apr 3, 2013 · 10 comments
Assignees

Comments

@yckart
Copy link

yckart commented Apr 3, 2013

I try to accomplish the YAZ-demo, without the fish-sprite (is that even possible?). However the canvas element is still empty. What I'm doing wrong? http://fiddle.jshell.net/pdcBR/

// FlashJS
var stage = new Stage("canvas");
var testObject = new DisplayObject();
testObject.width = 100;
testObject.height = 100;
testObject.x = 0;
testObject.y = 0;
testObject.rotation = 18;
testObject.fillColor = '#f00';

stage.addChild(testObject);
@PixelsCommander
Copy link
Owner

fillColor is deprecated in 0.5

We are currently updating examples on flashjs.com.

Please, check Yazz and other examples from repository. There are a lot new about most recent FlashJS features which move game development with FlashJS to new level of responsivity. Put more attention to ScalingAssets example and it`s description (at the bottom of index.html).

@ghost ghost assigned PixelsCommander Apr 3, 2013
@yckart
Copy link
Author

yckart commented Apr 3, 2013

Ok, good to know, however I can't find the Yazz-example in this repo (and even this). At the bottom of ScalingAssets -index.html is no description.

Update: Can you make my test work? Or even better, can you prepare a simple example, how we've to use FlashJS without sprites (Something like this or this)?

@PixelsCommander
Copy link
Owner

Try it now - Yazz for 0.5v was commited today as answer to your issue.

As for description - in fact it`s in the bottom of HTML code inside P tag.

For better understantion it`s better to try this example alive in browser.

To avoid Chrome security restrictions for local AJAX requests close all Chrome instances and run "open -a Google\ Chrome --args --disable-web-security --allow-file-access-from-files" command from Mac terminal or "C:\Users\YOUR_USER\AppData\Local\Google\Chrome\Application\chrome.exe --allow-file-access-from-files --disable-web-security" for Windows command promt.

This is needed during local sendboxing because FlashJS loads AssetsList declarations as JSON files for ex.: https://github.com/PixelsCommander/FlashJS/blob/master/examples/scaling-assets/assets/main-assets.json . This is simple and effective way to emulate Flash Symbols library and divide JS code from sounds, animations, images declarations.

@yckart
Copy link
Author

yckart commented Apr 3, 2013

Ok nice, thanks for that so far! However, my question is still unanswered. So, how can I use FlashJS without assets (just with the raw canvas context)? Do we use DisplayObject for this? A simple fiddle would be enough!

@PixelsCommander
Copy link
Owner

Yazz does not use AssetsList and code is quite simple:

var stage = new Stage('#yazzStage', 800, 600, {multiResolution: false});
var testObject = new DisplayObject('../../assets/yazz.jpg');

testObject.x = 100;
testObject.y = 100;
testObject.rotation = 18;

stage.addChild(testObject);

stage.onEnterFrame = function(){
testObject.rotation++;
}

@yckart
Copy link
Author

yckart commented Apr 3, 2013

Yeah, thats clear, however I don't understand the way we can use the canvas-context with FlashJS's features. Let's say we want to replace the yazz.jpg with a simple rectangle, like this:

context.fillStyle = "#f00";
context.fillRect(0, 0, 100, 100);

How can we accomplish this?

@PixelsCommander
Copy link
Owner

You can try to draw on testObject.cacheCanvas

@yckart
Copy link
Author

yckart commented Apr 5, 2013

I know, I'm troublesome! Anyway, can you prepare a simple example how to work with the canvas context? Maybe a simple rect with some mouse events?

@PixelsCommander
Copy link
Owner

Sorry for making you wait for better feedback.

At the moment there is no drawing API in FlashJS. So for now Its a question about canvas API, not FlashJS. I`ll try to find good sample and present it here.

Multiresolution drawing API similar to Flash one will be amazing contribution to FlashJS. Sad but I have not time to add this API in nearest future, but would be glad to help in any work on this, please contact me if you`ll have any questions.

@yckart
Copy link
Author

yckart commented Apr 14, 2013

#40

@yckart yckart closed this as completed Apr 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants