Search the Community
Showing results for tags 'add'.
-
Hey guys, first things first: sorry for my bad english. I have a big problem with phaser. I build a educational game without a webserver and everything's going fine and runs perfectly (using Phaser.CANVAS). But when i load a sound (game.load.audio("theme","assets/music/theme.ogg");) i get this error: "Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https." I've watched online and it seems, i need to have a webserver. But there are some questions and problems with this kind of thing. 1. Why can i add pictures, animations,code and more from my harddrive but music is a no go?! 2. I want the Game runs complete offline. It's important because the guy i am making this game for is teacher and they still have no Internet in his school. (unbelivable but true) 3. If I would setup a local server, then every who gets the game need one to?! it's so frustrating. i build the game as a html-file because this game should go to other schools with linux, mac etc. I just wanted it runs everywhere. With or without internet, no matter what OS is using. But what is a game without a Soundtrack? I have build the whole game and the only thing missing, is sound. I hope somebody can help me.
-
In Babylon.js Is there a way to render animated sprites with an additive (one one) blend mode? Either that or can I use an animated sprite as a particle that uses the particle's one one blend mode? Thanks, -=T=-
-
I am having the hardest time adding a list of objects to my container! For whatever reason, only the last container object appears on the left side of the screen. Any clue as to why only one container is being drawn? If anyone is interested in testing the program, here is a link to the related commit. Parent Container: (function (window) { function ChestManager() { container.Container_constructor(); container.addChest(640,100,1,1,"topClosed"); container.addChest(1100,360,1,1,"sideClosed"); container.addChest(640,620,1,1,"bottomClosed"); container.addChest(180,360,-1,1,"sideClosed"); } //instance of class var container = new createjs.extend(ChestManager, createjs.Container); //shared spritesheet properties var manifest = [{src: "chests.png", id: "chests"}]; container.loader = new createjs.LoadQueue(false); container.loader.addEventListener("complete", handleComplete); container.loader.loadManifest(manifest, true, "img/"); //configure after loaded function handleComplete() { container.spriteSheet = new createjs.SpriteSheet({ framerate: 4, images: [container.loader.getResult("chests")], frames: [[0,0,159,132,0,79.25,65.65],[159,0,193,107,0,98.25,40.650000000000006],[352,0,193,107,0,98.25,40.650000000000006], [545,0,113,147,0,56.5,73.4],[658,0,180,149,0,56.5,75.4],[838,0,180,149,0,56.5,75.4], //center bounds [0,149,116,97,0,57.25,47.75],[116,149,111,94,0,55.25,44.75],[227,149,111,94,0,55.25,44.75]], animations: { //"run": [0, 1, "run"], topClosed: [6], topOpenReward: [7], topOpenNothing: [8], sideClosed: [3], sideOpenReward: [4], sideOpenNothing: [5], bottomClosed: [0], bottomOpenReward: [1], bottomOpenNothing: [2] } }); } //update container.tick = function (event) { for (i=0; i<container.children.length; i++){ if (container.getChildAt(i).isClicked()){ container.removeChest(i); } } } container.addChest = function (x,y,scaleX,scaleY,frame){ container.addChild(new Chest(x,y,scaleX,scaleY,container.spriteSheet,frame)); //add to stage container.getChildAt(container.children.length-1).sprite.on("click", function(evt){ container.getChildAt(container.children.length-1).click(); }); } container.removeChest = function(i){ container.getChildAt(i).sprite.removeEventListener("click"); container.removeChildAt(i); } window.ChestManager = createjs.promote(ChestManager, "Container"); }(window)); Child Container: (function (window) { //constructors function Chest(){ container.Container_constructor(); } function Chest(x,y,scaleX,scaleY,spriteSheet,frame){ container.Container_constructor(); container.initChest(x,y,scaleX,scaleY,spriteSheet,frame); } //instance of class var container = new createjs.extend(Chest, createjs.Container); //initialize Chest container.initChest = function (x,y,scaleX,scaleY,spriteSheet,frame) { container.x = x; container.y = y; container.sprite = new createjs.Sprite(spriteSheet, frame); container.sprite.scaleX = scaleX; container.sprite.scaleY = scaleY; container.sprite.gotoAndStop(frame); container.customText = new CustomText(0,0,scaleX,scaleY,"car"); container.addChild(container.sprite); container.addChild(container.customText); } //public functions container.isClicked = function(){ return container.clicked; } container.click = function() { container.clicked=true; } window.Chest = createjs.promote(Chest, "Container"); }(window)); Result (ignore the backwards 'R' haha)
-
Hi Guys, I was looking for an answer but could not find one so Im sorry if I missed and double post. Im currently working on an small sidescroller game. The enemies are created as group and come from the right into the scene. what I would like to do is add a random name for the enemy displayed as text on top of the enemy, and having the same physical propperties like it (eg gets killed/destroyd if the enemy dies, moves at same speed etc) I suppose I can do this as child from the enemy but I have no idea how to add text this way especially for an "dynamic" text I appreciate any help cheers
-
I created a group with the enemies on the screen. Now I would like to have each enemy hit points (some 2 others 3 others 4, etc ...). Then I thought that if there is way to make a kind of stretched groups phaser (and that he extended class could add a variable to the health points of each enemy ..?) Or do inthe Sprite class phaser .... I do not know how I should approach this. Any help or ideas? Thanks.
-
I'm trying to create a bitmapdata with a single frame from a spritesheet and I'm getting nothing I'm using this, bmd = game.add.bitmapData(800, 800); bmd.add(new Phaser.Sprite(game, 50, 50, 'blocks', 3)); sprite = game.add.sprite(0,0,bmd);but its showing nothing. Am doing something wrong? I tried copypixels aswell and still got nothing, I tried adding the sprite in advance, nothing. (I'm useing phaser 2.0.6) Thanks for the help in advance.
- 3 replies
-
- sprite
- bitmapdata
-
(and 5 more)
Tagged with:
-
create() { var grp = new Phaser.Group(this.game,null); var txt = new Phaser.Text(this.game, 0, 0, "boogaloo", {}); grp.add(txt); }Btw this is typescript. When I use the above code on a state, the text is added to the stage. But I would expect that only to happen when I add the group to the stage. I'm trying to make a popup by extending a Phaser.Group, but when I make it in the create function it just appears on stage, including the buttons on the popup. How do i prepare a popup (an extended group containing sprites,text and buttons) and add it to the stage when i want?