About cocos2d isometric camera - cocos2d-iphone

I want to implement a isometric view. see the image. How to set CCLayer CCCamera property can do this?
Rotate and Scale can not to do this, because rotate and scale at same time.

Obviously this is far too late for you to use, but for anyone looking at this by googling "cocos2d isometric transformation rotate skew" or something like that like I was: I figured out the right skews and rotations. A two-layer approach was needed due to the lack of a diagonal scale or Z rotation. For javascript devs: this makes an isometrically transformed DrawNode. I'm not sure what performance impact this has, but since it's only using the native functions I don't believe it has much if any. For other languages, it should be trivial to port.
var MapContainer = cc.Layer.extend({
ctor: function(){
this._super();
this.scaleX = .947;
this.setAnchorPoint({x:0, y:0});
this.drawNode = new MapDrawNode();
this.addChild(this.drawNode);
return true;
},
drawNode: null
});
var MapDrawNode = cc.DrawNode.extend({
ctor: function(){
this._super();
this.setAnchorPoint({x:0, y:0});
this.y = 360; // shifts everything up, adjust as needed. Mine is 1/2 window size
this.transform();
// Your init code here
return true;
},
transform: function(){
this.setScaleX(0.81649658);
this.setScaleY(0.81649658);
this.setSkewX(16.3);
this.setSkewY(16.3);
this.setRotationY(45);
this.setRotationX(45);
}
});
Proof: check the image at the url since I don't have 10 rep to post it inline. http://i.stack.imgur.com/T3uU8.png

Related

chart.js how to draw arrow instead bar

What is the easiest way to draw an arrow instead of the bar?
I have tried this method, to add an image in every point, but the arrow is not responsive and I can't set the size of each arrow image.
// Variables 'sun' and 'cloud' are created before with `new Image()`
Chart.pluginService.register({
afterUpdate: function(chart) {
chart.config.data.datasets[0]._meta[0].data[7]._model.pointStyle = sun;
chart.config.data.datasets[1]._meta[0].data[2]._model.pointStyle = cloud;
}
});
And will give you this result.
I have achieved it here JSFiddle link.

Styling openlayers draw interaction

In the default openlayers draw interaction, there is no line segment which connects where your mouse is to the finish point (first image). When I set up a custom style, this segment is present which I don't want (second image). Does anyone know how I eliminate this final segment, like the default style does?
You'll need a style function that can style points, lines and polygons and distinguish by the geometry's type. Important: the polygon style should only have a fill, not a stroke. Because the boundary of the polygon is a separate linestring. A minimal working style function for the draw interaction would look like this:
var styles = {
Point: new ol.style.Style({
image: new ol.style.Circle()
}),
LineString: new ol.style.Style({
stroke: new ol.style.Stroke()
}),
Polygon: new ol.style.Style({
fill: new ol.style.Fill()
})
};
function styleFunction(feature) {
return styles[feature.getGeometry().getType();
}

Subviews disappears while performing Flip Transition second time?

I'm performing flip view transition on two views, which are bounded in A Container View. Flippng them first time is working fine. On second time views Frame goes out of view.
like
[<UIView: 0x7fc2316aa030; frame = (-154 -529; 0 0); autoresize = RM+BM; layer = <CALayer: 0x7fc2316aa1a0>>]
After flipping again, it shows container view.
It's working fine if I Uncheck "Use Autolayout" in my project.
But wWhat to do if I am using AutoLayout???
Here is code:
#IBAction func flipViews()
{
if a==false
{
UIView.transitionFromView(new, toView: old, duration: 1, options: .TransitionFlipFromLeft, completion: {(isFinished : Bool)
in
print(self.view_Effects.subviews)
// self.old.frame=self.view_Effects.frame
})
a=true
}
else
{
UIView.transitionFromView(old, toView: new, duration: 1, options: .TransitionFlipFromLeft, completion:{(isFinished : Bool)
in
print(self.view_Effects.subviews)
//self.view_Effects.hidden=true
//self.new.frame=self.view_Effects.frame
})
a=false
}
When I layout my views, all start work just fine. When you make a transform, it's important to remember, that autolayout always calculate your views bounds and frame, based on constraints that you set. So, in my case, I just added center vertical and horizontal align, width and height to my rotated view, so the autolayout mechanism knows when exactly my view is. And all goes just fine. Here is a good autolayout tutorial
http://www.raywenderlich.com/50319/beginning-auto-layout-tutorial-in-ios-7-part-1

Famo.us - StateModifiers disappearing?

Wondering if someone might help with another pair of eyes - as I am trying to work out why some of my Famo.us 'Views' are being displayed despite having an opacity StateModifier set to '0'.
Here is my code - My apologies for it not being standard - I have "Panels" instead of "Views" and a few other things..but happy to expand on the code if needed.
function _buildSidePanel() {
this._sidePanel = _createPanel.call(this);
this._sidePanel.setOptions(this.constructor.DEFAULT_OPTIONS.sideMenu);
this._sidePanel.position = this.cm(this.constructor.DEFAULT_OPTIONS.sideMenu.position);
this._container.add(this._sidePanel.position).add(this._sidePanel);
this._menuHolder = _createPanel.call(this); //My version of a View
this._menuHolder.setOptions(this.constructor.DEFAULT_OPTIONS.sideMenu.menuHolder);
// Create StateModifiers
this._menuHolder.position = this.cm({ align: [.5,.6], origin: [.5,.6], proportions: [.9,.8] });
this._menuHolder.fadeState = this.cm({ opacity: 0 });
this._menuHolder.sizeState = this.cm();
this._menuHolder.mC = new ModifierChain();
this._menuHolder.mC.addModifier(this._menuHolder.fadeState);
this._menuHolder.mC.addModifier(this._menuHolder.sizeState);
this._menuHolder.mC.addModifier(this._menuHolder.position);
/* Tried splitting it to just modifiers but getting the same thing
this._sidePanel._container.add(this._menuHolder.fadeState)
.add(this._menuHolder.sizeState)
.add(this._menuHolder.position)
.add(this._menuHolder);
*/
this._sidePanel._container.add(this._menuHolder.mC).add(this._menuHolder);
// this._menuHolder.fadeState.setOpacity(1,this.constructor.DEFAULT_OPTIONS.sideMenu.menuHolder.transition.in);
}
I have created a ModifierChain and added among other things an Opacity State of 0. When I add this and then add the modifier and 'View' to the container it displays the View even though the View has a StateModifier of '0' so should not be displayed.
The 'fadeState.setOpacity' command is meant to transition the fadeState to display the View but it is commented out, so the View should not be displayed.
I have this working in other areas so know the approach works. I am also (hopefully) not using the same variable names, so not using a StateModifier more than once. But still stuck as to why this is being displayed.
Any help or thoughts would be gratefully appreciated.
Thanks.

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.