Cocos2d-x V3. How to determine admob banner height for different screen sizes? - cocos2d-iphone

The rectangle is positioned at y=102.
auto spr = Sprite::create("images/interface/wideBtnBlack.png");
Vec2 origin = Director::getInstance()->getVisibleOrigin();
spr->setColor(Color3B::GREEN);
spr->setPosition(Vec2(origin.x + 200, origin.y + 102));
spr->setAnchorPoint(Vec2::ZERO);
How can I make sure that the rectangle is placed right above the banner for all devices?

You can set Banner Size According to Device. and then By Doing Simple Math You can Achieve what you are Trying to Get. or Use Admob Delegate Method to Get Banner Height.
Banner.Height + (Object.Height/2) = Position Exactly Above Banner.

Related

How to create animated canvas using famo.us integrated to angularjs?

So I try to create animation using canvas in famo.us integreted with angularjs.
I found this directive in docs:
<fa-canvas-surface
fa-size="[400,400]"
class="main-canvas"
>
</fa-canvas-surface>
But I have no ideas (or tutorials) how to access it from my controller.js:
mysiteControllers.controller('UvodCtrl', ['$scope','$famous',
function($scope,$famous) {
}]);
or create an animated object (for example this something like: http://jsfiddle.net/7wEWU/46/ ). Do you have any ideas?
You cannot change the size of the surface in runtime, but you can change the size of a modifier.
To animate the canvas you need to place it inside fa-modifier directive and then use Transitionable to animate size change.
Here is the example of animating surface size from 100x100 to 400x400 over 2s:
mysiteControllers.controller('UvodCtrl', ['$scope','$famous',
function($scope,$famous) {
// gets famous Transitionable
var Transitionable = $famous['famous/transitions/Transitionable'];
// sets initial surface size
$scope.surfaceSize = new Transitionable([100, 100]);
// animates surface size change, sets size to 400x400 during 2000ms
$scope.surfaceSize.set([400, 400], {duration: 2000})
}]);
<fa-modifier fa-size="surfaceSize.get()">
<fa-canvas-surface class="main-canvas">
Surface content
</fa-canvas-surface>
</fa-modifier>
Here are the docs on Transitionables: https://famo.us/docs/transitions/Transitionable
And fa-modifier: https://famo.us/integrations/angular/docs/unstable/api/directive/faModifier/
p.s. you can use Transitionable to animate any of the modifier's attributes (fa-rotate, fa-scale, fa-transform, fa-opacity...)

How could I skew/shear a sprite via SpriteKit like Cocos2D?

In Cocos2D-x, CCNode class provides "skewX" & "skewY" to let me do some distortion of the sprite, however, I fail to find similar mapping in SKNode of SpriteKit.
My game uses Flash to port skeleton animations, in which the configs of positioning, scaling, rotation and shearing of sprites would be decomposed into game-engine's digestive. Except shearing, all other configs do have solutions to be done in SpriteKit.
You can achieve a skew affect using a CGAffineTransform, CoreImage filter and an SKEffectNode
let transform = CGAffineTransform(a: 1, b: 0.1, c: -0.3, d: 1, tx: 0, ty: 0)
let transformValue = NSValue(cgAffineTransform: transform)
let transformFilter = CIFilter(name: "CIAffineTransform")!
transformFilter.setValue(transformValue, forKey: "inputTransform")
let effectNode = SKEffectNode()
effectNode.addChild(sprite) // <-- Add sprite to effect node
effectNode.filter = transformFilter
effectNode.shouldRasterize = true
effectNode.shouldEnableEffects = true
No you can't.
SKNode doesn't have skew* properties. And SKShader allows to use only fragment shader. It means you can change the color of each pixel whatever you want, but you can't change the shape of a sprite.
So I recommend you to use Cocos2d-Swift, Cocos2d-x or so on instead of SpriteKit.
Another option is UIView. You can use the matrix from Adobe Flash to UIView via CALayer transform.

Why is iPhone 5 briefly Letterboxing and displaying Default.png in Cocos2d?

I have Default-568#2x.png which loads fine.
However, (on the actual device) after it shows the iPhone 5 then displays Default.png, in letter box mode. It then loads the 1136 × 640 px Title Screen - which is fine and what it's supposed to do.
I'm using the default Cocos2d HelloWorld template. I haven't changed anything in the plist or otherwise.
Any ideas?
Why does it load the Default.png and how do you fix this?
Thanks.
In the IntroLayer we have
-(void) onEnter
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ) {
background = [CCSprite spriteWithFile:#"Default.png"];
background.rotation = 90;
}
Which is why Default.png is showing up.
How do you keep showing Default-568h#2x.png if you are using the iPhone 5?
I just added another if statement:
if ([UIScreen mainScreen].bounds.size.height == 568.0) {
background = [CCSprite spriteWithFile:#"Default-568h#2x.png"];
background.rotation = 90;
}

Flex Mobile List: How to get rid of grey overlay on renderer tap?

I tried setting all possible styles to something other than grey, just to try and get rid of the grey overlay as shown in the "Hello item 1" in the attached image of a list. Nothing worked. I examined the ListSkin class too and didn't fins anything that would draw these. How to get rid of these overlays?
<s:List id="list" width="100%" height="100%"
dataProvider="{dp}"
focusAlpha="0"
contentBackgroundAlpha="0"
contentBackgroundColor="0xFFFFFF"
selectionColor="0xFFFFFF"
downColor="0xFFFFFF"
borderVisible="false"
>
</s:List>
I just helped a client with this same thing. You, basically, have to extend the LabelItemRemderer class to not draw the rectangle. It is not exposed via styles or colors for you to change.
Look at this code (Starting at line 853 in the LabelItemRemderer):
// Selected and down states have a gradient overlay as well
// as different separators colors/alphas
if (selected || down)
{
var colors:Array = [0x000000, 0x000000 ];
var alphas:Array = [.2, .1];
var ratios:Array = [0, 255];
var matrix:Matrix = new Matrix();
// gradient overlay
matrix.createGradientBox(unscaledWidth, unscaledHeight, Math.PI / 2, 0, 0 );
graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix);
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
graphics.endFill();
}
You basically need some way to force this code to not run. You can do this by creating your own itemRenderer from scratch. Or you can extend the LabelItemRenderer, override the drawBackground() method and copy all the parent drawBackground() code into your extended child; minus the block above.
I'd love to see the color exposed as a style or something. I'd love to see a magic property (or style) we could use to make the overlay vanish altogether. Feel free to log this as a bug into the Apache Flex Jira.

AdWhirl iAd rotation problem

I integrated Adwhirl into my app and activated iAd only. My app is in landscapeleft mode and I want to have all Ads in 320x50(48) mode. I managed to rotate the banner view and the iAd looks right.I did this in the following way:
AdWhirl *adView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[[[Director sharedDirector] openGLView] addSubview:adView];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 150);
transform = CGAffineTransformTranslate(transform, 10, 10);
transform = CGAffineTransformRotate(transform, CC_DEGREES_TO_RADIANS(90));
[adView setTransform:transform];
It works fine in iOS4.2.
However,on device with iOS4.1,only left side of the banner view is clickable.I'm really confused about this behavior.Is there anyone having the same problem?
Any hint would be highly appreciated!
P.S.I tried to set frame,bounds,and center,but that does not solve the problem.