background image not loading - force canvas redraw
Shri

Hi,

 

I am making a version of a top down shooter.

The game starts with a splash screen and then on click, loads a level and then starts like your example top down shooter

The player object/sprite moves on mouse move and fires on a mouse click

The player sprite is 'flying' over water which is a background image sprite loaded when the level starts.

The problem I am seeing is this:

Sometimes when I start the game, if I don't move the mouse, the background image is not visible.

The player plane, and enemy planes are visible, along with enemy bullets.

This situation persists until a bullet strikes the player plane and an explosion animation is run. The the background appears.

 It only happens on the first level, never once the game is running.

I have a callback routine set to track the loaded images, and they are all there so it is not a problem of an image not loaded.

This is an intermittent problem, happening probably one out of 2 or 3 times if I don't move the mouse (player).

 

So, is there a way to set a 'dirty' bit when I load the background image so it is redrawn immediately.

Or is there a call to force a redraw ?

I think I saw in one of the samples you discussing a 'dirty' area setting, but I could not find anything in the documented functions.

 

thanks for any help 

 

cheers

All 9 Comments
Shri

As an addendum to my initial post, I found in the flow sample where you use setDirtyArea() on a sprite to force a redraw.

I tried that on the background image and it didn't seem to change anything.

 

cheers

Gio

is there any chance you could post some of your code to have a look? You could send me a private message if you don't want to show it to everyone. That would be the easiest way to understand your problem and help you fix it.

 

In the meantime, a couple of things to consider:

 

1) Are you using WADE 1.0.1?
2) What type of 'image' is the background sprite? An actual image-based sprite, or vector graphics?

3) Does it work if you move it around? As a test, could you try background.moveTo(10, 10, 10) or something like that and see if it's visible?

4) Do you have any errors in the console?

Shri

Gio,

 

thanks for the reply.

 

I have a few things to wrap up / fix  and then the game will be released. I am planning on making the game and code freely available, The game is a simple top down shooter, but it is more 'complete'  (IMHO and more code) than the example on your sample page. What is the best way to do that ? I noticed that on your site, the only game is Zirma, are you planning on linking to pages ?

 

 

To answer the questions you posed

1) Are you using WADE 1.0.1?

Yes

2) What type of 'image' is the background sprite? An actual image-based sprite, or vector graphics?

Image based sprite.

 

3) Does it work if you move it around? As a test, could you try background.moveTo(10, 10, 10) or something like that and see if it's visible?

Tried this, problem is still there.

 

4) Do you have any errors in the console?

No, it looks ok

 

Anyway, the problem is intermittent and I seem to be seeing it a lot less now.

I made some changes / fixes to the code so maybe I was smashing somemthing somewhere ?

Since this is my first go round with Wade, I assume I am doing several things wrong/inefficiently.

When I put the game/code out, I figure I will hear about some ot the things I am doing wrong.

 

cheers

Gio

Hey

 

I'm glad to hear it's almost finished, I want to see it :) I want to get to the bottom of that problem, so when the code is available I'll certainly have a good look.

 

We are restructuring the website, so we are probably getting rid of that "games" page entirely or maybe link to it from the footer, but either way it won't be very visible.

 

Instead we are working to build a system that would make it easy for community members to share their code and creations with others. It's still a few weeks away, but I'm sure we can think of something in the meantime. Just send me a message when you're happy that your game is ready, and we'll find a temporary solution to link to it until the community features are ready.

Shri

Gio,

 

Thanks for the response regarding this post as well as the sound pausing issue.

I decided to just send you the zipped version of what I have.

I stripped out the sound folder to make the zip smaller, so that is not available. In the code there is a flag which sets sound to false. The rest of the files should be there, the html, css, js and images folder with the necessary png image files.

In the html file, the jquery library is loaded from the net, but wade is loaded from a common directory.

You will have to modify the html to point to wherever you are getting the wade engine from.

Besides that, it should run out of the box (I think).

Anyway take a look at the code if you want and let me know if you see the problem or if I am out in the woods regarding developing with the engine.

 

cheers

Shri

Gio

The game is fun but really hard!

 

I think the code looks good, there isn't much I can suggest to improve it. One thing I should say is that you don't have to worry about removing event listeners when you remove objects from the scene, that's done automatically.

 

I played a few times and couldn't reproduce the problem you mentioned, which browser do you use? 

 

I'm sure this will be even better with sounds - in the short term I'm going to create a forum where you (and hopefully others) can put their games to show other people, get comments and share code. But like I said there's going to be a better way to do this soon.

Elliot

Looking good. Coding style is really nice, but if I may suggest something: you could declare a couple more variables in App, for example:

var scoreboard = wade.app.scoreboard.getBehavior();

So you don't have to type wade.app.scoreboard.getBehavior() so many times :) It would make it easier to read and it's probably a bit faster too.

Gio

OK, I've created a new forum for this, please post your game in there so it remains visible

Shri

Gio,

 

I am mainly using firefox 26.0 and still see the problem intermittently. Don't think I have seen it on Chrome 32.0.1700.6

Maybe if others try the game, something will shake out.

I made some minor fixes to the RAF game and posted it to your temporary games forum.

Per your suggestion, I removed the call to removeEventListener on object deletion.

Per Elliot's suggestion, I added a variable, shortening the access name to the scoreboard behaviors.

I will wait on the next engine release for the sound updates, if it is not there, no big deal.

To post to forums there is a 500K limit. Can this be bumped to 1M ? Background sounds/music can get pretty big,

and then you are uploading 2 of them (aac and ogg).

 

Anyway, thanks for your help, the engine is a lot of fun to work with.

I am looking forward to the physics and isometric realeases.

On to game #2.

 

cheers,

Shri

Post a reply
Add Attachment
Submit Reply
Login to Reply