Skip to content

Asynchronous loading texture #3350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 18, 2016
Merged

Asynchronous loading texture #3350

merged 19 commits into from
Aug 18, 2016

Conversation

VisualSJ
Copy link
Contributor

CCEventHelper

  • removeEventListener must be incoming listener
  • add removeEventTarget

CCSprite

  • When setting the texture, you need to clear the callback

Menu/Scale9Sprite/Button asynchronous loading texture

if ( this._listeners === undefined )
return;

var listeners = this._listeners;
var listenerArray = listeners[ type ];
if (!listenerArray) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this, you are checking it in the next if

@VisualSJ
Copy link
Contributor Author

Each interface for replace texture need to judge the state of loaded
In the case of load===false, Increase the waiting listener.

The listener will call the function again after the completion of loading.
Before is the direct execution function, then update data after loading successfully, update logic is too confusing...

@VisualSJ
Copy link
Contributor Author

@pandamicro

@@ -257,7 +257,19 @@ ccui.Scale9Sprite = cc.Scale9Sprite = cc.Node.extend(/** @lends ccui.Scale9Sprit
_getPreferredHeight: function () {
return this._preferredSize.height;
},

_asyncSetPreferredSize: function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uniform update after successful loading

@pandamicro pandamicro merged commit c55c739 into cocos2d:develop Aug 18, 2016
@1scaR1
Copy link
Contributor

1scaR1 commented Aug 18, 2016

Something strange with sprite positions if some non-trivial transformations are applied to them(for example with composition from parent's transform)

@pandamicro
Copy link
Contributor

for example with composition from parent's transform)

I don't understand, what do you mean by compositing parent transform ?

@1scaR1
Copy link
Contributor

1scaR1 commented Aug 19, 2016

I found example when anchor point is ignored:

        cc.spriteFrameCache.addSpriteFrames(res.some_plist);

        this.setContentSize(cc.director.getWinSize());

        var firstLayer = new cc.LayerColor(cc.color.RED);
        firstLayer.setContentSize(600,600);
        firstLayer.setScaleY(0.5);

        var secondLayer = new cc.LayerColor(cc.color.GREEN);
        secondLayer.setRotation(45);
        secondLayer.setContentSize(600,600);

        var sprite1 = new cc.Sprite(cc.spriteFrameCache.getSpriteFrame('some_frame_name.png'));

        secondLayer.addChild(sprite1);
        firstLayer.addChild(secondLayer);
        firstLayer.setPosition(300,50);

        this.addChild(firstLayer);

In this example center of sprite1 must be at left-center corner of green layer. But it is in green layer(like anchor point is ignored).
It only works with sprite frames, not directly loaded texture.

@pandamicro
Copy link
Contributor

@1scaR1 Sorry just see your comment, I have asked @VisualSJ to take a look

@VisualSJ
Copy link
Contributor Author

VisualSJ commented Aug 24, 2016

Thanks @1scaR1

Before the default value is set in the initTexture...

The default value should be set within the ctor...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants