Sign in to follow this  

Camera does not move properly with container

Recommended Posts


When a camera Is added to a moving container, it does not update its position unless the target moves out of the sensor field. To me this looks like a bug. Is it possible to work around it?

.body(function() {


game.createScene('Main', {
    init: function() {
        this.container = new game.Container();

        var bg = new game.TilingSprite('sprite.png', game.width * 2, game.height * 2);
        bg.alpha = 0.2;
        this.circleContainer = new game.Container();

        this.sprite = new game.Graphics();
        this.sprite.drawCircle(10, 10, 10);
        this.sprite.addTo(this.circleContainer); = new game.Camera(this.sprite);;

    update: function() {
        var speed = 200;
        this.circleContainer.y -= 10 *;
        if (game.keyboard.down('LEFT')) this.sprite.x -= speed *;
        if (game.keyboard.down('RIGHT')) this.sprite.x += speed *;
        if (game.keyboard.down('UP')) this.sprite.y -= speed *;
        if (game.keyboard.down('DOWN')) this.sprite.y += speed *;



Share this post

Link to post
Share on other sites

Is it bug????

I always use this method to make some sprite or shape fix into camera view.

if I want to make some sprite to fix into camera view and don't want to put it in 'stage'

I will create fixed_camera_container to make the sprite to fix into camera view.

this.fixed_camera_container = new game.Container();
this.fixed_camera_container .addTo(this.stage);
this.container = new game.Container();

this.healthbar = new game.healthbarClass();  //Fixed to camera

this.player = new game.playerClass(); 
this.player.sprite.addTo(this.container); = new game.Camera(this.player.sprite);;




Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.