Henryk

tween and adjust alpha of element not working

Recommended Posts

Hi folks,

 

I don't know if this is a phaser issue or it has to do with ME?

 

I wanted to tween the alpha of a group and it does not work as expected.

Later on I was trying even with a text element and its the same.

 

What happens is the following:

 

I can decrease the alpha by 0.1 manually and nothing happens until the alphas value gets down to zero. I guess then phaser internally sets the element to "visible = false"?

 

Anyway, I can't tween the value and that's the problem.

 

Share this post


Link to post
Share on other sites

Hi,

 

can you give a little more info - or code fragment?

 

Just made a little test case:

 

http://mightyeditor.mightyfingers.com/data/projects/p292i/AlphaGroup/index.html
animation + group alpha works there.

 

http://mightyeditor.mightyfingers.com/#p292i

var testGroup = mt.create("Group");mt.createTweens(testGroup);testGroup.mt.movies.alphaBlink.start().loop();

Probably there is special bug case. I need a little bit more info from you. Code or sample project with bug would be ideal :) 

Share this post


Link to post
Share on other sites

Pues, I will try:

"use strict";window.sc.state.end = {	preload: function(){		console.log('------------------');		console.log('WIN STATE STARTED');	},		create: function(){				this.initWin();		this.checkPoints();		this.setUpBtns();	},		initWin: function(){		console.log('points: ' + points);		// Game Group		this.gEnd = mt.create("End");		this.kidsWin = this.gEnd.mt.children;			// HappyEnd			this.gHappyEnd = this.kidsWin.HappyEnd;			this.gHappyEnd.visible = false;			this.kidsHappyEnd = this.gHappyEnd.mt.children;					// HappyEnd Elements			// UI			this.gUI = this.kidsWin.UI;			this.kidsUI = this.gUI.mt.children;					// UI Elements				this.btnNehmen = this.kidsUI.btnNehmen;	},	setUpBtns: function(){				        this.btnNehmen.inputEnabled = true;        // add Preis Click Events        this.btnNehmen.events.onInputUp.add(this.onClickNehmen, this);	},		onClickNehmen: function(){			this.gUI.visible = false;		this.gHappyEnd.visible = true;		this.gHappyEnd.alpha = 0.5;                // traces 0.5, but doesnt look like it		console.log('this.gHappyEnd.alpha:  ' + this.gHappyEnd.alpha); 			},	};

I took out all the non relevant elements and functions...

Share this post


Link to post
Share on other sites

Ahh, misunderstanding!

 

You meant an animation created within ME. I meant a tween applied via code.

Mhm, but it's true, I could set up my animations in ME...

 

Btw, can I set callbacks to animations created within ME?

testGroup.mt.movies.alphaBlink.onComplete();

Share this post


Link to post
Share on other sites

Does this example has same functionality?
http://mightyeditor.mightyfingers.com/#p292o

http://mightyeditor.mightyfingers.com/data/projects/p292o/AlphaGroup/index.html - click on the car

"use strict";var group, racer;window.AlphaGroup.state.play = {	preload: function(){			},		create: function(){				var gContainer = mt.create("Container");		racer = gContainer.mt.children.racer1;		group = gContainer.mt.children.Group;				group.visible = false;						racer.inputEnabled = true;        // add Preis Click Events        racer.events.onInputUp.add(this.onClickNehmen, this);	},		onClickNehmen: function(){		group.visible = true;		group.alpha = 0.1;				var tw = this.game.add.tween(group);		tw.to({alpha: 1}, 1000);		tw.start();	},		update: function(){			},	};

Your code should work - everything looks fine.

Share this post


Link to post
Share on other sites

movie.onComplete.add(yourCallback, context);

onComplete is a Phaser.Signal - http://docs.phaser.io/Phaser.Signal.html
 

same demo
http://mightyeditor.mightyfingers.com/#p292p

http://mightyeditor.mightyfingers.com/data/projects/p292p/AlphaGroup/index.html

var group, racer;window.AlphaGroup.state.play = {	preload: function(){			},		create: function(){				var gContainer = mt.create("Container");		racer = gContainer.mt.children.racer1;		group = gContainer.mt.children.Group;				group.visible = false;		mt.createTweens(group);		group.mt.movies.alphaBlink.onComplete.add(this.onAnimEnd, this);				racer.inputEnabled = true;        // add Preis Click Events        racer.events.onInputUp.add(this.onClickNehmen, this);	},		onAnimEnd: function(){		alert("DONE!");		},		onClickNehmen: function(){		group.visible = true;		group.alpha = 0.1;		group.mt.movies.alphaBlink.start();	},		update: function(){			}};

imo - you should use Phaser.Tween if you don't need fancy things :)

Phaser.tween should be faster. ME TweenCollection -  is just a wrapper for multiple phaser tweens.

Share this post


Link to post
Share on other sites

Thanks for your fast reply. Mhm,

I guess I need to dig deeper in my code to find the problem.

 

Good to know, I can apply callbacks to ME Tweens. And yes, I'll use ME Tweens only for animations that'd be rather comlicated to set up via code.

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.

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

  • Recently Browsing   0 members

    No registered users viewing this page.