Skip to content

Instantly share code, notes, and snippets.

function styleDoubleFullscreen(element) {
// Get bazaar-ad children
var children = element.querySelectorAll("div,iframe");
// Style bazaar-ad
element.style.setProperty("height", "calc(200vh + 30px)");
// for desktop
if (window.innerWidth > 500) {
element.style.setProperty("width", "100vw");
element.style.setProperty("left", "-50vw");
@pontusarmini
pontusarmini / ActionRotateAround.swift
Last active November 10, 2015 04:38
A Cocos2d-iPhone/Obj-c/Spritebuilder action that rotates a node around a given point
/*
* Copyright (c) 2015 Pontus Armini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
//
// CCAnimationManager+ExposeSequences.h
//
//
// Created by Pontus Armini on 2015-06-22.
// Copyright © 2015 Pontus Armini. All rights reserved.
//
#import "CCAnimationManager.h"
//
// CCPhysicsCollisionPair+SwiftCollisionPair.h
//
//
// Created by pontus armini on 2015-06-15.
// Copyright © 2015 Pontus Armini. All rights reserved.
//
#import "CCPhysicsNode.h"
@pontusarmini
pontusarmini / Cocos2dSwift.swift
Last active November 10, 2015 04:39
Cocos2d Objective-C to Swift transition snippets
/*
Setting up custom texture parameters:
Firstly, add this to Bridging-Header.h-file: #import "libs/cocos2d-iphone/cocos2d/CCTexture_Private.h"
The ccTexParams struct is set up with GLuint's. The texParams needs to be a 'var' and not a 'let' constant.
*/
var texture = ...
var texParams = ccTexParams(minFilter: GLuint(GL_LINEAR), magFilter: GLuint(GL_LINEAR), wrapS: GLuint(GL_REPEAT), wrapT: GLuint(GL_CLAMP_TO_EDGE))
texture.setTexParameters(&texParams)
/*
@pontusarmini
pontusarmini / Random.swift
Last active November 10, 2015 04:39 — forked from jstn/RandomNumbers.swift
Forked from user jstn. I have added extensions to CGFloat, CGPoint and Bool.
import Darwin
public func arc4random <T: IntegerLiteralConvertible> (type: T.Type) -> T {
var r: T = 0
arc4random_buf(&r, Int(sizeof(T)))
return r
}
public extension UInt {
public static func random(lower: UInt = min, upper: UInt = max) -> UInt {
@pontusarmini
pontusarmini / Soft body CCSprite Swift
Last active April 16, 2020 18:22
Soft body CCSprite originally created by Sébastien Dabet (Gist: https://gist.github.com/sdabet/08a6f41415c5e3b8be0f and article: http://2sa-studio.blogspot.se/2014/05/soft-bodies-with-cocos2d-v3.html) updated for the new rendering engine (Cocos2d-SpriteBuilder >3.1). This is the slightly optimized Swift version set up for use with SpriteBuilder.
import Foundation
import CoreGraphics
class SwiftBubble:CCSprite {
static let π = CGFloat(M_PI)
//Number of segments (the more the smoother circle) and segment radius
static let numSegments = 60
let physicsBodyRadius:CGFloat = 2.0
@pontusarmini
pontusarmini / Soft body CCSprite
Last active April 16, 2020 18:22
Soft body CCSprite originally created by Sébastien Dabet (Gist: https://gist.github.com/sdabet/08a6f41415c5e3b8be0f and tutorial: http://2sa-studio.blogspot.se/2014/05/soft-bodies-with-cocos2d-v3.html) updated for the new rendering engine (Cocos2d-SpriteBuilder >3.1).
//
// SoftBubble.h
//
//
// Created by Pontus Armini on 2015-04-12.
//
//
#import "CCSprite.h"