Jump to content

Panda 2 development


enpu
 Share

Recommended Posts

colision: function(opponent){    console.dir(arguments);    console.log('Colision!!!');    //opponent.eliminar();    return true;},

opponent is not reference to Heroe class, it's the body that you are colliding with. So you can't call opponent.eliminar, because there is no eliminar function in Body

Link to comment
Share on other sites

game.module(    'game.main').body(function() {game.addAsset('panda.png');game.addAsset('coin.png');game.createClass('Panda', 'Sprite', {		interactive: true,	mouse: {x:100, y: 100},		init: function(x, y){		this._super('panda.png', x, y, {anchor: { x: 0.5, y: 0.5 }});		this.position = {x: x, y: y};		//body        this.body = new game.Body({            position: { x: x, y: y },            velocityLimit: { x: 150, y: 150 },            velocity: {x:-100,y:-50},            collisionGroup: 1,            collideAgainst: 0,            mass: 0        });        this.body.collide = this.collide.bind(this);        this.body.addShape(new game.Rectangle(60, 60));		//add sprite to scene        game.scene.addObject(this);        //add body of this sprite to the world object        game.scene.world.addBody(this.body);        //add sprite to display container        game.scene.stage.addChild(this);	},	    collide: function(opponent) {		console.dir(arguments);		console.log("Collision!");		opponent.remove();        return true;    },    update: function(){		this.position.x = this.body.position.x;		this.position.y = this.body.position.y;        this.body.velocity.x = (this.mouse.x - this.body.position.x);        this.body.velocity.y = (this.mouse.y - this.body.position.y);    },    remove: function() {        game.scene.removeObject(this);        game.scene.world.removeBody(this.body);        game.scene.stage.removeChild(this);    },        mousemove: function(e) {		this.mouse.x = e.global.x;		this.mouse.y = e.global.y;    }    });game.createClass('Coin', 'Sprite', {	init: function(x, y){		this._super('coin.png', x, y, {anchor: { x: 0.5, y: 0.5 }});		this.position = {x: x, y: y};		//body        this.body = new game.Body({            position: { x: x, y: y },            velocityLimit: { x: 300, y: 1000 },            velocity: {x:0,y:0},            collisionGroup: 0,            mass: 0        });        this.body.remove = this.remove.bind(this);        this.body.addShape(new game.Circle(10));		//add sprite to scene        game.scene.addObject(this);        //add body of this sprite to the world object        game.scene.world.addBody(this.body);        //add sprite to display container        game.scene.stage.addChild(this);	},    update: function(){		this.position.x = this.body.position.x;		this.position.y = this.body.position.y;    },    remove: function() {        game.scene.removeObject(this);        game.scene.world.removeBody(this.body);        game.scene.stage.removeChild(this);    }});game.createScene('Main', {    backgroundColor: 0xb9bec7,    init: function() {		this.world = new game.World(0, 0);				for(var i=0; i<10; i++){			coin = new game.Coin(Math.random()*game.system.width, Math.random()*game.system.height);		}		var panda = new game.Panda(300,200);    }});});

but if you look at the example that put this as such as what you send, look at the code example.

Link to comment
Share on other sites

@enpu

 

I'm trying to accomplish this example: http://phaser.io/exa...ra/basic-follow

 

http://vermeire.home.xs4all.nl/panda/fiddler.html, In the examples of the fiddler, I saw an example of using the camera in panda. 

 

Ok watching these videos, I think it will help you understand a little.

 

urrently the example in the fiddle, can only do this. ( https://dl.dropboxusercontent.com/u/62623895/Images/camera%20test/fiddle-1.webm )

 

Modify it and add a line of code, and reach that work like the example I want to make. the example is made of phaser. ( https://dl.dropboxusercontent.com/u/62623895/Images/camera%20test/fiddle-3.webm )

 

Ok when all good, but I'm working with the development version panda engine 2.0.0.

 

In this video, my code works as it is the code on the fiddle. to be more clear as the first video. ( https://dl.dropboxusercontent.com/u/62623895/Images/camera%20test/tests-1.webm )

 

As you saw in the second video, just add the line of code to add the camera to the scene, in my video I make the same.but it does not work, stop working even.
 
Well, so far as you can see me the code does not work, do not know why.
 
but as you see, I worked as it was the first video.
 
Now this last line, which have added, in the second line, look at the video. ( https://dl.dropboxusercontent.com/u/62623895/Images/camera%20test/test-3.webm )
 
now it works as it is the example in the fiddle and the first video. but it does not work the way I want it to work.
 
the question is that if the code is the same, but is not working. and if you help me in this small, and that is the last part that I need to put to work the camera.
 
this is my code VS the code example of the fiddle
 
My code ( https://db.tt/mjeKLH0K ), Example Fiddle ( https://db.tt/Umnn20hn )
 
Thanks for your help.
Link to comment
Share on other sites

@enpu

 

In the end I finished reading the camera.js class, to make it work.

 

I understood many things, and I managed to work, hmm but a little flawed.

 

To make it work, create a container where the objects would be captured would create, that is a general container. sprite has its own container and container text and added them to the general sprite container.

this.camera = new game.Camera();this.camera.addTo(this.contenedorMundo); //Main container, is assumed that this should be the stage.this.camera.offset.set(game.width / 3, game.height / 2);this.camera.minX = 0; this.camera.minY = 0;this.camera.maxX = 2800;  this.camera.maxY = 1800;this.camera.setSensor(10,10);this.camera.setTarget(this.contenedor); //Container sprite.

I doubt this genre. if in a scene the stage is a container, I had to create one for it to work the camera.

 

And the other as you can see in the video, the camera moves either to the right and down, but the left and top do not function. ( https://db.tt/iUVXgXTA )

Link to comment
Share on other sites

Is the TilingSprite class available yet? I downloaded the latest version of the develop fork, but when I try to instantiate a TilingSprite, I get a "TypeError: Cannot read property 'resolve' of null" console message. 

 

It fails on something like this: var bg = new game.TilingSprite('graphics/bgImage.png', 200, 300);

 

Am I somehow doing this wrong?

 

Thanks!

Link to comment
Share on other sites

@goide

 

Thanks for the reply. Did you test this yourself? I've done that and it doesn't work on my end. 

 

enpu stated a few weeks ago (on page 9 of this thread) that TilingSprite was "almos[t] done" while providing a link to a working TilingSprite playground. Maybe it's still not quite done?

Link to comment
Share on other sites

Weird. I still can't seem to get it to work. Downloading the most recent version of the develop branch and using the exact code from the Playground with a panda.png downloaded in the root, it won't work.

 

Erasing "Tiling" to make it a normal Sprite works just fine. Having the "addAsset" function above also seems to make the load hang even when it's just the normal Sprite.

 

This is tested using Brackets and WebStorm's built-in local server on Windows 8 with Chrome and Firefox.

 

Not sure what I'm doing wrong.

Link to comment
Share on other sites

Hi @enpu

 

Just a few things I found working with the latest dev version ...

 

1. I've noticed that when I setup a sprite and set it's alpha to 0, its hitArea doesn't seem to show at the co-ordinates given to it.

Instead it gets drawn in the top-left corner of the screen, until the sprite's alpha is more than 0.

 

2. Using the 'new game.Animation.fromFrames' function seems to throw frames out of order. This doesn't happen when I setup the animation manually.

 

3. .mouseupoutside and .touchendoutside don't work (aren't implemented?).

 

Thank you!

Link to comment
Share on other sites

  • 2 weeks later...

RE: TilingSprite issue

 

I got it to work by putting in the game.addAsset statement for the graphic file. Why is addAsset required for TilingSprite but not ordinary Sprite?

 

On a separate note, is there a convenient way to add physics to particles emitted, without having to create a custom particle class and custom emitter for those particles?

 

Thanks!

Link to comment
Share on other sites

Hey Enpu, I haven't found any discussion about it and I really wanted to know if it is possible to stop event bubbling in panda? lets say I have a big sprite that is clickable and many small sprites on top which are also clickable. when I click on the small sprites I don't want the big sprite event handler to be fired. I had already tried event.stopPropagation() but it didn't stop the event from bubbling.

Link to comment
Share on other sites

  • 2 weeks later...

Hi @enpu

 

Just wondering if you've had a chance to look at a few of the bug/issues I posted above? I'm only wondering in case you missed the post :)

 

Thank you!!!

 

Here is the list of issues I've found ...

 

- An object with alpha 0 does not seem to respond to mouse clicks.

 

- Using the 'new game.Animation.fromFrames' function seems to throw frames out of order. This doesn't happen when I setup the animation manually.

 

- .mouseupoutside and .touchendoutside don't work (aren't implemented?).

Link to comment
Share on other sites

@Ninjadoodle

 

Sorry for the delay.

 

When object is not visible, renderer won't update it's transform. So if it's alpha is 0 before it's first time added to stage, it's transform never gets updated, and then mouse events won't work. In that case, you can try manually update it's transform (after it's added to stage or another container). sprite.updateTransform()

 

game.Animation.fromFrames uses the order in texture cache. Are you using sprite sheets? Do you have your frames in correct order in your JSON?

 

I just pushed update with mouseupoutside implemented. Let me know if you got any issues with it :)

Link to comment
Share on other sites

@enpu are there plans to add sprite tinting? In the previous version I used it a lot for light effects where I could have one black and white sprite representing the lighting and tint it with whatever color I wanted on the fly and then set the blend mode of this sprite to ADD.

Link to comment
Share on other sites

Hi @enpu

 

I tried loading my game on iPad Air and all the graphics look completely messed up on screen.

 

Things work fine on iPhone 4s and iPhone5s, but on Galaxy S5 only the low res assets seem to be loaded (i have @4x enabled).

 

Not really sure whats causing this, just wanted to let you know :)

 

Thank you!

Link to comment
Share on other sites

Hi @enpu

 

I wanted to ask what are the best practices for working with custom particles? I want to define a custom particle that will have a blending mode, an anchor point, expand outwards and rotate based on the emitter's rotation for example. I got something working but it's messy and seems a lot more complicated than it should be... I had to extend a few base game modules to get it to work.

 

Edit:

Ok I think I figured what the best way to do this is. you just need to re-define the game.Emitter.addParticle function to whatever you want your particle to do. so:

var emitter = new game.Emitter();emitter.addParticle = function(){    // -- your particular particle code});
Link to comment
Share on other sites

  • enpu unpinned this topic

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...